Пример #1
0
        private void buttonShowContent_Click(object sender, System.EventArgs e)
        {
            int termHC;
            int entryCounter = 1;

            listEntries.Items.Clear();
            hash.Clear();
            try
            {
                termHC = Int32.Parse(textTermID.Text);
            }
            catch (Exception)
            {
                termHC = Word.GetTermId(textTermID.Text.ToLower());
                LexemeConstructor ctor = new LexemeConstructor(OMEnv.ScriptMorphoAnalyzer,
                                                               OMEnv.DictionaryServer);
                string normForm = ctor.GetNormalizedToken(textTermID.Text);
                labelNormForm.Text = "Normalized Form: " + normForm;
                termHC             = Word.GetTermId(normForm.ToLower());
            }

            if (termHC != -1)
            {
                labelHC.Text = termHC.ToString();
                recMain      = (TermIndexRecord)FullTextIndexer.Instance.GetTermRecordMain(termHC);
                recMem       = (TermIndexRecord)FullTextIndexer.Instance.GetTermRecordMem(termHC);

                if (recMain != null)
                {
                    FillList(recMain, ref entryCounter, Color.LightSkyBlue);
                }
                if (recMem != null)
                {
                    FillList(recMem, ref entryCounter, Color.LightYellow);
                }
            }
            else
            {
                MessageBox.Show("No such term in the index");
            }
        }
Пример #2
0
        //  1. find ordinary lexeme which is in the dictionary
        //  2. find mapped lexeme
        //  3. find wordform after morphoanalysis
        //  4. find mapped wordform after morphoanalysis
        //  4. test several rules in the morphogrammar
        //  Test reverse transformations - from lexeme to wordforms
        [Test] public void  LexemeConstructor()
        {
            Word word = new Word();
            LexemeConstructor constructor = new LexemeConstructor(OMEnv.ScriptMorphoAnalyzer,
                                                                  OMEnv.DictionaryServer);

            word.Token = "paper";
            constructor.NormalizeToken(word);
            AssertIfTrue("Did not find ordinary lexeme which is in the dictionary", word.Token == "paper");

            word.Token = "brightly";
            constructor.NormalizeToken(word);
            AssertIfTrue("Did not find mapped lexeme: " + word.Token, word.Token == "bright");

            word.Token = "chessboards";
            constructor.NormalizeToken(word);
            AssertIfTrue("Did not find wordform after morphoanalysis", word.Token == "chessboard");

            //-----------------------------------------------------------------
            word.Token = "computerizations";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find mapped wordform after morphoanalysis", word.Token == "computerize");

            int    variant = RetrieveIndexFromBits(word.StartOffset);
            string str     = OMEnv.DictionaryServer.GetLexemeMapping("computerize", variant);

            AssertIfTrue("Reversed transoformations failed", str == "computerizations");

            //-----------------------------------------------------------------
            word.Token = "garbage-garbage";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find mapped wordform after morphoanalysis", word.Token == "garbage-garbage");

            //-----------------------------------------------------------------
            word.Token = "paid";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find wordform [paid] after morphoanalysis", word.Token == "pay");

            word.Token = "crabbing";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find wordform [crabbing] after morphoanalysis: " + word.Token, word.Token == "crab");

            word.Token = "swimming";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find wordform [swimming] after morphoanalysis", word.Token == "swim");

            word.Token = "prices";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find wordform [swimming] after morphoanalysis", word.Token == "price");

            word.Token = "ies";
            constructor.NormalizeToken(word);
            Console.WriteLine(word.Token);
            AssertIfTrue("Did not find wordform [swimming] after morphoanalysis", word.Token == "ies");
        }