use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.
the class TurkishMorphologyFunctionalTests method testTime.
@Test
public void testTime() {
TurkishMorphology morphology = getMorphology("otuz [P:Num,Card]");
WordAnalysis result = morphology.analyze("20:30'da");
Assert.assertEquals(1, result.analysisCount());
Assert.assertEquals(SecondaryPos.Clock, result.getAnalysisResults().get(0).getDictionaryItem().secondaryPos);
}
use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.
the class TurkishMorphologyFunctionalTests method testHashTag.
@Test
public void testHashTag() {
TurkishMorphology morphology = getMorphology();
WordAnalysis result = morphology.analyze("#haha_ha'ya");
Assert.assertEquals(1, result.analysisCount());
SingleAnalysis analysis = result.getAnalysisResults().get(0);
Assert.assertEquals(SecondaryPos.HashTag, analysis.getDictionaryItem().secondaryPos);
String lexical = analysis.formatLexical();
Assert.assertTrue(lexical.endsWith("A3sg+Dat"));
Assert.assertEquals("#haha_ha", analysis.getDictionaryItem().lemma);
}
use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.
the class TurkishMorphology method analyzeSentence.
public List<WordAnalysis> analyzeSentence(String sentence) {
String normalized = TextUtil.normalizeQuotesHyphens(sentence);
List<WordAnalysis> result = new ArrayList<>();
for (Token token : tokenizer.tokenize(normalized)) {
result.add(analyze(token));
}
return result;
}
use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.
the class PerceptronAmbiguityResolver method disambiguate.
@Override
public SentenceAnalysis disambiguate(String sentence, List<WordAnalysis> allAnalyses) {
DecodeResult best = decoder.bestPath(allAnalyses);
List<SentenceWordAnalysis> l = new ArrayList<>();
for (int i = 0; i < allAnalyses.size(); i++) {
WordAnalysis wordAnalysis = allAnalyses.get(i);
SingleAnalysis analysis = best.bestParse.get(i);
l.add(new SentenceWordAnalysis(analysis, wordAnalysis));
}
return new SentenceAnalysis(sentence, l);
}
use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.
the class MorphologyServiceImpl method analyzeWord.
@Override
public void analyzeWord(WordAnalysisRequest request, StreamObserver<WordAnalysisProto> responseObserver) {
String input = request.getInput();
WordAnalysis a = morphology.analyze(input);
responseObserver.onNext(toWordAnalysisProto(a));
responseObserver.onCompleted();
}
Aggregations