Example #1
0
 public void TestGetCorrectForm()
 {
     for (var i = 0; i < dictionary.Size(); i++)
     {
         Assert.IsNull(dictionary.GetCorrectForm(dictionary.GetWord(i).GetName()));
     }
 }
        public void morphologicalAnalysisIsPortmanteau()
        {
            TxtDictionary dictionary = fsm.GetDictionary();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                var word = (TxtWord)dictionary.GetWord(i);
                if (word.IsNominal() && word.IsPortmanteau() && !word.IsPlural() &&
                    !word.IsPortmanteauFacedVowelEllipsis())
                {
                    var    transitionState = new State("CompoundNounRoot", true, false);
                    var    startState = new State("CompoundNounRoot", true, false);
                    var    transition = new Transition(transitionState, "lArH", "A3PL+P3PL");
                    string rootForm, surfaceForm, exceptLast2, exceptLast;
                    exceptLast2 = word.GetName().Substring(0, word.GetName().Length - 2);
                    exceptLast  = word.GetName().Substring(0, word.GetName().Length - 1);
                    if (word.IsPortmanteauFacedSoftening())
                    {
                        switch (word.GetName()[word.GetName().Length - 2])
                        {
                        case 'b':
                            rootForm = exceptLast2 + 'p';
                            break;

                        case 'c':
                            rootForm = exceptLast2 + 'ç';
                            break;

                        case 'd':
                            rootForm = exceptLast2 + 't';
                            break;

                        case 'ğ':
                            rootForm = exceptLast2 + 'k';
                            break;

                        default:
                            rootForm = exceptLast;
                            break;
                        }
                    }
                    else
                    {
                        if (word.IsPortmanteauEndingWithSI())
                        {
                            rootForm = exceptLast2;
                        }
                        else
                        {
                            rootForm = exceptLast;
                        }
                    }

                    surfaceForm = transition.MakeTransition(word, rootForm, startState);
                    Assert.True(fsm.MorphologicalAnalysis(surfaceForm).Size() != 0);
                }
            }
        }
        public void morphologicalAnalysisProperNoun()
        {
            TxtDictionary dictionary = fsm.GetDictionary();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                var word = (TxtWord)dictionary.GetWord(i);
                if (word.IsProperNoun())
                {
                    Assert.True(fsm.MorphologicalAnalysis(word.GetName().ToUpper(new CultureInfo("tr"))).Size() != 0);
                }
            }
        }
        public void morphologicalAnalysisVowelAChangesToIDuringYSuffixation()
        {
            TxtDictionary dictionary = fsm.GetDictionary();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                var word = (TxtWord)dictionary.GetWord(i);
                if (word.IsVerb() && word.VowelAChangesToIDuringYSuffixation())
                {
                    var    transitionState = new State("VerbalStem", false, false);
                    var    startState      = new State("VerbalRoot", true, false);
                    var    transition      = new Transition(transitionState, "Hyor", "PROG1");
                    string surfaceForm     = transition.MakeTransition(word, word.GetName(), startState);
                    Assert.True(fsm.MorphologicalAnalysis(surfaceForm).Size() != 0);
                }
            }
        }
        public void morphologicalAnalysisNounSoftenDuringSuffixation()
        {
            TxtDictionary dictionary = fsm.GetDictionary();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                var word = (TxtWord)dictionary.GetWord(i);
                if (word.IsNominal() && word.NounSoftenDuringSuffixation())
                {
                    var    transitionState = new State("Possessive", false, false);
                    var    startState      = new State("NominalRoot", true, false);
                    var    transition      = new Transition(transitionState, "yH", "ACC");
                    string surfaceForm     = transition.MakeTransition(word, word.GetName(), startState);
                    Assert.True(fsm.MorphologicalAnalysis(surfaceForm).Size() != 0);
                }
            }
        }
        public void morphologicalAnalysisLastIdropsDuringPassiveSuffixation()
        {
            TxtDictionary dictionary = fsm.GetDictionary();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                var word = (TxtWord)dictionary.GetWord(i);
                if (word.IsVerb() && word.LastIdropsDuringPassiveSuffixation())
                {
                    var    transitionState = new State("VerbalStem", false, false);
                    var    startState      = new State("VerbalRoot", true, false);
                    var    transition      = new Transition(transitionState, "Hl", "^DB+VERB+PASS");
                    string surfaceForm     = transition.MakeTransition(word, word.GetName(), startState);
                    Assert.True(fsm.MorphologicalAnalysis(surfaceForm).Size() != 0);
                }
            }
        }
        public void Setup()
        {
            simpleTrie = new Trie();
            simpleTrie.AddWord("azı", new Word("azı"));
            simpleTrie.AddWord("az", new Word("az"));
            simpleTrie.AddWord("ad", new Word("ad"));
            simpleTrie.AddWord("adi", new Word("adi"));
            simpleTrie.AddWord("adil", new Word("adil"));
            simpleTrie.AddWord("a", new Word("a"));
            simpleTrie.AddWord("adilane", new Word("adilane"));
            simpleTrie.AddWord("ısı", new Word("ısı"));
            simpleTrie.AddWord("ısıtıcı", new Word("ısıtıcı"));
            simpleTrie.AddWord("ölü", new Word("ölü"));
            simpleTrie.AddWord("ölüm", new Word("ölüm"));
            simpleTrie.AddWord("ören", new Word("ören"));
            simpleTrie.AddWord("örgü", new Word("örgü"));
            complexTrie = new Trie();
            var dictionary = new TxtDictionary();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                complexTrie.AddWord(dictionary.GetWord(i).GetName(), dictionary.GetWord(i));
            }
        }
 public void TestSize()
 {
     Assert.AreEqual(29, lowerCaseDictionary.Size());
     Assert.AreEqual(58, mixedCaseDictionary.Size());
     Assert.AreEqual(62120, dictionary.Size());
 }
