Search in sources :

Example 16 with WordAnalysis

use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.

the class ParseConsole method run.

public void run(TurkishMorphology parser) throws IOException {
    String input;
    System.out.println("Enter word:");
    Scanner sc = new Scanner(System.in);
    input = sc.nextLine();
    while (!input.equals("exit") && !input.equals("quit")) {
        List<WordAnalysis> tokens = parser.analyze(input);
        if (tokens.size() == 0 || (tokens.size() == 1 && tokens.get(0).dictionaryItem.primaryPos == PrimaryPos.Unknown)) {
            System.out.println("cannot be parsed");
            parser.getWordAnalyzer().dump(input);
        } else {
            tokens.forEach(this::printMorphParse);
        }
        input = sc.nextLine();
    }
}
Also used : Scanner(java.util.Scanner) WordAnalysis(zemberek.morphology.analysis.WordAnalysis)

Example 17 with WordAnalysis

use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.

the class TurkishMorphologyFunctionalTests method testWordsWithCircumflex.

@Test
public void testWordsWithCircumflex() {
    TurkishMorphology morphology = getMorphology("zekâ");
    WordAnalysis result = morphology.analyze("zekâ");
    Assert.assertEquals(1, result.analysisCount());
}
Also used : WordAnalysis(zemberek.morphology.analysis.WordAnalysis) Test(org.junit.Test)

Example 18 with WordAnalysis

use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.

the class TurkishMorphologyFunctionalTests method testRomanNumeral3.

@Test
public void testRomanNumeral3() {
    TurkishMorphology morphology = getMorphology("dört [P:Num,Card;A:Voicing]");
    WordAnalysis result = morphology.analyze("XXIV'ten");
    Assert.assertEquals(1, result.analysisCount());
    Assert.assertEquals(SecondaryPos.RomanNumeral, result.getAnalysisResults().get(0).getDictionaryItem().secondaryPos);
}
Also used : WordAnalysis(zemberek.morphology.analysis.WordAnalysis) Test(org.junit.Test)

Example 19 with WordAnalysis

use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.

the class TurkishMorphologyFunctionalTests method testPercent.

@Test
public void testPercent() {
    TurkishMorphology morphology = getMorphology("iki [P:Num,Card]");
    String[] correct = { "%2", "%2'si", "%2.2'si", "%2,2'si" };
    for (String s : correct) {
        WordAnalysis result = morphology.analyze(s);
        Assert.assertEquals("Failed for " + s, 1, result.analysisCount());
        Assert.assertEquals("Failed for " + s, SecondaryPos.Percentage, result.getAnalysisResults().get(0).getDictionaryItem().secondaryPos);
    }
}
Also used : WordAnalysis(zemberek.morphology.analysis.WordAnalysis) Test(org.junit.Test)

Example 20 with WordAnalysis

use of zemberek.morphology.analysis.WordAnalysis in project zemberek-nlp by ahmetaa.

the class TurkishMorphologyFunctionalTests method testWordsWithDash.

@Test
public void testWordsWithDash() {
    // Instance with no dictionary item.
    TurkishMorphology morphology = getEmptyTurkishMorphology();
    WordAnalysis result = morphology.analyze("Blah-Foo'ya");
    Assert.assertEquals(1, result.analysisCount());
}
Also used : WordAnalysis(zemberek.morphology.analysis.WordAnalysis) Test(org.junit.Test)

Aggregations

WordAnalysis (zemberek.morphology.analysis.WordAnalysis)96 Test (org.junit.Test)42 SingleAnalysis (zemberek.morphology.analysis.SingleAnalysis)36 TurkishMorphology (zemberek.morphology.TurkishMorphology)22 ArrayList (java.util.ArrayList)21 SentenceAnalysis (zemberek.morphology.analysis.SentenceAnalysis)19 LinkedHashSet (java.util.LinkedHashSet)13 Ignore (org.junit.Ignore)13 Histogram (zemberek.core.collections.Histogram)12 Path (java.nio.file.Path)11 PrintWriter (java.io.PrintWriter)10 SentenceWordAnalysis (zemberek.morphology.analysis.SentenceWordAnalysis)10 IOException (java.io.IOException)6 HashSet (java.util.HashSet)6 List (java.util.List)6 WordAnalyzer (zemberek.morphology.analysis.WordAnalyzer)6 SimpleGenerator (zemberek.morphology.generator.SimpleGenerator)6 DictionaryItem (zemberek.morphology.lexicon.DictionaryItem)6 DynamicLexiconGraph (zemberek.morphology.lexicon.graph.DynamicLexiconGraph)6 Log (zemberek.core.logging.Log)5