@Test public void testNlpEntity() throws Exception { NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate( NlpEntityType.LOCATION, attributeNames, "nlpEntityResults"); testPredicate(nlpEntityPredicate); }
public static void matchNLP(String tableName, NlpEntityType tokenType) throws Exception { List<String> attributeNames = Arrays.asList(MedlineIndexWriter.ABSTRACT); ISourceOperator sourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName)); NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(tokenType, attributeNames, SchemaConstants.SPAN_LIST); NlpEntityOperator nlpEntityOperator = new NlpEntityOperator(nlpEntityPredicate); nlpEntityOperator.setInputOperator(sourceOperator); long startMatchTime = System.currentTimeMillis(); nlpEntityOperator.open(); Tuple nextTuple = null; int counter = 0; while ((nextTuple = nlpEntityOperator.getNextTuple()) != null) { ListField<Span> spanListField = nextTuple.getField(SchemaConstants.SPAN_LIST); List<Span> spanList = spanListField.getValue(); counter += spanList.size(); } nlpEntityOperator.close(); long endMatchTime = System.currentTimeMillis(); double matchTime = (endMatchTime - startMatchTime) / 1000.0; totalMatchingTime += matchTime; totalResults += counter; }
public List<Tuple> getQueryResults(String tableName, List<String> attributeNames, NlpEntityType nlpEntityType, int limit, int offset) throws Exception { ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName)); NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(nlpEntityType, attributeNames, RESULTS); NlpEntityOperator nlpEntityOperator = new NlpEntityOperator(nlpEntityPredicate); nlpEntityOperator.setInputOperator(scanSource); nlpEntityOperator.setLimit(limit); nlpEntityOperator.setOffset(offset); Tuple nextTuple = null; List<Tuple> results = new ArrayList<Tuple>(); nlpEntityOperator.open(); while ((nextTuple = nlpEntityOperator.getNextTuple()) != null) { results.add(nextTuple); } nlpEntityOperator.close(); return results; }