Search in sources :

Example 1 with SimilarityProcessor

use of com.graphaware.nlp.ml.similarity.SimilarityProcessor in project neo4j-nlp by graphaware.

the class SimilarityProcedure method similarity.

@Procedure(name = "ga.nlp.ml.similarity.cosine", mode = Mode.WRITE)
@Description("Compute similarity between Annotated Text")
public Stream<SingleResult> similarity(@Name("similarityRequest") Map<String, Object> similarityRequest) {
    try {
        SimilarityRequest request = SimilarityRequest.fromMap(similarityRequest);
        SimilarityProcessor similarityProcessor = (SimilarityProcessor) getNLPManager().getExtension(SimilarityProcessor.class);
        int processed = similarityProcessor.compute(request);
        return Stream.of(new SingleResult(processed));
    } catch (Exception ex) {
        LOG.error("Error while computing similarity", ex);
        throw new RuntimeException(ex);
    }
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) SimilarityRequest(com.graphaware.nlp.dsl.request.SimilarityRequest) SimilarityProcessor(com.graphaware.nlp.ml.similarity.SimilarityProcessor) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Aggregations

SimilarityRequest (com.graphaware.nlp.dsl.request.SimilarityRequest)1 SingleResult (com.graphaware.nlp.dsl.result.SingleResult)1 SimilarityProcessor (com.graphaware.nlp.ml.similarity.SimilarityProcessor)1 Description (org.neo4j.procedure.Description)1 Procedure (org.neo4j.procedure.Procedure)1