Search in sources :

Example 1 with NlpEntityPredicate

use of edu.uci.ics.textdb.exp.nlp.entity.NlpEntityPredicate in project textdb by TextDB.

the class NlpExtractorPerformanceTest method matchNLP.

/*
     * This function does match based on tokenType
     */
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, null);
    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;
}
Also used : NlpEntityPredicate(edu.uci.ics.textdb.exp.nlp.entity.NlpEntityPredicate) Span(edu.uci.ics.textdb.api.span.Span) ScanBasedSourceOperator(edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator) ISourceOperator(edu.uci.ics.textdb.api.dataflow.ISourceOperator) NlpEntityOperator(edu.uci.ics.textdb.exp.nlp.entity.NlpEntityOperator) ScanSourcePredicate(edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.textdb.api.tuple.Tuple)

Example 2 with NlpEntityPredicate

use of edu.uci.ics.textdb.exp.nlp.entity.NlpEntityPredicate in project textdb by TextDB.

the class PredicateBaseTest method testNlpEntity.

@Test
public void testNlpEntity() throws Exception {
    NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(NlpEntityType.LOCATION, attributeNames, "nlpEntityResults");
    testPredicate(nlpEntityPredicate);
}
Also used : NlpEntityPredicate(edu.uci.ics.textdb.exp.nlp.entity.NlpEntityPredicate) Test(org.junit.Test)

Aggregations

NlpEntityPredicate (edu.uci.ics.textdb.exp.nlp.entity.NlpEntityPredicate)2 ISourceOperator (edu.uci.ics.textdb.api.dataflow.ISourceOperator)1 Span (edu.uci.ics.textdb.api.span.Span)1 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)1 NlpEntityOperator (edu.uci.ics.textdb.exp.nlp.entity.NlpEntityOperator)1 ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)1 ScanSourcePredicate (edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate)1 Test (org.junit.Test)1