Search in sources :

Example 1 with FuzzyTokenPredicate

use of edu.uci.ics.texera.dataflow.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.texera.dataflow.fuzzytokenmatcher.FuzzyTokenSourcePredicate) FuzzyTokenPredicate(edu.uci.ics.texera.dataflow.fuzzytokenmatcher.FuzzyTokenPredicate) Test(org.junit.Test)

Example 2 with FuzzyTokenPredicate

use of edu.uci.ics.texera.dataflow.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 TexeraException {
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    FuzzyTokenPredicate fuzzyTokenPredicate = new FuzzyTokenPredicate(query, attributeNames, RelationManager.getInstance().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.texera.dataflow.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.texera.api.tuple.Tuple) FuzzyTokenPredicate(edu.uci.ics.texera.dataflow.fuzzytokenmatcher.FuzzyTokenPredicate)

Aggregations

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