protected bool IsLastWordOfNounPhrase(ParseNodeDrawable parseNode) { var parent = (ParseNodeDrawable)parseNode.GetParent(); var grandParent = (ParseNodeDrawable)parent.GetParent(); var next = (ParseNodeDrawable)parseNode.NextSibling(); var previous = (ParseNodeDrawable)parseNode.PreviousSibling(); if (parent.IsLastChild(parseNode)) { if (previous != null && previous.GetData().GetName().StartsWith("J") && previous.LastChild().IsLeaf()) { string word = ((ParseNodeDrawable)previous.LastChild()).GetLayerData(ViewLayerType.TURKISH_WORD); if (word != null && txtDictionary.GetWord(word) != null && ((TxtWord)txtDictionary.GetWord(word)).IsNominal()) { return(true); } } if (previous != null && previous.GetData().GetName().StartsWith("N")) { return(true); } if (grandParent != null && grandParent.IsLastChild(parent) && grandParent.NumberOfChildren() == 2) { ParseNodeDrawable parentPrevious = (ParseNodeDrawable)parent.PreviousSibling(); if (parentPrevious.GetData().GetName().Equals("PP") && parentPrevious.LastChild().GetData().GetName().Equals("IN")) { ParseNodeDrawable inNode = (ParseNodeDrawable)parentPrevious.LastChild().LastChild(); if (inNode != null && inNode.GetLayerData(ViewLayerType.ENGLISH_WORD) != null && inNode.GetLayerData(ViewLayerType.ENGLISH_WORD).Equals("of")) { return(true); } return(false); } return(false); } return(false); } if (next != null && previous != null) { return(!(next.GetData().GetName().StartsWith("N")) && previous.GetData().GetName().StartsWith("N")); } return(false); }
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 TestGetWord() { Assert.AreEqual("a", lowerCaseDictionary.GetWord(0).GetName()); Assert.AreEqual("ç", lowerCaseDictionary.GetWord(3).GetName()); Assert.AreEqual("ğ", lowerCaseDictionary.GetWord(8).GetName()); Assert.AreEqual("ı", lowerCaseDictionary.GetWord(10).GetName()); Assert.AreEqual("ö", lowerCaseDictionary.GetWord(18).GetName()); Assert.AreEqual("ş", lowerCaseDictionary.GetWord(22).GetName()); Assert.AreEqual("ü", lowerCaseDictionary.GetWord(25).GetName()); Assert.AreEqual("z", lowerCaseDictionary.GetWord(28).GetName()); for (int i = 0; i < dictionary.Size(); i++) { Assert.NotNull(dictionary.GetWord(i)); } }
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 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 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"]); }