use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationPhraseBasicFail3WithSkips.
@Test
public void testEvaluationPhraseBasicFail3WithSkips() {
String query = buildFunction(ContentFunctions.CONTENT_PHRASE_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'", "'fish'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2, list3;
list1 = asList(Arrays.asList(2), Arrays.asList(0));
list2 = asList(Arrays.asList(4), Arrays.asList(0));
list3 = asList(Arrays.asList(3), Arrays.asList(0));
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("fish", 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 testEvaluation3.
@Test
public void testEvaluation3() {
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 = asList(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, false));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationAdjacent1.
@Test
public void testEvaluationAdjacent1() {
String query = buildFunction(ContentFunctions.CONTENT_ADJACENT_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2;
list1 = asList(1);
list2 = asList(2);
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 testEvaluationPhraseBasicOrderFail2.
@Test
public void testEvaluationPhraseBasicOrderFail2() {
String query = buildFunction(ContentFunctions.CONTENT_PHRASE_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'", "'fish'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2, list3;
list1 = asList(4);
list2 = asList(3);
list3 = asList(2);
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("fish", 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 testEvaluationPhrasePruningEdgeCondition.
/**
* This tests the adjustment mechanism in the ContentOrderedEvaluator within the TraverseAndPrune method.
*/
@Test
public void testEvaluationPhrasePruningEdgeCondition() {
String query = buildFunction(phraseFunction, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'", "'bat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2, list3;
list1 = asList(9, 10);
list2 = asList(9, 10, 11);
list3 = asList(7, 12);
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("bat", 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, true));
}
Aggregations