Search in sources :

Example 6 with ConceptRequest

use of com.graphaware.nlp.dsl.request.ConceptRequest in project neo4j-nlp by graphaware.

the class ConceptRequestUnitTest method testRequestWithLimitLongCanBeCaster.

@Test
public void testRequestWithLimitLongCanBeCaster() {
    Map<String, Object> map = new HashMap<>();
    map.put("tag", new NodeProxy());
    map.put("admittedRelationships", Arrays.asList("IsA", "PartOf"));
    map.put("admittedPos", Arrays.asList("NNS", "NN"));
    map.put("language", "en");
    map.put("splitTag", true);
    map.put("limit", 50L);
    ConceptRequest request = ConceptRequest.fromMap(map);
    assertEquals(50, request.getResultsLimit());
}
Also used : HashMap(java.util.HashMap) ConceptRequest(com.graphaware.nlp.dsl.request.ConceptRequest) NodeProxy(com.graphaware.nlp.util.NodeProxy) Test(org.junit.Test)

Example 7 with ConceptRequest

use of com.graphaware.nlp.dsl.request.ConceptRequest in project neo4j-nlp by graphaware.

the class ConceptRequestUnitTest method testConceptRequestFromMap.

@Test
public void testConceptRequestFromMap() {
    Map<String, Object> map = new HashMap<>();
    map.put("tag", new NodeProxy());
    map.put("admittedRelationships", Arrays.asList("IsA", "PartOf"));
    map.put("admittedPos", Arrays.asList("NNS", "NN"));
    map.put("splitTag", true);
    map.put("relDirection", "out");
    ConceptRequest request = ConceptRequest.fromMap(map);
    assertEquals(2, request.getAdmittedRelationships().size());
    assertTrue(request.getAdmittedRelationships().contains("IsA"));
    assertEquals(2, request.getAdmittedPos().size());
    assertEquals("out", request.getRelDirection());
}
Also used : HashMap(java.util.HashMap) ConceptRequest(com.graphaware.nlp.dsl.request.ConceptRequest) NodeProxy(com.graphaware.nlp.util.NodeProxy) Test(org.junit.Test)

Example 8 with ConceptRequest

use of com.graphaware.nlp.dsl.request.ConceptRequest 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

ConceptRequest (com.graphaware.nlp.dsl.request.ConceptRequest)8 Test (org.junit.Test)7 DynamicConfiguration (com.graphaware.nlp.configuration.DynamicConfiguration)4 EnricherAbstractTest (com.graphaware.nlp.enrich.EnricherAbstractTest)4 PersistenceRegistry (com.graphaware.nlp.persistence.PersistenceRegistry)4 TextProcessorsManager (com.graphaware.nlp.processor.TextProcessorsManager)4 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)4 Transaction (org.neo4j.graphdb.Transaction)4 NodeProxy (com.graphaware.nlp.util.NodeProxy)3 TestNLPGraph (com.graphaware.nlp.util.TestNLPGraph)3 HashMap (java.util.HashMap)3 NodeResult (com.graphaware.nlp.dsl.result.NodeResult)1 Enricher (com.graphaware.nlp.enrich.Enricher)1 TextProcessor (com.graphaware.nlp.processor.TextProcessor)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 Label (org.neo4j.graphdb.Label)1