Search in sources :

Example 6 with ScanBasedSourceOperator

use of edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class KeywordTestHelper method getScanSourceResults.

public static List<Tuple> getScanSourceResults(String tableName, String keywordQuery, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    KeywordPredicate keywordPredicate = new KeywordPredicate(keywordQuery, attributeNames, relationManager.getTableAnalyzerString(tableName), matchingType, RESULTS, limit, offset);
    KeywordMatcher keywordMatcher = new KeywordMatcher(keywordPredicate);
    keywordMatcher.setInputOperator(scanSource);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    keywordMatcher.open();
    while ((tuple = keywordMatcher.getNextTuple()) != null) {
        results.add(tuple);
    }
    keywordMatcher.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) RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Example 7 with ScanBasedSourceOperator

use of edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class NlpEntityTest method getQueryResults.

public List<Tuple> getQueryResults(String tableName, List<String> attributeNames, NlpEntityType nlpEntityType, int limit, int offset) throws Exception {
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(nlpEntityType, attributeNames, RESULTS);
    NlpEntityOperator nlpEntityOperator = new NlpEntityOperator(nlpEntityPredicate);
    nlpEntityOperator.setInputOperator(scanSource);
    nlpEntityOperator.setLimit(limit);
    nlpEntityOperator.setOffset(offset);
    Tuple nextTuple = null;
    List<Tuple> results = new ArrayList<Tuple>();
    nlpEntityOperator.open();
    while ((nextTuple = nlpEntityOperator.getNextTuple()) != null) {
        results.add(nextTuple);
    }
    nlpEntityOperator.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)

Example 8 with ScanBasedSourceOperator

use of edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class ProjectionOperatorTest method testProjection1.

@Test
public void testProjection1() throws Exception {
    List<String> projectionFields = Arrays.asList(TestConstants.DESCRIPTION);
    Schema projectionSchema = new Schema(TestConstants.DESCRIPTION_ATTR);
    IField[] fields1 = { new TextField("Tall Angry") };
    IField[] fields2 = { new TextField("Short Brown") };
    IField[] fields3 = { new TextField("White Angry") };
    IField[] fields4 = { new TextField("Lin Clooney is Short and lin clooney is Angry") };
    IField[] fields5 = { new TextField("Tall Fair") };
    IField[] fields6 = { new TextField("Short angry") };
    Tuple tuple1 = new Tuple(projectionSchema, fields1);
    Tuple tuple2 = new Tuple(projectionSchema, fields2);
    Tuple tuple3 = new Tuple(projectionSchema, fields3);
    Tuple tuple4 = new Tuple(projectionSchema, fields4);
    Tuple tuple5 = new Tuple(projectionSchema, fields5);
    Tuple tuple6 = new Tuple(projectionSchema, fields6);
    List<Tuple> expectedResults = Arrays.asList(tuple1, tuple2, tuple3, tuple4, tuple5, tuple6);
    List<Tuple> returnedResults = getProjectionResults(new ScanBasedSourceOperator(new ScanSourcePredicate(PEOPLE_TABLE)), projectionFields);
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Schema(edu.uci.ics.textdb.api.schema.Schema) TextField(edu.uci.ics.textdb.api.field.TextField) IField(edu.uci.ics.textdb.api.field.IField) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) ScanBasedSourceOperator(edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate) Test(org.junit.Test)

Example 9 with ScanBasedSourceOperator

use of edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator 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 10 with ScanBasedSourceOperator

use of edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator 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

ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)20 ScanSourcePredicate (edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate)20 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)17 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)6 IField (edu.uci.ics.textdb.api.field.IField)3 TextField (edu.uci.ics.textdb.api.field.TextField)3 Schema (edu.uci.ics.textdb.api.schema.Schema)3 IOperator (edu.uci.ics.textdb.api.dataflow.IOperator)2 DataFlowException (edu.uci.ics.textdb.api.exception.DataFlowException)2 RelationManager (edu.uci.ics.textdb.storage.RelationManager)2 ISourceOperator (edu.uci.ics.textdb.api.dataflow.ISourceOperator)1 TextDBException (edu.uci.ics.textdb.api.exception.TextDBException)1 StringField (edu.uci.ics.textdb.api.field.StringField)1 Attribute (edu.uci.ics.textdb.api.schema.Attribute)1 Span (edu.uci.ics.textdb.api.span.Span)1 DictionaryPredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate)1 FuzzyTokenPredicate (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenPredicate)1 KeywordMatcherSourceOperator (edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator)1 KeywordSourcePredicate (edu.uci.ics.textdb.exp.keywordmatcher.KeywordSourcePredicate)1