Search in sources :

Example 1 with NodeResult

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

the class AnnotateProcedure method annotate.

@Procedure(name = "ga.nlp.annotate", mode = Mode.WRITE)
@Description("Performs the text annotation and store it into the graph")
public Stream<NodeResult> annotate(@Name("annotationRequest") Map<String, Object> annotationRequest) {
    try {
        AnnotationRequest request = AnnotationRequest.fromMap(annotationRequest);
        Node result = getNLPManager().annotateTextAndPersist(request);
        return Stream.of(new NodeResult(result));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : AnnotationRequest(com.graphaware.nlp.dsl.request.AnnotationRequest) NodeResult(com.graphaware.nlp.dsl.result.NodeResult) Node(org.neo4j.graphdb.Node) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 2 with NodeResult

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

the class ComputeVectorProcedure method annotate.

@Procedure(name = "ga.nlp.vector.compute", mode = Mode.WRITE)
@Description("Compute vectors for input node and store vector in the property specified")
public Stream<NodeResult> annotate(@Name("computeVectorRequest") Map<String, Object> computeVectorRequest) {
    try {
        ComputeVectorRequest request = ComputeVectorRequest.fromMap(computeVectorRequest);
        Node result = getNLPManager().computeVectorAndPersist(request);
        return Stream.of(new NodeResult(result));
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : NodeResult(com.graphaware.nlp.dsl.result.NodeResult) Node(org.neo4j.graphdb.Node) ComputeVectorRequest(com.graphaware.nlp.dsl.request.ComputeVectorRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 3 with NodeResult

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

the class EnrichConceptProcedure method annotate.

@Procedure(name = "ga.nlp.enrich.concept", mode = Mode.WRITE)
@Description("Enrich knowledge concepts by consulting external knowledge bases like ConceptNet5 or Microsoft Concept Graphs")
public Stream<NodeResult> annotate(@Name("conceptRequest") Map<String, Object> conceptRequest) {
    ConceptRequest request = ConceptRequest.fromMap(conceptRequest);
    Enricher enricher = getNLPManager().getEnricher(request.getEnricherName());
    Node result = enricher.importConcept(request);
    return Stream.of(new NodeResult(result));
}
Also used : NodeResult(com.graphaware.nlp.dsl.result.NodeResult) Node(org.neo4j.graphdb.Node) ConceptRequest(com.graphaware.nlp.dsl.request.ConceptRequest) Enricher(com.graphaware.nlp.enrich.Enricher) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Aggregations

NodeResult (com.graphaware.nlp.dsl.result.NodeResult)3 Node (org.neo4j.graphdb.Node)3 Description (org.neo4j.procedure.Description)3 Procedure (org.neo4j.procedure.Procedure)3 AnnotationRequest (com.graphaware.nlp.dsl.request.AnnotationRequest)1 ComputeVectorRequest (com.graphaware.nlp.dsl.request.ComputeVectorRequest)1 ConceptRequest (com.graphaware.nlp.dsl.request.ConceptRequest)1 Enricher (com.graphaware.nlp.enrich.Enricher)1