@Test public void testEntityExtraction() throws Exception { JSONObject visibilityJson = new JSONObject(); visibilityJson.put("source", ""); InMemoryVertex vertex = (InMemoryVertex) graph.prepareVertex("v1", new Visibility("")) .setProperty("text", "none", new Visibility("")) .setProperty(LumifyProperties.VISIBILITY_JSON.getPropertyName(), visibilityJson, new Visibility("")) .save(new InMemoryAuthorizations()); graph.flush(); GraphPropertyWorkData workData = new GraphPropertyWorkData(visibilityTranslator, vertex, vertex.getProperty("text"), null, ""); String text = "This is a sentence that is going to tell you about a guy named " + "Bob Robertson who lives in Boston, MA and works for a company called Altamira Corporation"; extractor.execute(new ByteArrayInputStream(text.getBytes()), workData); List<Vertex> termMentions = toList(termMentionRepository.findBySourceGraphVertex(vertex.getId(), authorizations)); assertEquals(3, termMentions.size()); boolean found = false; for (Vertex term : termMentions) { String title = LumifyProperties.TERM_MENTION_TITLE.getPropertyValue(term); if (title.equals("Bob Robertson")) { found = true; assertEquals(63, LumifyProperties.TERM_MENTION_START_OFFSET.getPropertyValue(term, 0)); assertEquals(76, LumifyProperties.TERM_MENTION_END_OFFSET.getPropertyValue(term, 0)); break; } } assertTrue("Expected name not found!", found); ArrayList<String> signs = new ArrayList<>(); for (Vertex term : termMentions) { String title = LumifyProperties.TERM_MENTION_TITLE.getPropertyValue(term); signs.add(title); } assertTrue("Bob Robertson not found", signs.contains("Bob Robertson")); assertTrue("Altamira Corporation not found", signs.contains("Altamira Corporation")); assertTrue("Boston , MA not found", signs.contains("Boston , MA")); }
@Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(new InputStreamReader(in)); 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"); }
OpenNLPDictionaryExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(new InputStreamReader(in)); 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"); } }
OpenNLPDictionaryExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(new InputStreamReader(in)); 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"); }  }
OpenNLPDictionaryExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(new InputStreamReader(in)); 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); @Inject void setDictionaryEntryRepository(DictionaryEntryRepository dictionaryEntryRepository); }
OpenNLPDictionaryExtractorGraphPropertyWorker extends GraphPropertyWorker { @Override public void execute(InputStream in, GraphPropertyWorkData data) throws Exception { ObjectStream<String> untokenizedLineStream = new PlainTextByLineStream(new InputStreamReader(in)); 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); @Inject void setDictionaryEntryRepository(DictionaryEntryRepository dictionaryEntryRepository); static final String PATH_PREFIX_CONFIG; }