use of com.graphaware.nlp.ml.textrank.TextRankProcessor in project neo4j-nlp by graphaware.
the class TextRankProcedure method summarizeText.
@Procedure(name = "ga.nlp.ml.textRank.summarize", mode = Mode.WRITE)
@Description("TextRank procedure")
public Stream<SingleResult> summarizeText(@Name("textRankRequest") Map<String, Object> textRankRequest) {
try {
TextRankRequest request = TextRankRequest.fromMap(textRankRequest);
TextRankProcessor processor = (TextRankProcessor) getNLPManager().getExtension(TextRankProcessor.class);
return Stream.of(processor.summarize(request));
} catch (Exception e) {
LOG.error("ERROR in TextRankSummarizer", e);
throw new RuntimeException(e);
}
}
use of com.graphaware.nlp.ml.textrank.TextRankProcessor 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);
}
}
use of com.graphaware.nlp.ml.textrank.TextRankProcessor in project neo4j-nlp by graphaware.
the class TextRankProcedure method textRankPostprocess.
@Procedure(name = "ga.nlp.ml.textRank.postprocess", mode = Mode.WRITE)
@Description("TextRank post-processing procedure")
public Stream<SingleResult> textRankPostprocess(@Name("textRankRequest") Map<String, Object> textRankRequest) {
try {
TextRankPostprocessRequest request = TextRankPostprocessRequest.fromMap(textRankRequest);
TextRankProcessor processor = (TextRankProcessor) getNLPManager().getExtension(TextRankProcessor.class);
return Stream.of(processor.postprocess(request));
} catch (Exception e) {
LOG.error("ERROR in TextRank", e);
throw new RuntimeException(e);
}
}
use of com.graphaware.nlp.ml.textrank.TextRankProcessor in project neo4j-nlp by graphaware.
the class TextRankProcedure method computeAndStoreTextRank.
@Procedure(name = "ga.nlp.ml.textRank", mode = Mode.WRITE)
@Description("Keywords Extraction using TextRank algorithm (includes storage of result)")
public Stream<SingleResult> computeAndStoreTextRank(@Name("textRankRequest") Map<String, Object> textRankRequest) {
try {
TextRankRequest request = TextRankRequest.fromMap(textRankRequest);
TextRankProcessor processor = (TextRankProcessor) getNLPManager().getExtension(TextRankProcessor.class);
return Stream.of(processor.computeAndStore(request));
} catch (Exception e) {
LOG.error("ERROR in TextRank", e);
throw new RuntimeException(e);
}
}
Aggregations