use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class BasicWordSpellingCheckAndSuggestion method main.
public static void main(String[] args) throws IOException {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
TurkishSpellChecker spellChecker = new TurkishSpellChecker(morphology);
Log.info("Check if written correctly.");
String[] words = { "Ankara'ya", "Ankar'aya", "yapbileceksen", "yapabileceğinizden" };
for (String word : words) {
Log.info(word + " -> " + spellChecker.check(word));
}
Log.info();
Log.info("Give suggestions.");
String[] toSuggest = { "Kraamanda", "okumuştk", "yapbileceksen", "oukyamıyorum" };
for (String s : toSuggest) {
Log.info(s + " -> " + spellChecker.suggestForWord(s));
}
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class DistanceBasedStemmer method load.
public static DistanceBasedStemmer load(Path vector, Path distances, Path vocabFile) throws IOException {
Log.info("Loading vector file.");
List<WordVector> wordVectors = WordVector.loadFromBinary(vector);
Map<String, WordVector> map = new HashMap<>(wordVectors.size());
for (WordVector wordVector : wordVectors) {
map.put(wordVector.word, wordVector);
}
Log.info("Loading distances.");
DistanceList experiment = DistanceList.readFromBinary(distances, vocabFile);
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
return new DistanceBasedStemmer(map, experiment, morphology);
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class StemmingAndLemmatization method main.
public static void main(String[] args) {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
String word = "kutucuğumuz";
Log.info("Word = " + word);
Log.info("Results: ");
WordAnalysis results = morphology.analyze(word);
for (SingleAnalysis result : results) {
Log.info(result.formatLong());
Log.info("\tStems = " + result.getStems());
Log.info("\tLemmas = " + result.getLemmas());
}
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class UseNer method main.
public static void main(String[] args) throws IOException {
// assumes you generated a model in my-model directory.
Path modelRoot = Paths.get("my-model");
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
PerceptronNer ner = PerceptronNer.loadModel(modelRoot, morphology);
String sentence = "Ali Kaan yarın İstanbul'a gidecek.";
NerSentence result = ner.findNamedEntities(sentence);
List<NamedEntity> namedEntities = result.getNamedEntities();
for (NamedEntity namedEntity : namedEntities) {
System.out.println(namedEntity);
}
}
use of zemberek.morphology.TurkishMorphology in project zemberek-nlp by ahmetaa.
the class AmbiguityResolutionTests method issue157ShouldNotThrowNPE.
@Test
public void issue157ShouldNotThrowNPE() {
String input = "Yıldız Kızlar Dünya Şampiyonası FIVB'nin düzenlediği ve 18 " + "yaşının altındaki voleybolcuların katılabildiği bir şampiyonadır.";
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
SentenceAnalysis analysis = morphology.analyzeAndDisambiguate(input);
Assert.assertEquals(TurkishTokenizer.DEFAULT.tokenize(input).size(), analysis.size());
for (SentenceWordAnalysis sentenceWordAnalysis : analysis) {
String token = sentenceWordAnalysis.getWordAnalysis().getInput();
SingleAnalysis an = sentenceWordAnalysis.getBestAnalysis();
System.out.println(token + " = " + an.formatLong());
}
}
Aggregations