use of edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate in project textdb by TextDB.
the class PredicateBaseTest method testKeyword.
@Test
public void testKeyword() throws Exception {
KeywordPredicate keywordPredicate = new KeywordPredicate("keyword", attributeNames, "standard", KeywordMatchingType.CONJUNCTION_INDEXBASED, "keywordResults");
testPredicate(keywordPredicate);
KeywordSourcePredicate keywordSourcePredicate = new KeywordSourcePredicate("keyword", attributeNames, "standard", KeywordMatchingType.CONJUNCTION_INDEXBASED, "tableName", "keywordSourceResults");
testPredicate(keywordSourcePredicate);
}
use of edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate in project textdb by TextDB.
the class KeywordExtractPredicateTest method testGeneratePredicateBase01.
/**
* Test the generatePredicateBase method.
* Build a KeywordExtractPredicate, invoke the generatePredicateBase and
* check whether a KeywordMatcherBean with the right attributes is returned.
* A list with one field is used as the list of fields to perform the match.
*/
@Test
public void testGeneratePredicateBase01() {
String operatorId = "operator";
List<String> matchingFields = Arrays.asList("fieldOne");
String keywords = "keyword(s)";
String matchingType = KeywordMatchingType.PHRASE_INDEXBASED.toString();
KeywordExtractPredicate keywordExtractPredicate = new KeywordExtractPredicate(matchingFields, keywords, matchingType);
PredicateBase computedProjectionBean = keywordExtractPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new KeywordPredicate(keywords, matchingFields, null, KeywordMatchingType.fromName(matchingType), operatorId);
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
use of edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate in project textdb by TextDB.
the class KeywordExtractPredicate method generateOperatorBean.
/**
* Return this operator converted to a { @code KeywordMatcherBean }.
* @param extractionOperatorId The ID of the OperatorBean to be created.
* @return this operator converted to a KeywordMatcherBean.
*/
@Override
public KeywordPredicate generateOperatorBean(String extractionOperatorId) {
KeywordPredicate keywordPredicate = new KeywordPredicate(this.keywords, this.matchingFields, null, KeywordMatchingType.fromName(this.matchingType), extractionOperatorId);
keywordPredicate.setID(extractionOperatorId);
return keywordPredicate;
}
use of edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder03.
/**
* Test the correctness of the generated beans by a SelectStatement with a
* KeywordExtractPredicate.
* Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
* methods and check if the generated path form the node getInputNodeID() to
* the node getOutputNodeID() is correct. Also check whether getInputViews()
* is returning the correct dependencies.
*/
@Test
public void testSelectStatementBeansBuilder03() {
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("c", "d"), "word", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
SelectStatement selectStatement = new SelectStatement("id", null, extractPredicate, "TableP9", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("word", Arrays.asList("c", "d"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "id_e"));
List<String> dependencies = Arrays.asList("TableP9");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder05.
/**
* Test the correctness of the generated beans by a SelectStatement with a
* ProjectAllFieldsPredicate and a KeywordExtractPredicate.
* Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
* methods and check if the generated path form the node getInputNodeID() to
* the node getOutputNodeID() is correct. Also check whether getInputViews()
* is returning the correct dependencies.
*/
@Test
public void testSelectStatementBeansBuilder05() {
ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b"));
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "x", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
SelectStatement selectStatement = new SelectStatement("_sid4", projectPredicate, extractPredicate, "from", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("x", Arrays.asList("a", "b"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "_sid4_e"), new ProjectionPredicate(Arrays.asList("a", "b")));
List<String> dependencies = Arrays.asList("from");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
Aggregations