Search in sources :

Example 16 with TurkishMorphology

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

the class WordAnalysisFormatterTest method formatToCase.

@Test
public void formatToCase() throws IOException {
    TurkishMorphology morphology = TurkishMorphology.builder().addDictionaryLines("kış", "şiir", "Aydın", "Google [Pr:gugıl]").build();
    String[] inputs = { "aydında", "googledan", "Google", "şiirde", "kışçığa", "kış" };
    String[] expectedDefaultCase = { "Aydın'da", "Google'dan", "Google", "şiirde", "kışçığa", "kış" };
    String[] expectedLowerCase = { "aydın'da", "google'dan", "google", "şiirde", "kışçığa", "kış" };
    String[] expectedUpperCase = { "AYDIN'DA", "GOOGLE'DAN", "GOOGLE", "ŞİİRDE", "KIŞÇIĞA", "KIŞ" };
    String[] expectedCapitalCase = { "Aydın'da", "Google'dan", "Google", "Şiirde", "Kışçığa", "Kış" };
    String[] expectedUpperRootLowerEndingCase = { "AYDIN'da", "GOOGLE'dan", "GOOGLE", "ŞİİRde", "KIŞçığa", "KIŞ" };
    testCaseType(morphology, inputs, expectedDefaultCase, WordAnalysisFormatter.CaseType.DEFAULT_CASE);
    testCaseType(morphology, inputs, expectedLowerCase, WordAnalysisFormatter.CaseType.LOWER_CASE);
    testCaseType(morphology, inputs, expectedUpperCase, WordAnalysisFormatter.CaseType.UPPER_CASE);
    testCaseType(morphology, inputs, expectedCapitalCase, WordAnalysisFormatter.CaseType.TITLE_CASE);
    testCaseType(morphology, inputs, expectedUpperRootLowerEndingCase, WordAnalysisFormatter.CaseType.UPPER_CASE_ROOT_LOWER_CASE_ENDING);
}
Also used : TurkishMorphology(zemberek.morphology.analysis.tr.TurkishMorphology) Test(org.junit.Test)

Example 17 with TurkishMorphology

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

the class WordAnalysisFormatterTest method formatNumerals.

@Test
public void formatNumerals() throws IOException {
    TurkishMorphology morphology = TurkishMorphology.builder().build();
    String[] inputs = { "1e", "4ten", "123ü", "12,5ten" };
    String[] expected = { "1'e", "4'ten", "123'ü", "12,5ten" };
    WordAnalysisFormatter formatter = new WordAnalysisFormatter();
    int i = 0;
    for (String input : inputs) {
        List<WordAnalysis> results = morphology.analyze(input);
        for (WordAnalysis result : results) {
            if (result.getDictionaryItem().primaryPos == PrimaryPos.Numeral) {
                Assert.assertEquals(expected[i], formatter.format(result, "'"));
            }
        }
        i++;
    }
}
Also used : TurkishMorphology(zemberek.morphology.analysis.tr.TurkishMorphology) Test(org.junit.Test)

Example 18 with TurkishMorphology

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

the class AddNewDictionaryItem method main.

public static void main(String[] args) throws IOException {
    TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
    AddNewDictionaryItem app = new AddNewDictionaryItem(morphology);
    System.out.println("Proper Noun Test - 1 :");
    app.test("Meydan'a", new DictionaryItem("Meydan", "meydan", "meydan", PrimaryPos.Noun, SecondaryPos.ProperNoun));
    System.out.println();
    System.out.println("Proper Noun Test - 2 :");
    app.test("Meeeydan'a", new DictionaryItem("Meeeydan", "meeeydan", "meeeydan", PrimaryPos.Noun, SecondaryPos.ProperNoun));
    System.out.println();
    System.out.println("Verb Test : ");
    app.test("tweetleyeyazdım", new DictionaryItem("tweetlemek", "tweetle", "tivitle", PrimaryPos.Verb, SecondaryPos.None));
}
Also used : DictionaryItem(zemberek.morphology.lexicon.DictionaryItem) TurkishMorphology(zemberek.morphology.analysis.tr.TurkishMorphology)

Example 19 with TurkishMorphology

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

the class FindPOS method main.

public static void main(String[] args) throws IOException {
    TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
    Z3MarkovModelDisambiguator disambiguator = new Z3MarkovModelDisambiguator();
    TurkishSentenceAnalyzer sentenceAnalyzer = new TurkishSentenceAnalyzer(morphology, disambiguator);
    new FindPOS(sentenceAnalyzer).test("Keşke yarın hava güzel olsa.");
}
Also used : Z3MarkovModelDisambiguator(zemberek.morphology.ambiguity.Z3MarkovModelDisambiguator) TurkishSentenceAnalyzer(zemberek.morphology.analysis.tr.TurkishSentenceAnalyzer) TurkishMorphology(zemberek.morphology.analysis.tr.TurkishMorphology)

Example 20 with TurkishMorphology

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

the class StemmingAndLemmatization method main.

public static void main(String[] args) throws IOException {
    TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
    new StemmingAndLemmatization(morphology).analyze("kitabımızsa");
}
Also used : TurkishMorphology(zemberek.morphology.analysis.tr.TurkishMorphology)

Aggregations

TurkishMorphology (zemberek.morphology.analysis.tr.TurkishMorphology)26 Test (org.junit.Test)13 Ignore (org.junit.Ignore)5 Z3MarkovModelDisambiguator (zemberek.morphology.ambiguity.Z3MarkovModelDisambiguator)5 WordAnalysis (zemberek.morphology.analysis.WordAnalysis)5 TurkishSentenceAnalyzer (zemberek.morphology.analysis.tr.TurkishSentenceAnalyzer)5 Path (java.nio.file.Path)2 UnidentifiedTokenAnalyzer (zemberek.morphology.analysis.tr.UnidentifiedTokenAnalyzer)2 DictionaryItem (zemberek.morphology.lexicon.DictionaryItem)2 Stopwatch (com.google.common.base.Stopwatch)1 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Before (org.junit.Before)1 SentenceAnalysis (zemberek.morphology.analysis.SentenceAnalysis)1 LexiconProto (zemberek.morphology.lexicon.proto.LexiconProto)1 Dictionary (zemberek.morphology.lexicon.proto.LexiconProto.Dictionary)1 TurkishSpellChecker (zemberek.normalization.TurkishSpellChecker)1