Search in sources :

Example 1 with DictionaryPredicate

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

the class DictionaryMatcherTestHelper method getScanSourceResults.

/**
     * Get the results from a DictionaryMatcher with a ScanSource Operator 
     *   (which scans the table first and then feeds the data into the dictionary matcher)
     * 
     * @param tableName
     * @param dictionary
     * @param attributeNames
     * @param matchingType
     * @param limit
     * @param offset
     * @return
     * @throws TextDBException
     */
public static List<Tuple> getScanSourceResults(String tableName, Dictionary dictionary, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    String luceneAnalyzerStr = relationManager.getTableAnalyzerString(tableName);
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    DictionaryPredicate dictiaonryPredicate = new DictionaryPredicate(dictionary, attributeNames, luceneAnalyzerStr, matchingType, RESULTS);
    DictionaryMatcher dictionaryMatcher = new DictionaryMatcher(dictiaonryPredicate);
    dictionaryMatcher.setLimit(limit);
    dictionaryMatcher.setOffset(offset);
    dictionaryMatcher.setInputOperator(scanSource);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    dictionaryMatcher.open();
    while ((tuple = dictionaryMatcher.getNextTuple()) != null) {
        results.add(tuple);
    }
    dictionaryMatcher.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) DictionaryPredicate(edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate) ScanBasedSourceOperator(edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Example 2 with DictionaryPredicate

use of edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate 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

DictionaryPredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate)2 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)1 Dictionary (edu.uci.ics.textdb.exp.dictionarymatcher.Dictionary)1 DictionarySourcePredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionarySourcePredicate)1 ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)1 ScanSourcePredicate (edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate)1 RelationManager (edu.uci.ics.textdb.storage.RelationManager)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1