use of edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate in project textdb by TextDB.
the class NlpExtractorPerformanceTest method matchNLP.
/*
* This function does match based on tokenType
*/
public static void matchNLP(String tableName, NlpEntityType tokenType) throws Exception {
List<String> attributeNames = Arrays.asList(MedlineIndexWriter.ABSTRACT);
ISourceOperator sourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(tokenType, attributeNames, SchemaConstants.SPAN_LIST);
NlpEntityOperator nlpEntityOperator = new NlpEntityOperator(nlpEntityPredicate);
nlpEntityOperator.setInputOperator(sourceOperator);
long startMatchTime = System.currentTimeMillis();
nlpEntityOperator.open();
Tuple nextTuple = null;
int counter = 0;
while ((nextTuple = nlpEntityOperator.getNextTuple()) != null) {
ListField<Span> spanListField = nextTuple.getField(SchemaConstants.SPAN_LIST);
List<Span> spanList = spanListField.getValue();
counter += spanList.size();
}
nlpEntityOperator.close();
long endMatchTime = System.currentTimeMillis();
double matchTime = (endMatchTime - startMatchTime) / 1000.0;
totalMatchingTime += matchTime;
totalResults += counter;
}
use of edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate 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;
}
use of edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate in project textdb by TextDB.
the class PredicateBaseTest method testScanSource.
@Test
public void testScanSource() throws Exception {
ScanSourcePredicate scanSourcePredicate = new ScanSourcePredicate("tableName");
testPredicate(scanSourcePredicate);
}
use of edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate 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 TexeraException {
RelationManager relationManager = RelationManager.getInstance();
ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
KeywordPredicate keywordPredicate = new KeywordPredicate(keywordQuery, attributeNames, relationManager.getTableAnalyzerString(tableName), matchingType, RESULTS);
KeywordMatcher keywordMatcher = new KeywordMatcher(keywordPredicate);
keywordMatcher.setLimit(limit);
keywordMatcher.setOffset(offset);
keywordMatcher.setInputOperator(scanSource);
Tuple tuple;
List<Tuple> results = new ArrayList<>();
keywordMatcher.open();
while ((tuple = keywordMatcher.getNextTuple()) != null) {
results.add(tuple);
}
keywordMatcher.close();
return results;
}
use of edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate 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;
}
Aggregations