use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationPhraseSameTermFailure.
@Test
public void testEvaluationPhraseSameTermFailure() {
String query = buildFunction(ContentFunctions.CONTENT_PHRASE_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'cat'", "'cat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1;
list1 = asList(1, 3, 5);
termOffSetMap.put("cat", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list1)));
context.set(Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, termOffSetMap);
Object o = expr.evaluate(context);
Assert.assertTrue(expect(o, false));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationPhraseBasicTermOrderFalsePositive.
/**
* This test case was originally testPhraseBasicTermOrderFail. This test case knowingly returns a false positive. We can't seem to differentiate term order
* at the same off, but we were missing some valid phraes. Maybe someone can come up with a way. For now, false negatives seemed worse than false positives.
*/
@Test
public void testEvaluationPhraseBasicTermOrderFalsePositive() {
String query = buildFunction(phraseFunction, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'cat'", "'dog'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2;
list1 = asList(1, 2, 3);
list2 = asList(3, 4, 5);
termOffSetMap.put("dog", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list1)));
termOffSetMap.put("cat", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list2)));
context.set(Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, termOffSetMap);
Object o = expr.evaluate(context);
Assert.assertTrue(expect(o, true));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationEmptyOffsetList.
@Test
public void testEvaluationEmptyOffsetList() {
String query = buildFunction(ContentFunctions.CONTENT_WITHIN_FUNCTION_NAME, "1", Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2;
list1 = asList(1, 2, 3);
list2 = new ArrayList<>();
termOffSetMap.put("dog", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list1)));
termOffSetMap.put("cat", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list2)));
context.set(Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, termOffSetMap);
Object o = expr.evaluate(context);
Assert.assertTrue(expect(o, false));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationThreeTermsTooSmallDistance.
@Test
public void testEvaluationThreeTermsTooSmallDistance() {
String query = buildFunction(ContentFunctions.CONTENT_WITHIN_FUNCTION_NAME, "2", Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'", "'rat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2, list3;
list1 = asList(1, 2, 3);
list2 = asList(3, 4, 5);
list3 = asList(10, 15, 20, 25);
termOffSetMap.put("dog", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list1)));
termOffSetMap.put("cat", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list2)));
termOffSetMap.put("rat", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list3)));
context.set(Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, termOffSetMap);
Object o = expr.evaluate(context);
Assert.assertTrue(expect(o, false));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationAdjacencySameTermSuccessTest.
@Test
public void testEvaluationAdjacencySameTermSuccessTest() {
String query = buildFunction(ContentFunctions.CONTENT_WITHIN_FUNCTION_NAME, "2", Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'cat'", "'cat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1;
list1 = asList(1, 3);
termOffSetMap.put("cat", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), list1)));
context.set(Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, termOffSetMap);
Object o = expr.evaluate(context);
Assert.assertTrue(expect(o, true));
}
Aggregations