@Override protected void doProcess(JCas jCas) throws AnalysisEngineProcessException { String documentSourceName = SourceUtils.getDocumentSourceBaseName(jCas); Graph entityGraph = factory.create(jCas); processGraph(documentSourceName, entityGraph); }
@Override protected void doProcess(JCas jCas) throws AnalysisEngineProcessException { String documentSourceName = SourceUtils.getDocumentSourceBaseName(jCas); Graph entityGraph = factory.create(jCas); processGraph(documentSourceName, entityGraph); }
@Test public void testValueCoerser() throws UIMAException { EntityGraphOptions options = EntityGraphOptions.builder().withValueCoercer((v) -> 1).build(); EntityGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); final GraphTraversalSource traversal = graph.traversal(); traversal .V() .forEachRemaining( v -> { Set<Object> values = ElementHelper.propertyValueMap(v).values().stream().collect(Collectors.toSet()); assertAllValuesCoerceTo1(v, values); }); traversal .E() .forEachRemaining( v -> { Set<Object> values = ElementHelper.propertyValueMap(v).values().stream().collect(Collectors.toSet()); assertTrue(values.contains(1) && values.size() == 1 || values.size() == 0); }); }
@Test public void testStopFetures() throws UIMAException { EntityGraphOptions options = EntityGraphOptions.builder().withStopFeatures("gender").build(); EntityGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); final GraphTraversalSource traversal = graph.traversal(); assertTrue(traversal.V().not(has("gender")).hasNext()); }
@Test public void testNoEvents() throws UIMAException { EntityGraphOptions options = EntityGraphOptions.builder().withEvents(false).build(); EntityGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); final GraphTraversalSource traversal = graph.traversal(); assertEquals(3, traversal.V().hasLabel(ENTITY).count().next().intValue()); assertEquals(0, traversal.V().hasLabel(EVENT).count().next().intValue()); assertEquals(0, traversal.E().hasLabel(PARTICIPANT_IN).count().next().intValue()); assertEquals(2, traversal.E().hasLabel(RELATION).count().next().intValue()); assertEquals(3, IteratorUtils.count(graph.vertices())); assertEquals(2, IteratorUtils.count(graph.edges())); }
JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas);
JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); String documentId = ConsumerUtils.getExternalId(