@Test public void testEntityExtraction() throws Exception { JSONObject visibilityJson = new JSONObject(); visibilityJson.put("source", ""); Vertex vertex = graph.prepareVertex("v1", new Visibility("")) .setProperty("text", "none", new Visibility("")) .setProperty(LumifyProperties.VISIBILITY_JSON.getPropertyName(), visibilityJson, new Visibility("")) .save(new InMemoryAuthorizations()); GraphPropertyWorkData workData = new GraphPropertyWorkData(visibilityTranslator, vertex, vertex.getProperty("text"), null, null); extractor.setVisibilityTranslator(visibilityTranslator); extractor.execute(new ByteArrayInputStream(text.getBytes("UTF-8")), workData); List<Vertex> termMentions = toList(vertex.getVertices(Direction.OUT, LumifyProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION, authorizations)); assertEquals(3, termMentions.size()); boolean foundBobRobertson = false; boolean foundBenghazi = false; boolean foundCnn = false; for (Vertex termMention : termMentions) { String title = LumifyProperties.TERM_MENTION_TITLE.getPropertyValue(termMention); long start = LumifyProperties.TERM_MENTION_START_OFFSET.getPropertyValue(termMention); long end = LumifyProperties.TERM_MENTION_END_OFFSET.getPropertyValue(termMention); String conceptType = LumifyProperties.TERM_MENTION_CONCEPT_TYPE.getPropertyValue(termMention); if (title.equals("Bob Robértson")) { foundBobRobertson = true; assertEquals("http: assertEquals(31, start); assertEquals(44, end); } else if (title.equals("Benghazi")) { foundBenghazi = true; assertEquals("http: assertEquals(189, start); assertEquals(197, end); } else if (title.equals("CNN")) { foundCnn = true; assertEquals("http: assertEquals(151, start); assertEquals(154, end); } } assertTrue("could not find bob robertson", foundBobRobertson); assertTrue("could not find benghazi", foundBenghazi); assertTrue("could not find cnn", foundCnn); }
@Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(in, "UTF-8"); String line; int charOffset = 0; LOGGER.debug("Processing artifact content stream"); Vertex sourceVertex = (Vertex) data.getElement(); List<Vertex> termMentions = new ArrayList<>(); while ((line = untokenizedLineStream.read()) != null) { termMentions.addAll(processLine(sourceVertex, data.getProperty().getKey(), line, charOffset, LumifyProperties.VISIBILITY_JSON.getPropertyValue(sourceVertex))); getGraph().flush(); charOffset += line.length() + NEW_LINE_CHARACTER_LENGTH; } applyTermMentionFilters(sourceVertex, termMentions); pushTextUpdated(data); untokenizedLineStream.close(); LOGGER.debug("Stream processing completed"); }
OpenNLPMaximumEntropyExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(in, "UTF-8"); String line; int charOffset = 0; LOGGER.debug("Processing artifact content stream"); Vertex sourceVertex = (Vertex) data.getElement(); List<Vertex> termMentions = new ArrayList<>(); while ((line = untokenizedLineStream.read()) != null) { termMentions.addAll(processLine(sourceVertex, data.getProperty().getKey(), line, charOffset, LumifyProperties.VISIBILITY_JSON.getPropertyValue(sourceVertex))); getGraph().flush(); charOffset += line.length() + NEW_LINE_CHARACTER_LENGTH; } applyTermMentionFilters(sourceVertex, termMentions); pushTextUpdated(data); untokenizedLineStream.close(); LOGGER.debug("Stream processing completed"); } }
OpenNLPMaximumEntropyExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(in, "UTF-8"); String line; int charOffset = 0; LOGGER.debug("Processing artifact content stream"); Vertex sourceVertex = (Vertex) data.getElement(); List<Vertex> termMentions = new ArrayList<>(); while ((line = untokenizedLineStream.read()) != null) { termMentions.addAll(processLine(sourceVertex, data.getProperty().getKey(), line, charOffset, LumifyProperties.VISIBILITY_JSON.getPropertyValue(sourceVertex))); getGraph().flush(); charOffset += line.length() + NEW_LINE_CHARACTER_LENGTH; } applyTermMentionFilters(sourceVertex, termMentions); pushTextUpdated(data); untokenizedLineStream.close(); LOGGER.debug("Stream processing completed"); }  }
OpenNLPMaximumEntropyExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(in, "UTF-8"); String line; int charOffset = 0; LOGGER.debug("Processing artifact content stream"); Vertex sourceVertex = (Vertex) data.getElement(); List<Vertex> termMentions = new ArrayList<>(); while ((line = untokenizedLineStream.read()) != null) { termMentions.addAll(processLine(sourceVertex, data.getProperty().getKey(), line, charOffset, LumifyProperties.VISIBILITY_JSON.getPropertyValue(sourceVertex))); getGraph().flush(); charOffset += line.length() + NEW_LINE_CHARACTER_LENGTH; } applyTermMentionFilters(sourceVertex, termMentions); pushTextUpdated(data); untokenizedLineStream.close(); LOGGER.debug("Stream processing completed"); }  @Override void prepare(GraphPropertyWorkerPrepareData workerPrepareData); @Override void execute(InputStream in, GraphPropertyWorkData data); @Override boolean isHandled(Element element, Property property); }
OpenNLPMaximumEntropyExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(in, "UTF-8"); String line; int charOffset = 0; LOGGER.debug("Processing artifact content stream"); Vertex sourceVertex = (Vertex) data.getElement(); List<Vertex> termMentions = new ArrayList<>(); while ((line = untokenizedLineStream.read()) != null) { termMentions.addAll(processLine(sourceVertex, data.getProperty().getKey(), line, charOffset, LumifyProperties.VISIBILITY_JSON.getPropertyValue(sourceVertex))); getGraph().flush(); charOffset += line.length() + NEW_LINE_CHARACTER_LENGTH; } applyTermMentionFilters(sourceVertex, termMentions); pushTextUpdated(data); untokenizedLineStream.close(); LOGGER.debug("Stream processing completed"); }  @Override void prepare(GraphPropertyWorkerPrepareData workerPrepareData); @Override void execute(InputStream in, GraphPropertyWorkData data); @Override boolean isHandled(Element element, Property property); static final String PATH_PREFIX_CONFIG; }