use of com.graphaware.nlp.ml.textrank.TextRankResult in project neo4j-nlp by graphaware.
the class TextRankProcedure method computeTextRank.
@Procedure(name = "ga.nlp.ml.textRank.compute", mode = Mode.WRITE)
@Description("Keywords Extraction using TextRank algorithm ( without storage )")
public Stream<KeywordResult> computeTextRank(@Name("textRankRequest") Map<String, Object> textRankRequest) {
try {
TextRankRequest request = TextRankRequest.fromMap(textRankRequest);
TextRankProcessor processor = (TextRankProcessor) getNLPManager().getExtension(TextRankProcessor.class);
TextRankResult result = processor.compute(request);
return result.getResult().values().stream().map(keyword -> {
return new KeywordResult(keyword.getKeyword(), keyword.getRelevance());
});
} catch (Exception e) {
LOG.error("Error during TextRank computation", e);
throw new RuntimeException(e);
}
}
Aggregations