zemberek.morphology.analysis.WordAnalysis.stream()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中zemberek.morphology.analysis.WordAnalysis.stream()方法的一些代码示例,展示了WordAnalysis.stream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WordAnalysis.stream()方法的具体详情如下:
包路径:zemberek.morphology.analysis.WordAnalysis
类名称:WordAnalysis
方法名:stream

WordAnalysis.stream介绍

暂无

代码示例

代码示例来源:origin: ahmetaa/zemberek-nlp

WordAnalysisProto toWordAnalysisProto(WordAnalysis analysis) {
 return WordAnalysisProto.newBuilder()
   .addAllAnalyses(analysis
     .stream()
     .map(this::toSingleAnalysisProto)
     .collect(Collectors.toList()))
   .build();
}

代码示例来源:origin: ahmetaa/zemberek-nlp

/**
 * Returns true if only word is analysed with internal dictionary and analysis dictionary item is
 * not proper noun.
 */
boolean hasRegularAnalysis(String s) {
 WordAnalysis a = morphology.analyze(s);
 return a.stream().anyMatch(k -> !k.isUnknown() && !k.isRuntime() &&
   k.getDictionaryItem().secondaryPos != SecondaryPos.ProperNoun &&
   k.getDictionaryItem().secondaryPos != SecondaryPos.Abbreviation
 );
}

代码示例来源:origin: ahmetaa/zemberek-nlp

Set<String> stems = wordResults.stream()
  .map(a -> normalize(a.getDictionaryItem().lemma))
  .collect(Collectors.toSet());

代码示例来源: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);
  }
}

相关文章