Search in sources :

Example 1 with FuzzyTokenMatcherSourceOperator

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

the class JoinDistanceTest method testOneOfTheOperatorResultContainsNoSpan.

// This case tests for the scenario when one of the operators result lists has no span. 
// If one of the operators doesn't have span, then an exception will be thrown.
// Test result: DataFlowException is thrown
@Test(expected = DataFlowException.class)
public void testOneOfTheOperatorResultContainsNoSpan() throws Exception {
    JoinTestHelper.insertToTable(BOOK_TABLE, JoinTestConstants.bookGroup1.get(0));
    KeywordMatcherSourceOperator keywordSourceOuter = JoinTestHelper.getKeywordSource(BOOK_TABLE, "special", conjunction);
    String fuzzyTokenQuery = "this writer writes well";
    double thresholdRatio = 0.25;
    List<String> textAttributeNames = JoinTestConstants.BOOK_SCHEMA.getAttributes().stream().filter(attr -> attr.getAttributeType() != AttributeType.TEXT).map(Attribute::getAttributeName).collect(Collectors.toList());
    FuzzyTokenSourcePredicate fuzzySourcePredicateInner = new FuzzyTokenSourcePredicate(fuzzyTokenQuery, textAttributeNames, LuceneAnalyzerConstants.standardAnalyzerString(), thresholdRatio, BOOK_TABLE, SchemaConstants.SPAN_LIST);
    FuzzyTokenMatcherSourceOperator fuzzyMatcherInner = new FuzzyTokenMatcherSourceOperator(fuzzySourcePredicateInner);
    ProjectionPredicate removeSpanListPredicate = new ProjectionPredicate(JoinTestConstants.BOOK_SCHEMA.getAttributeNames());
    ProjectionOperator removeSpanListProjection = new ProjectionOperator(removeSpanListPredicate);
    removeSpanListProjection.setInputOperator(fuzzyMatcherInner);
    JoinTestHelper.getJoinDistanceResults(keywordSourceOuter, removeSpanListProjection, new JoinDistancePredicate(JoinTestConstants.REVIEW, 20), Integer.MAX_VALUE, 0);
}
Also used : FuzzyTokenMatcherSourceOperator(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenMatcherSourceOperator) ProjectionOperator(edu.uci.ics.textdb.exp.projection.ProjectionOperator) FuzzyTokenSourcePredicate(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenSourcePredicate) ProjectionPredicate(edu.uci.ics.textdb.exp.projection.ProjectionPredicate) JoinDistancePredicate(edu.uci.ics.textdb.exp.join.JoinDistancePredicate) KeywordMatcherSourceOperator(edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator) Test(org.junit.Test)

Example 2 with FuzzyTokenMatcherSourceOperator

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

the class FuzzyTokenMatcherPerformanceTest method match.

/*
     * This function does match for a list of queries
     */
public static void match(ArrayList<String> queryList, double threshold, String luceneAnalyzerStr, String tableName, boolean bool) throws TextDBException, IOException {
    List<String> attributeNames = Arrays.asList(MedlineIndexWriter.ABSTRACT);
    for (String query : queryList) {
        FuzzyTokenSourcePredicate predicate = new FuzzyTokenSourcePredicate(query, attributeNames, luceneAnalyzerStr, threshold, tableName, null);
        FuzzyTokenMatcherSourceOperator fuzzyTokenSource = new FuzzyTokenMatcherSourceOperator(predicate);
        long startMatchTime = System.currentTimeMillis();
        fuzzyTokenSource.open();
        int counter = 0;
        Tuple nextTuple = null;
        while ((nextTuple = fuzzyTokenSource.getNextTuple()) != null) {
            ListField<Span> spanListField = nextTuple.getField(SchemaConstants.SPAN_LIST);
            List<Span> spanList = spanListField.getValue();
            counter += spanList.size();
        }
        fuzzyTokenSource.close();
        long endMatchTime = System.currentTimeMillis();
        double matchTime = (endMatchTime - startMatchTime) / 1000.0;
        timeResults.add(Double.parseDouble(String.format("%.4f", matchTime)));
        totalResultCount += counter;
    }
}
Also used : FuzzyTokenMatcherSourceOperator(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenMatcherSourceOperator) FuzzyTokenSourcePredicate(edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenSourcePredicate) Span(edu.uci.ics.textdb.api.span.Span) Tuple(edu.uci.ics.textdb.api.tuple.Tuple)

Aggregations

FuzzyTokenMatcherSourceOperator (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenMatcherSourceOperator)2 FuzzyTokenSourcePredicate (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenSourcePredicate)2 Span (edu.uci.ics.textdb.api.span.Span)1 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)1 JoinDistancePredicate (edu.uci.ics.textdb.exp.join.JoinDistancePredicate)1 KeywordMatcherSourceOperator (edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator)1 ProjectionOperator (edu.uci.ics.textdb.exp.projection.ProjectionOperator)1 ProjectionPredicate (edu.uci.ics.textdb.exp.projection.ProjectionPredicate)1 Test (org.junit.Test)1