Example #9
0
        public void TestVerbType()
        {
            var verbs = new Dictionary <string, int>();

            for (var i = 0; i < dictionary.Size(); i++)
            {
                var word     = (TxtWord)dictionary.GetWord(i);
                var verbType = word.VerbType();
                if (verbs.ContainsKey(verbType))
                {
                    verbs[verbType] = verbs[verbType] + 1;
                }
                else
                {
                    verbs.Add(verbType, 1);
                }
            }

            Assert.AreEqual(5, verbs["F2P1-NO-REF"]);
            Assert.AreEqual(1, verbs["F3P1-NO-REF"]);
            Assert.AreEqual(1, verbs["F4P1-NO-REF"]);
            Assert.AreEqual(14, verbs["F4PR-NO-REF"]);
            Assert.AreEqual(2, verbs["F4PL-NO-REF"]);
            Assert.AreEqual(67, verbs["F4PW-NO-REF"]);
            Assert.AreEqual(10, verbs["F5PL-NO-REF"]);
            Assert.AreEqual(111, verbs["F5PR-NO-REF"]);
            Assert.AreEqual(1, verbs["F5PW-NO-REF"]);
            Assert.AreEqual(2, verbs["F1P1"]);
            Assert.AreEqual(11, verbs["F2P1"]);
            Assert.AreEqual(4, verbs["F3P1"]);
            Assert.AreEqual(1, verbs["F4P1"]);
            Assert.AreEqual(1, verbs["F5P1"]);
            Assert.AreEqual(7, verbs["F6P1"]);
            Assert.AreEqual(2, verbs["F2PL"]);
            Assert.AreEqual(49, verbs["F4PL"]);
            Assert.AreEqual(18, verbs["F5PL"]);
            Assert.AreEqual(173, verbs["F4PR"]);
            Assert.AreEqual(808, verbs["F5PR"]);
            Assert.AreEqual(1396, verbs["F4PW"]);
            Assert.AreEqual(13, verbs["F5PW"]);
        }