use of edu.uci.ics.textdb.exp.wordcount.WordCountOperatorPredicate in project textdb by TextDB.
the class WordCountTest method computePayLoadWordCount.
//Compute result by tuple's PayLoad.
public static HashMap<String, Integer> computePayLoadWordCount(String tableName, String attribute) throws TextDBException {
ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
WordCountOperator wordCount = null;
HashMap<String, Integer> result = new HashMap<String, Integer>();
if (tableName.equals(COUNT_TABLE)) {
wordCount = new WordCountOperator(new WordCountOperatorPredicate(TestConstants.DESCRIPTION, LuceneAnalyzerConstants.standardAnalyzerString()));
} else if (tableName.equals(COUNT_CHINESE_TABLE)) {
wordCount = new WordCountOperator(new WordCountOperatorPredicate(TestConstantsChineseWordCount.DESCRIPTION, LuceneAnalyzerConstants.chineseAnalyzerString()));
}
wordCount.setInputOperator(scanSource);
wordCount.open();
Tuple tuple;
while ((tuple = wordCount.getNextTuple()) != null) {
result.put((String) tuple.getField(WordCountOperator.WORD).getValue(), (Integer) tuple.getField(WordCountOperator.COUNT).getValue());
}
wordCount.close();
return result;
}
use of edu.uci.ics.textdb.exp.wordcount.WordCountOperatorPredicate in project textdb by TextDB.
the class PredicateBaseTest method testWordCountOperator.
@Test
public void testWordCountOperator() throws Exception {
WordCountOperatorPredicate wordCountPredicate = new WordCountOperatorPredicate("attr1", "standard");
testPredicate(wordCountPredicate);
}
Aggregations