@Test public void testDocumentGraphWithTypeFiltering() throws UIMAException { Set<Class<? extends Entity>> typeClasses = TypeUtils.getTypeClasses(Entity.class, Person.class.getSimpleName()); DocumentGraphOptions options = DocumentGraphOptions.builder().withTypeClasses(typeClasses).build(); DocumentGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); assertEquals(2, graph.traversal().V().hasLabel(REFERENCE_TARGET).count().next().intValue()); assertEquals(1, graph.traversal().V().hasLabel(EVENT).count().next().intValue()); assertEquals(3, graph.traversal().V().hasLabel(MENTION).count().next().intValue()); assertEquals(1, graph.traversal().V().hasLabel(RELATION).count().next().intValue()); assertEquals(3, graph.traversal().E().hasLabel(MENTION_OF).count().next().intValue()); assertEquals(2, graph.traversal().E().hasLabel(PARTICIPANT_IN).count().next().intValue()); assertNoDocumentNode(graph); assertNoRelationEdges(graph); assertEquals(7, IteratorUtils.count(graph.vertices())); assertEquals(7, IteratorUtils.count(graph.edges())); }
/** * Constructor for EntityGraphFactory * * @param monitor to report * @param options to be used during creation of graphs */ public EntityGraphFactory(final UimaMonitor monitor, EntityGraphOptions options) { this.monitor = monitor; this.options = options; DocumentGraphOptions documentOptions = new DocumentGraphOptions.Builder() .withDocument(false) .withRelationsAsLinks(true) .withContentHashAsId(options.isContentHashAsId()) .withEvents(options.isOutputEvents()) .withStopFeatures(options.getStopFeatures()) .withTypeClasses(options.getTypeClasses()) .build(); factory = new DocumentGraphFactory(monitor, documentOptions); }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); Set<Class<? extends Entity>> typeClasses = TypeUtils.getTypeClasses(Entity.class, typeNames); DocumentGraphOptions.Builder builder = DocumentGraphOptions.builder() .withContentHashAsId(contentHashAsId) .withContent(outputContent) .withMeta(outputMeta) .withReferenceTargets(outputReferents) .withRelations(outputRelations) .withRelationsAsLinks(outputRelationsAsLinks) .withEvents(outputEvents) .withDocument(outputDocument) .withStopFeatures(filterFeatures) .withValueCoercer(valueCoercer) .withTypeClasses(typeClasses); addOptions(builder); factory = new DocumentGraphFactory(getMonitor(), builder.build()); }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); Set<Class<? extends Entity>> typeClasses = TypeUtils.getTypeClasses(Entity.class, typeNames); DocumentGraphOptions.Builder builder = DocumentGraphOptions.builder() .withContentHashAsId(contentHashAsId) .withContent(outputContent) .withMeta(outputMeta) .withReferenceTargets(outputReferents) .withRelations(outputRelations) .withRelationsAsLinks(outputRelationsAsLinks) .withEvents(outputEvents) .withDocument(outputDocument) .withStopFeatures(filterFeatures) .withValueCoercer(valueCoercer) .withTypeClasses(typeClasses); addOptions(builder); factory = new DocumentGraphFactory(getMonitor(), builder.build()); }
/** * Constructor for EntityGraphFactory * * @param monitor to report * @param options to be used during creation of graphs */ public EntityGraphFactory(final UimaMonitor monitor, EntityGraphOptions options) { this.monitor = monitor; this.options = options; DocumentGraphOptions documentOptions = new DocumentGraphOptions.Builder() .withDocument(false) .withRelationsAsLinks(true) .withContentHashAsId(options.isContentHashAsId()) .withEvents(options.isOutputEvents()) .withStopFeatures(options.getStopFeatures()) .withTypeClasses(options.getTypeClasses()) .build(); factory = new DocumentGraphFactory(monitor, documentOptions); }