Search in sources :

Example 1 with SingleResult

use of com.graphaware.nlp.dsl.result.SingleResult in project neo4j-nlp by graphaware.

the class AnnotateProcedure method filter.

@Procedure(name = "ga.nlp.filter", mode = Mode.WRITE)
@Description("Boolean filter for text accordingly to complex filter definition")
public Stream<SingleResult> filter(@Name("filterRequest") Map<String, Object> filterRequest) {
    FilterRequest request = FilterRequest.fromMap(filterRequest);
    Object result = getNLPManager().filter(request);
    return Stream.of(new SingleResult(result));
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) FilterRequest(com.graphaware.nlp.dsl.request.FilterRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 2 with SingleResult

use of com.graphaware.nlp.dsl.result.SingleResult in project neo4j-nlp by graphaware.

the class TextProcessorsProcedure method test.

@Procedure(name = "ga.nlp.processor.test", mode = Mode.WRITE)
@Description("Procedure for testing custom models.")
public Stream<SingleResult> test(@Name("customModelsRequest") Map<String, Object> customModelsRequest) {
    try {
        CustomModelsRequest request = CustomModelsRequest.fromMap(customModelsRequest);
        Object result = getNLPManager().test(request);
        return Stream.of(new SingleResult(result));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) CustomModelsRequest(com.graphaware.nlp.dsl.request.CustomModelsRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 3 with SingleResult

use of com.graphaware.nlp.dsl.result.SingleResult in project neo4j-nlp by graphaware.

the class Word2VecProcedure method attachConcepts.

@Procedure(name = "ga.nlp.ml.word2vec.attach", mode = Mode.WRITE)
@Description("For each tag attach the related word2vec value")
public Stream<SingleResult> attachConcepts(@Name("input") Map<String, Object> word2VecRequest) {
    Word2VecRequest request = Word2VecRequest.fromMap(word2VecRequest);
    Word2VecProcessor word2VecProcessor = (Word2VecProcessor) getNLPManager().getExtension(Word2VecProcessor.class);
    int processed = word2VecProcessor.attach(request);
    return Stream.of(new SingleResult(processed));
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) Word2VecRequest(com.graphaware.nlp.dsl.request.Word2VecRequest) Word2VecProcessor(com.graphaware.nlp.ml.word2vec.Word2VecProcessor)

Example 4 with SingleResult

use of com.graphaware.nlp.dsl.result.SingleResult 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> similarityOld(@Name("input") List<Node> input,
// @Name("depth") Long depth,
// @Name("query") String query,
// @Name("relationshipType") String relationshipType) {
// SimilarityProcessor similarityProcessor = (SimilarityProcessor) getNLPManager().getExtension(SimilarityProcessor.class);
// int processed = similarityProcessor.compute(input, query, relationshipType, depth);
// return Stream.of(new SingleResult(processed));
// }
@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)

Example 5 with SingleResult

use of com.graphaware.nlp.dsl.result.SingleResult in project neo4j-nlp by graphaware.

the class TextProcessorsProcedure method train.

@Procedure(name = "ga.nlp.processor.train", mode = Mode.WRITE)
@Description("Procedure for training custom models.")
public Stream<SingleResult> train(@Name("customModelsRequest") Map<String, Object> customModelsRequest) {
    try {
        CustomModelsRequest request = CustomModelsRequest.fromMap(customModelsRequest);
        Object result = getNLPManager().train(request);
        return Stream.of(new SingleResult(result));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) CustomModelsRequest(com.graphaware.nlp.dsl.request.CustomModelsRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Aggregations

SingleResult (com.graphaware.nlp.dsl.result.SingleResult)5 Description (org.neo4j.procedure.Description)4 Procedure (org.neo4j.procedure.Procedure)4 CustomModelsRequest (com.graphaware.nlp.dsl.request.CustomModelsRequest)2 FilterRequest (com.graphaware.nlp.dsl.request.FilterRequest)1 SimilarityRequest (com.graphaware.nlp.dsl.request.SimilarityRequest)1 Word2VecRequest (com.graphaware.nlp.dsl.request.Word2VecRequest)1 SimilarityProcessor (com.graphaware.nlp.ml.similarity.SimilarityProcessor)1 Word2VecProcessor (com.graphaware.nlp.ml.word2vec.Word2VecProcessor)1