@Test public void testSingleGraphTransform() throws UIMAException { EntityGraphOptions options = EntityGraphOptions.builder() .withValueStrategy("value", new Longest()) .withValueStrategy("gender", new Mode<String>()) .build(); EntityGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); String documentId = ConsumerUtils.getExternalId( UimaSupport.getDocumentAnnotation(jCas), options.isContentHashAsId()); final GraphTraversalSource traversal = graph.traversal(); assertEquals(3, traversal.V().hasLabel(ENTITY).count().next().intValue()); assertEquals(1, traversal.V().hasLabel(EVENT).count().next().intValue()); assertEquals(2, traversal.E().hasLabel(PARTICIPANT_IN).count().next().intValue()); assertEquals(2, traversal.E().hasLabel(RELATION).count().next().intValue()); assertEquals(4, IteratorUtils.count(graph.vertices())); assertEquals(4, IteratorUtils.count(graph.edges())); JCasUtil.select(jCas, Entity.class) .forEach( e -> assertTrue( traversal .V() .hasLabel(ENTITY) .has("type") .has(MENTIONS_PROPERTY) .has("value") .not(has("begin")) .not(has("end")) .hasNext())); Event event = JCasUtil.selectSingle(jCas, Event.class); assertTrue( traversal .V(event.getExternalId()) .hasLabel(EVENT) .has("value", event.getValue()) .not(has("begin")) .not(has("end")) .has(MENTIONS_PROPERTY) .hasNext()); JCasUtil.select(jCas, Relation.class) .forEach( r -> assertTrue( traversal .E(r.getExternalId()) .hasLabel(RELATION) .has("relationshipType", r.getRelationshipType()) .has("value", r.getValue()) .not(has("begin")) .not(has("end")) .has(MENTIONS_PROPERTY) .hasNext())); assertTrue( traversal .V() .has("gender", "Male") .has("value", "John Smith") .not(has("value", "He")) .has(LONGEST_VALUE, "John Smith") .has(DocumentGraphFactory.FIELD_DOCUMENT_ID, ImmutableList.of(documentId, documentId)) .hasNext()); }
public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; }
EntityGraphFactory { public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; } }
EntityGraphFactory { public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; } EntityGraphFactory(final UimaMonitor monitor, EntityGraphOptions options); }
EntityGraphFactory { public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; } EntityGraphFactory(final UimaMonitor monitor, EntityGraphOptions options); Graph create(JCas jCas); Graph create(JCas jCas, Features features); void load(JCas jCas, Graph graph, Features features); }
EntityGraphFactory { public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; } EntityGraphFactory(final UimaMonitor monitor, EntityGraphOptions options); Graph create(JCas jCas); Graph create(JCas jCas, Features features); void load(JCas jCas, Graph graph, Features features); static final String MENTIONS_PROPERTY; static final String MOST_COMMON_VALUE; static final String LONGEST_VALUE; }