use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class Scripts method foobar.
static void foobar() throws IOException {
Path path = Paths.get("/home/aaa/projects/zemberek-nlp/morphology/src/main/resources/tr/person-names.dict");
Path path2 = Paths.get("/home/aaa/projects/zemberek-nlp/morphology/src/main/resources/tr/person-names-reduced.dict");
List<String> bb = Files.readAllLines(path);
TurkishMorphology morphology = TurkishMorphology.create(RootLexicon.builder().addTextDictionaryResources("tr/master-dictionary.dict", "tr/non-tdk.dict", "tr/proper.dict", "tr/proper-from-corpus.dict", "tr/abbreviations.dict").build());
List<String> r = new ArrayList<>();
for (String s : bb) {
if (s.trim().length() == 0) {
continue;
}
s = s.replaceAll("[ ]+", " ").trim();
DictionaryItem d = TurkishDictionaryLoader.loadFromString(s);
if (!morphology.getLexicon().containsItem(d)) {
r.add(s.trim());
}
}
r.sort(Turkish.STRING_COMPARATOR_ASC);
Files.write(path2, r);
}
use of zemberek.morphology.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);
Log.info("Proper Noun Test - 1 :");
app.test("Meydan'a", new DictionaryItem("Meydan", "meydan", "meydan", PrimaryPos.Noun, SecondaryPos.ProperNoun));
Log.info("----");
Log.info("Proper Noun Test - 2 :");
app.test("Meeeydan'a", new DictionaryItem("Meeeydan", "meeeydan", "meeeydan", PrimaryPos.Noun, SecondaryPos.ProperNoun));
Log.info("----");
Log.info("Verb Test : ");
app.test("tweetleyeyazdım", new DictionaryItem("tweetlemek", "tweetle", "tivitle", PrimaryPos.Verb, SecondaryPos.None));
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class AnalyzeIgnoreDiacritics method main.
public static void main(String[] args) throws IOException {
TurkishMorphology morphology = TurkishMorphology.builder().ignoreDiacriticsInAnalysis().setLexicon(RootLexicon.getDefault()).build();
morphology.analyze("kisi").forEach(System.out::println);
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class ChangeStem method main.
public static void main(String[] args) {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
DictionaryItem newStem = morphology.getLexicon().getMatchingItems("poğaça").get(0);
String word = "simidime";
Log.info("Input Word = " + word);
WordAnalysis results = morphology.analyze(word);
for (SingleAnalysis result : results) {
List<Result> generated = morphology.getWordGenerator().generate(newStem, result.getMorphemes());
for (Result s : generated) {
Log.info("Input analysis: " + result.formatLong());
Log.info("After stem change, word = " + s.surface);
Log.info("After stem change, Analysis = " + s.analysis.formatLong());
}
}
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class FindPOS method main.
public static void main(String[] args) {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
String sentence = "Keşke yarın hava güzel olsa.";
Log.info("Sentence = " + sentence);
SentenceAnalysis analysis = morphology.analyzeAndDisambiguate(sentence);
for (SentenceWordAnalysis a : analysis) {
PrimaryPos primaryPos = a.getBestAnalysis().getPos();
Log.info("%s : %s ", a.getWordAnalysis().getInput(), primaryPos);
}
}
Aggregations