public void Setup() { var fsm = new FsmMorphologicalAnalyzer(); parse1 = fsm.MorphologicalAnalysis("açılır").GetFsmParse(0); parse2 = fsm.MorphologicalAnalysis("koparılarak").GetFsmParse(0); parse3 = fsm.MorphologicalAnalysis("toplama").GetFsmParse(0); parse4 = fsm.MorphologicalAnalysis("değerlendirmede").GetFsmParse(0); parse5 = fsm.MorphologicalAnalysis("soruşturmasının").GetFsmParse(0); parse6 = fsm.MorphologicalAnalysis("karşılaştırmalı").GetFsmParse(0); parse7 = fsm.MorphologicalAnalysis("esaslarını").GetFsmParse(0); parse8 = fsm.MorphologicalAnalysis("güçleriyle").GetFsmParse(0); parse9 = fsm.MorphologicalAnalysis("bulmayacakları").GetFsmParse(0); parse10 = fsm.MorphologicalAnalysis("mü").GetFsmParse(0); }
public void TestDeasciify() { var fsm = new FsmMorphologicalAnalyzer(); var nGram = new NGram <string>("../../../ngram.txt"); nGram.CalculateNGramProbabilities(new NoSmoothing <string>()); var nGramDeasciifier = new NGramDeasciifier(fsm, nGram, true); var simpleAsciifier = new SimpleAsciifier(); var corpus = new Corpus.Corpus("../../../corpus.txt"); for (var i = 0; i < corpus.SentenceCount(); i++) { var sentence = corpus.GetSentence(i); for (var j = 1; j < sentence.WordCount(); j++) { if (fsm.MorphologicalAnalysis(sentence.GetWord(j).GetName()).Size() > 0) { var asciified = simpleAsciifier.Asciify(sentence.GetWord(j)); if (!asciified.Equals(sentence.GetWord(j).GetName())) { var deasciified = nGramDeasciifier.Deasciify( new Sentence(sentence.GetWord(j - 1).GetName() + " " + sentence.GetWord(j).GetName())); Assert.AreEqual(sentence.GetWord(j).GetName(), deasciified.GetWord(1).GetName()); } } } } }
/** * <summary>The candidateList method takes a {@link Word} as an input and creates new candidates {@link List}. First it * adds given word to this {@link List} and calls generateCandidateList method with candidates, given word and * index 0. Then, loops i times where i ranges from 0 to size of candidates {@link List} and calls morphologicalAnalysis * method with ith item of candidates {@link List}. If it does not return any analysis for given item, it removes * the item from candidates {@link List}.</summary> * * <param name="word">{@link Word} type input.</param> * <returns>List candidates.</returns> */ public List <string> CandidateList(Word word) { var candidates = new List <string> { word.GetName() }; GenerateCandidateList(candidates, word.GetName(), 0); for (var i = 0; i < candidates.Count; i++) { var fsmParseList = fsm.MorphologicalAnalysis(candidates[i]); if (fsmParseList.Size() == 0) { candidates.RemoveAt(i); i--; } } return(candidates); }
/** * <summary>The candidateList method takes a {@link Word} as an input and creates a candidates {@link List} by calling generateCandidateList * method with given word. Then, it loop i times where i ranges from 0 to size of candidates {@link List} and creates a * {@link FsmParseList} by calling morphologicalAnalysis with each item of candidates {@link List}. If the size of * {@link FsmParseList} is 0, it then removes the ith item.</summary> * * <param name="word">Word input.</param> * <returns>candidates {@link List}.</returns> */ protected List <string> CandidateList(Word word) { var candidates = generateCandidateList(word.GetName()); for (var i = 0; i < candidates.Count; i++) { var fsmParseList = fsm.MorphologicalAnalysis(candidates[i]); if (fsmParseList.Size() == 0) { var newCandidate = fsm.GetDictionary().GetCorrectForm(candidates[i]); if (newCandidate != null && fsm.MorphologicalAnalysis(newCandidate).Size() > 0) { candidates[i] = newCandidate; } else { candidates.RemoveAt(i); i--; } } } return(candidates); }
public void morphologicalAnalysisDataTimeNumber() { Assert.True(fsm.MorphologicalAnalysis("3/4").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("3\\/4").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("4/2/1973").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("14/2/1993").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("14/12/1933").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("6/12/1903").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("%34.5").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("%3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("%56").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("2:3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("12:3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("4:23").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("11:56").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("1:2:3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("3:12:3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("5:4:23").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("7:11:56").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("12:2:3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("10:12:3").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("11:4:23").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("22:11:56").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("45").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("34.23").Size() != 0); }
public void TestNumberWithAccusative() { Assert.True(fsm.MorphologicalAnalysis("2'yi").Size() != 0); Assert.AreEqual(0, fsm.MorphologicalAnalysis("2'i").Size()); Assert.True(fsm.MorphologicalAnalysis("5'i").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("9'u").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("10'u").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("30'u").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("3'ü").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("4'ü").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("100'ü").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("6'yı").Size() != 0); Assert.AreEqual(0, fsm.MorphologicalAnalysis("6'ı").Size()); Assert.True(fsm.MorphologicalAnalysis("40'ı").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("60'ı").Size() != 0); Assert.True(fsm.MorphologicalAnalysis("90'ı").Size() != 0); }