Search in sources :

Example 1 with DictionarySourcePredicate

use of edu.uci.ics.textdb.exp.dictionarymatcher.DictionarySourcePredicate in project textdb by TextDB.

the class DictionaryMatcherPerformanceTest method match.

/**
     * This function does match for a dictionary
     */
public static void match(ArrayList<String> queryList, KeywordMatchingType opType, String luceneAnalyzerStr, String tableName) throws Exception {
    List<String> attributeNames = Arrays.asList(MedlineIndexWriter.ABSTRACT);
    Dictionary dictionary = new Dictionary(queryList);
    DictionarySourcePredicate dictionarySourcePredicate = new DictionarySourcePredicate(dictionary, attributeNames, luceneAnalyzerStr, opType, tableName, null);
    DictionaryMatcherSourceOperator dictionaryMatcher = new DictionaryMatcherSourceOperator(dictionarySourcePredicate);
    long startMatchTime = System.currentTimeMillis();
    dictionaryMatcher.open();
    Tuple nextTuple = null;
    int counter = 0;
    while ((nextTuple = dictionaryMatcher.getNextTuple()) != null) {
        ListField<Span> spanListField = nextTuple.getField(SchemaConstants.SPAN_LIST);
        List<Span> spanList = spanListField.getValue();
        counter += spanList.size();
    }
    dictionaryMatcher.close();
    long endMatchTime = System.currentTimeMillis();
    matchTime = (endMatchTime - startMatchTime) / 1000.0;
    resultCount = counter;
}
Also used : Dictionary(edu.uci.ics.textdb.exp.dictionarymatcher.Dictionary) Span(edu.uci.ics.textdb.api.span.Span) DictionaryMatcherSourceOperator(edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryMatcherSourceOperator) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) DictionarySourcePredicate(edu.uci.ics.textdb.exp.dictionarymatcher.DictionarySourcePredicate)

Example 2 with DictionarySourcePredicate

use of edu.uci.ics.textdb.exp.dictionarymatcher.DictionarySourcePredicate in project textdb by TextDB.

the class PredicateBaseTest method testDictionary.

@Test
public void testDictionary() throws Exception {
    DictionaryPredicate dictionaryPredicate = new DictionaryPredicate(new Dictionary(Arrays.asList("entry1", "entry2")), attributeNames, "standard", KeywordMatchingType.CONJUNCTION_INDEXBASED, "dictResults");
    testPredicate(dictionaryPredicate);
    DictionarySourcePredicate dictionarySourcePredicate = new DictionarySourcePredicate(new Dictionary(Arrays.asList("entry1", "entry2")), attributeNames, "standard", KeywordMatchingType.CONJUNCTION_INDEXBASED, "tableName", "dictSourceResults");
    testPredicate(dictionarySourcePredicate);
}
Also used : Dictionary(edu.uci.ics.textdb.exp.dictionarymatcher.Dictionary) DictionaryPredicate(edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate) DictionarySourcePredicate(edu.uci.ics.textdb.exp.dictionarymatcher.DictionarySourcePredicate) Test(org.junit.Test)

Aggregations

Dictionary (edu.uci.ics.textdb.exp.dictionarymatcher.Dictionary)2 DictionarySourcePredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionarySourcePredicate)2 Span (edu.uci.ics.textdb.api.span.Span)1 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)1 DictionaryMatcherSourceOperator (edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryMatcherSourceOperator)1 DictionaryPredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate)1 Test (org.junit.Test)1