Search in sources :

Example 1 with TextRankResult

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);
    }
}
Also used : TextRankResult(com.graphaware.nlp.ml.textrank.TextRankResult) TextRankProcessor(com.graphaware.nlp.ml.textrank.TextRankProcessor) TextRankRequest(com.graphaware.nlp.dsl.request.TextRankRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Aggregations

TextRankRequest (com.graphaware.nlp.dsl.request.TextRankRequest)1 TextRankProcessor (com.graphaware.nlp.ml.textrank.TextRankProcessor)1 TextRankResult (com.graphaware.nlp.ml.textrank.TextRankResult)1 Description (org.neo4j.procedure.Description)1 Procedure (org.neo4j.procedure.Procedure)1