/** * Load the data form the jCas into the given graph traversal. * * @param jCas to load the data from * @param traversal to load the data into */ public void load(JCas jCas, GraphTraversalSource traversal) { traversal(jCas, traversal); }
/** @return a Builder to create {@link DocumentGraphOptions}. */ public static Builder builder() { return new DocumentGraphOptions.Builder(); } }
/** @return a Builder to create {@link EntityGraphOptions}. */ public static Builder builder() { return new EntityGraphOptions.Builder(); } }
/** * 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); }
@Test public void testDocumentGraphCreatesMetadataFromJCas() throws UIMAException { DocumentGraphOptions options = DocumentGraphOptions.builder().withMeta(true).build(); DocumentGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); assertMetadata(jCas, graph.variables().asMap()); }
@Test public void testDocumentGraphMetadataHasContentFromJCas() throws UIMAException { DocumentGraphOptions options = DocumentGraphOptions.builder().withContent(true).build(); DocumentGraphFactory factory = createfactory(options); JCas jCas = JCasFactory.createJCas(); JCasTestGraphUtil.populateJcas(jCas); Graph graph = factory.create(jCas); Variables variables = graph.variables(); assertEquals(JCasTestGraphUtil.CONTENT, variables.get(FIELD_CONTENT).orElse("")); }
@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()); }
private Optional<Vertex> traversal(JCas jCas, GraphTraversalSource traversal) { EntityRelationConverter converter = new EntityRelationConverter(monitor, options.getStopFeatures(), fields, false); loadMentions(jCas, traversal, converter); if (options.isOutputRelations()) { loadRelations(jCas, traversal, converter); } else { monitor.debug("DocumentGraph relations ommitted"); } if (options.isOutputEvents()) { loadEvents(jCas, traversal, converter); } else { monitor.debug("DocumentGraph events ommitted"); } return loadDocument(jCas, traversal); }
/** * Create a document graph from the given jCas. * * @param jCas to create the document from * @return the document graph * @throws AnalysisEngineProcessException */ public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; }
@Override protected void addOptions(EntityGraphOptions.Builder builder) { builder.withValueCoercer(new Neo4JValueCoercer()); }
@Override protected void addOptions(Builder builder) { builder.withValueCoercer(new Neo4JValueCoercer()); }
private DocumentGraphFactory createfactory(DocumentGraphOptions options) { UimaMonitor monitor = new UimaMonitor("test", DocumentGraphFactoryTest.class); return new DocumentGraphFactory(monitor, options); }
/** * Create a document graph from the given jCas. * * @param jCas to create the document from * @return the document graph */ public Graph create(JCas jCas) { TinkerGraph graph = TinkerGraph.open(); load(jCas, graph); return graph; }
protected Object setProperty(Element v, String key, Object value) { return v.property(key, coerce(value)); } }
/** * 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); }
/** * Create a document graph from the given jCas. * * @param jCas to create the document from * @return the document graph * @throws AnalysisEngineProcessException */ public Graph create(JCas jCas) throws AnalysisEngineProcessException { Graph graph = createTransformGraph(options.isMultiValueProperties()); load(jCas, graph, graph.features()); return graph; }
/** * Load the data form the jCas into the given graph traversal. * * @param jCas to load the data from * @param traversal to load the data into */ public void load(JCas jCas, GraphTraversalSource traversal) { traversal(jCas, traversal); }
/** @return a Builder to create {@link DocumentGraphOptions}. */ public static Builder builder() { return new DocumentGraphOptions.Builder(); } }
/** @return a Builder to create {@link EntityGraphOptions}. */ public static Builder builder() { return new EntityGraphOptions.Builder(); } }
/** * Create a document graph from the given jCas. * * @param jCas to create the document from * @return the document graph */ public Graph create(JCas jCas) { TinkerGraph graph = TinkerGraph.open(); load(jCas, graph); return graph; }