Search in sources :

Example 1 with FuzzyTokenPredicate

use of edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenPredicate in project textdb by TextDB.

the class PredicateBaseTest method testFuzzyToken.

@Test
public void testFuzzyToken() throws Exception {
    FuzzyTokenPredicate fuzzyTokenPredicate = new FuzzyTokenPredicate("token1 token2 token3", attributeNames, "standard", 0.8, "spanListName");
    testPredicate(fuzzyTokenPredicate);
    FuzzyTokenSourcePredicate fuzzyTokenSourcePredicate = new FuzzyTokenSourcePredicate("token1 token2 token3", attributeNames, "standard", 0.8, "tableName", "spanListName");
    testPredicate(fuzzyTokenSourcePredicate);
}
Also used : FuzzyTokenSourcePredicate(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenSourcePredicate) FuzzyTokenPredicate(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenPredicate) Test(org.junit.Test)

Example 2 with FuzzyTokenPredicate

use of edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenPredicate in project textdb by TextDB.

the class FuzzyTokenMatcherTestHelper method getScanSourceResults.

/*
     * Gets the query results by scanning the table and passing the data into a FuzzyTokenMatcher.
     */
public static List<Tuple> getScanSourceResults(String tableName, String query, double threshold, List<String> attributeNames, int limit, int offset) throws TextDBException {
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    FuzzyTokenPredicate fuzzyTokenPredicate = new FuzzyTokenPredicate(query, attributeNames, RelationManager.getRelationManager().getTableAnalyzerString(tableName), threshold, RESULTS);
    FuzzyTokenMatcher fuzzyTokenMatcher = new FuzzyTokenMatcher(fuzzyTokenPredicate);
    fuzzyTokenMatcher.setLimit(limit);
    fuzzyTokenMatcher.setOffset(offset);
    fuzzyTokenMatcher.setInputOperator(scanSource);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    fuzzyTokenMatcher.open();
    while ((tuple = fuzzyTokenMatcher.getNextTuple()) != null) {
        results.add(tuple);
    }
    fuzzyTokenMatcher.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) 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) FuzzyTokenPredicate(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenPredicate)

Aggregations

FuzzyTokenPredicate (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenPredicate)2 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)1 FuzzyTokenSourcePredicate (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenSourcePredicate)1 ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)1 ScanSourcePredicate (edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1