예제 #1
0
        public Form4()
        {
            InitializeComponent();

            string connectionString = CM.AppSettings["connectionString"];

            Connection = new IrbisConnection();
            Connection.ParseConnectionString(connectionString);
            Connection.Connect();

            Grid = new SiberianTermGrid
            {
                Dock = DockStyle.Fill
            };
            Controls.Add(Grid);

            TermParameters parameters = new TermParameters
            {
                //Database = "IBIS",
                NumberOfTerms = 100,
                //ReverseOrder = false,
                StartTerm = "K=",
                //Format = null
            };

            TermInfo[] terms = Connection.ReadTerms(parameters);
            terms = TermInfo.TrimPrefix(terms, "K=");

            Grid.Load(terms);

            FormClosed += _FormClosed;
        }
예제 #2
0
        public void ReadTerms_Backward()
        {
            IrbisConnection connection
                = Connection.ThrowIfNull("Connection");

            TermParameters parameters = new TermParameters
            {
                Database      = "IBIS",
                NumberOfTerms = 3,
                ReverseOrder  = true,
                StartTerm     = "K=C",
                Format        = null
            };

            TermInfo[] terms = connection.ReadTerms
                               (
                parameters
                               );

            string text = string.Join
                          (
                "; ",
                TermInfo.TrimPrefix(terms, "K=")
                .Select(term => term.Text)
                .ToArray()
                          );

            Write(text);
        }
예제 #3
0
        public void ReadTerms_Format()
        {
            IrbisConnection connection
                = Connection.ThrowIfNull("Connection");

            TermParameters parameters = new TermParameters
            {
                Database      = "IBIS",
                NumberOfTerms = 10,
                ReverseOrder  = false,
                StartTerm     = "K=",
                Format        = IrbisFormat.Brief
            };

            TermInfoEx[] terms = (TermInfoEx[])connection.ReadTerms
                                 (
                parameters
                                 );

            string text = string.Join
                          (
                "| ",
                terms.Select
                (
                    item => item.Formatted.SafeSubstring(0, 10)
                )
                          );

            Write(text);
        }
예제 #4
0
        static void DumpTerms()
        {
            bool           first      = true;
            TermParameters parameters = new TermParameters
            {
                Database      = connection.Database,
                StartTerm     = TermPrefix,
                NumberOfTerms = 1000
            };

            while (true)
            {
                if (Cancel)
                {
                    break;
                }

                TermInfo[] terms = connection.ReadTerms(parameters);
                if (terms.Length == 0)
                {
                    break;
                }

                int start = first ? 0 : 1;
                for (int i = start; i < terms.Length; i++)
                {
                    if (Cancel)
                    {
                        break;
                    }

                    TermInfo term = terms[i];
                    if (!term.Text.SafeStarts(TermPrefix))
                    {
                        break;
                    }
                    if (term.Count > 1)
                    {
                        DumpTerm(term.Text);
                    }
                }

                if (terms.Length < 2)
                {
                    break;
                }
                string lastTerm = terms.Last().Text;
                if (!lastTerm.SafeStarts(TermPrefix))
                {
                    break;
                }
                parameters.StartTerm = lastTerm;
                first = false;
            }
        }
예제 #5
0
        public static TermInfo[] GetTerms
        (
            [NotNull] string year
        )
        {
            Code.NotNull(year, "year");

            int    prefixLength = Prefix.Length;
            string start        = Prefix + year;

            TermInfo[] result;
            using (IrbisConnection connection = GetIrbisConnection())
            {
                TermParameters parameters = new TermParameters
                {
                    Database      = connection.Database,
                    StartTerm     = start,
                    NumberOfTerms = 1000
                };
                result = connection.ReadTerms(parameters);
            }

            result = result
                     .Where
                     (
                term => term.Text
                .ThrowIfNull("term.Text")
                .StartsWith(start)
                     )
                     .Select
                     (
                term => new TermInfo
            {
                Count = term.Count,
                Text  = term.Text
                        .ThrowIfNull("term.Text")
                        .Substring
                        (
                    prefixLength,
                    term.Text
                    .ThrowIfNull("term.Text")
                    .Length - prefixLength
                        )
            }
                     )
                     .ToArray();

            Array.Sort(result, _TermComparison);

            return(result);
        }
예제 #6
0
        static void AnalyzeTerms()
        {
            TermParameters parameters = new TermParameters
            {
                Database      = connection.Database,
                StartTerm     = "RD=",
                NumberOfTerms = 10000
            };

            TermInfo[] terms = connection.ReadTerms(parameters);
            terms = terms.Where(ti => ti.Text.SafeStarts("RD=201"))
                    .ToArray();
            terms = TermInfo.TrimPrefix(terms, "RD=");
            foreach (TermInfo term in terms)
            {
                DateTime date = IrbisDate.ConvertStringToDate(term.Text);
                Console.WriteLine("{0:yyyy-MM-dd}\t{1}", date, term.Count);
            }
        }
예제 #7
0
        public void ReadPostings_Test3()
        {
            IrbisConnection connection
                = Connection.ThrowIfNull("Connection");

            TermParameters termParameters = new TermParameters
            {
                Database      = "IBIS",
                NumberOfTerms = 3,
                ReverseOrder  = false,
                StartTerm     = "K=",
                Format        = null
            };

            TermInfo[] terms = connection.ReadTerms
                               (
                termParameters
                               );

            PostingParameters postingParameters = new PostingParameters
            {
                Database    = "IBIS",
                ListOfTerms = terms.ThrowIfNullOrEmpty("terms")
                              .Select(t => t.Text).ToArray(),
                NumberOfPostings = 3,
                Format           = IrbisFormat.Brief
            };

            TermPosting[] postings = Connection.ReadPostings
                                     (
                postingParameters
                                     );

            string text = string.Join
                          (
                "| ",
                postings.Select(p => p.ToString())
                          );

            Write(text);
        }
예제 #8
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: <connectionString> <termPrefix>");

                return;
            }

            string connectionString = args[0];
            string termPrefix       = args[1];

            try
            {
                using (IrbisConnection connection
                           = new IrbisConnection(connectionString))
                {
                    TermParameters parameters = new TermParameters
                    {
                        Database      = connection.Database,
                        StartTerm     = termPrefix,
                        NumberOfTerms = 100
                    };
                    TermInfo[] terms = connection.ReadTerms(parameters);
                    Console.WriteLine("Found terms: {0}", terms.Length);
                    foreach (TermInfo term in terms)
                    {
                        DumpTerm(connection, term);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }