本文整理了Java中zemberek.morphology.analysis.WordAnalysis.analysisCount()
方法的一些代码示例,展示了WordAnalysis.analysisCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WordAnalysis.analysisCount()
方法的具体详情如下:
包路径:zemberek.morphology.analysis.WordAnalysis
类名称:WordAnalysis
方法名:analysisCount
暂无
代码示例来源:origin: ahmetaa/zemberek-nlp
Predicate<WordAnalysis> maxAnalysisCount(int i) {
return p -> p.analysisCount() <= i;
}
代码示例来源:origin: ahmetaa/zemberek-nlp
private String generateKeyFromParse(WordAnalysis results) {
StringBuilder key = new StringBuilder();
for (int i = 0; i < results.analysisCount(); i++) {
key.append(results.getAnalysisResults().get(i).formatMorphemesLexical());
if (i < results.analysisCount() - 1) {
key.append("\n");
}
}
return key.toString();
}
代码示例来源:origin: ahmetaa/zemberek-nlp
public static void saveUnambiguous(
List<SentenceAnalysis> sentences,
Path out)
throws IOException {
try (PrintWriter pwMorph = new PrintWriter(out.toFile(), "utf-8")) {
for (SentenceAnalysis analysis : sentences) {
if (analysis.bestAnalysis().stream().anyMatch(SingleAnalysis::isUnknown)) {
continue;
}
pwMorph.format("S:%s%n", analysis.getSentence());
for (SentenceWordAnalysis sw : analysis) {
WordAnalysis wa = sw.getWordAnalysis();
pwMorph.println(wa.getInput());
SingleAnalysis best = sw.getBestAnalysis();
for (SingleAnalysis singleAnalysis : wa) {
boolean isBest = singleAnalysis.equals(best);
if (wa.analysisCount() == 1) {
pwMorph.println(singleAnalysis.formatLong());
} else {
pwMorph.format("%s%s%n", singleAnalysis.formatLong(), isBest ? "*" : "");
}
}
}
pwMorph.println();
}
}
}
代码示例来源:origin: ahmetaa/zemberek-nlp
if (w.analysisCount() != s.wordAnalysis.size()) {
Log.warn(
"Actual analysis token [%s] has [%d] analyses but word from training file has [%d] "
+ " analyses for sentence [%s]",
w.getInput(), w.analysisCount(), s.wordAnalysis.size(), sentence);
break;
代码示例来源:origin: ahmetaa/zemberek-nlp
private void printResults(WordAnalysis results) {
int i = 1;
if (results.analysisCount() == 0) {
Log.info("No Analysis.");
}
for (SingleAnalysis result : results) {
String str = result.formatLong();
if (result.getDictionaryItem().attributes.contains(RootAttribute.Runtime)) {
str = str + " (Generated by UnidentifiedTokenParser)";
}
Log.info(i + " - " + str);
i++;
}
}
}
代码示例来源:origin: ahmetaa/zemberek-nlp
public static void saveUnambiguous(
List<String> sentences,
TurkishMorphology morphology,
Path out)
throws IOException {
try (PrintWriter pwMorph = new PrintWriter(out.toFile(), "utf-8")) {
for (String sentence : sentences) {
SentenceAnalysis analysis = morphology.analyzeAndDisambiguate(sentence);
if (analysis.bestAnalysis().stream().anyMatch(SingleAnalysis::isUnknown)) {
continue;
}
pwMorph.format("S:%s%n", sentence);
for (SentenceWordAnalysis sw : analysis) {
WordAnalysis wa = sw.getWordAnalysis();
pwMorph.println(wa.getInput());
SingleAnalysis best = sw.getBestAnalysis();
for (SingleAnalysis singleAnalysis : wa) {
boolean isBest = singleAnalysis.equals(best);
if (wa.analysisCount() == 1) {
pwMorph.println(singleAnalysis.formatLong());
} else {
pwMorph.format("%s%s%n", singleAnalysis.formatLong(), isBest ? "*" : "");
}
}
}
pwMorph.println();
}
}
}
代码示例来源:origin: ahmetaa/zemberek-nlp
analyses.analysisCount() > 0 ?
analyses.getAnalysisResults().get(analyses.analysisCount() - 1) :
SingleAnalysis.unknown(word);
for (SingleAnalysis analysis : analyses) {
代码示例来源:origin: ahmetaa/zemberek-nlp
for (SingleAnalysis singleAnalysis : wa) {
boolean isBest = singleAnalysis.equals(best);
if (wa.analysisCount() == 1) {
pwMorph.println(singleAnalysis.formatLong());
} else {
代码示例来源:origin: ahmetaa/zemberek-nlp
if (results.analysisCount() == 0) {
代码示例来源:origin: ahmetaa/zemberek-nlp
if ((analyses.analysisCount() == 0) && current.length() > 3) {
代码示例来源:origin: ahmetaa/zemberek-nlp
for (SingleAnalysis singleAnalysis : wa) {
boolean isBest = singleAnalysis.equals(best);
if (wa.analysisCount() == 1) {
System.out.println(singleAnalysis.formatLong());
} else {
代码示例来源:origin: ahmetaa/zemberek-nlp
System.out.println("Processed: " + total);
if (results.analysisCount() == 0) {
uniques.add(s);
代码示例来源:origin: ahmetaa/zemberek-nlp
System.out.println("Processed: " + total);
if (results.analysisCount() > 1) {
uniques.add(s);
代码示例来源:origin: ahmetaa/zemberek-nlp
System.out.println("Processed: " + total);
if (results.analysisCount() > 1) {
String key = generateKeyFromParse(results);
uniques.add(key);
代码示例来源:origin: ahmetaa/zemberek-nlp
if (results.analysisCount() == 0) {
local.incorrect.add(s);
} else {
代码示例来源:origin: iorixxx/lucene-solr-analysis-turkish
private static void parse(String word, TurkishMorphology morphology) {
WordAnalysis results = morphology.analyze(word);
System.out.println("Word = " + word + " has " + results.analysisCount() + " many solutions");
if (results.analysisCount() == 0) return;
System.out.println("Parses: ");
for (SingleAnalysis result : results) {
System.out.println("number of morphemes = " + result.getMorphemeDataList().size()) ;
System.out.println(result.formatLong());
System.out.println("\tStems = " + result.getStems());
System.out.println("\tLemmas = " + result.getLemmas());
System.out.println("\tStemAndEnding = " + result.getStemAndEnding());
System.out.println("-------------------");
}
System.out.println("final selected stem : " + Zemberek3StemFilter.stem(results, "maxLength"));
System.out.println("==================================");
}
代码示例来源:origin: iorixxx/lucene-solr-analysis-turkish
private static List<SingleAnalysis> selectMorphemes(WordAnalysis results, String strategy) {
// if 0 or 1
if (results.analysisCount() < 2) return results.stream().collect(Collectors.toList());
switch (strategy) {
case "all":
return results.stream().collect(Collectors.toList());
case "maxMorpheme":
final int max = results.stream().map(morphParse -> morphParse.getMorphemeDataList().size()).max(Comparator.naturalOrder()).get();
return results.stream().filter(parse -> parse.getMorphemeDataList().size() == max).collect(Collectors.toList());
case "minMorpheme":
final int min = results.stream().map(morphParse -> morphParse.getMorphemeDataList().size()).min(Comparator.naturalOrder()).get();
return results.stream().filter(parse -> parse.getMorphemeDataList().size() == min).collect(Collectors.toList());
default:
throw new RuntimeException("unknown strategy " + strategy);
}
}
代码示例来源:origin: ahmetaa/turkish-nlp-examples
private void printResults(WordAnalysis results) {
int i = 1;
if (results.analysisCount() == 0) {
Log.info("No Analysis.");
}
for (SingleAnalysis result : results) {
String str = result.formatLong();
if (result.getDictionaryItem().attributes.contains(RootAttribute.Runtime)) {
str = str + " (Generated by UnidentifiedTokenParser)";
}
Log.info(i + " - " + str);
i++;
}
}
}
代码示例来源:origin: iorixxx/lucene-solr-analysis-turkish
@Override
public boolean incrementToken() throws IOException {
if (!input.incrementToken()) return false;
if (keywordAttribute.isKeyword()) return true;
/**
* copied from {@link org.apache.lucene.analysis.br.BrazilianStemFilter#incrementToken}
*/
final String word = termAttribute.toString();
final WordAnalysis parses = morphology.analyze(word);
if (parses.analysisCount() == 0) return true;
final String s = stem(parses, aggregation);
// If not stemmed, don't waste the time adjusting the token.
if ((s != null) && !s.equals(word))
termAttribute.setEmpty().append(s);
return true;
}
}
内容来源于网络,如有侵权,请联系作者删除!