use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method forwardSharedTokenIndex.
@Test
public void forwardSharedTokenIndex() {
String query = buildFunction(ContentFunctions.CONTENT_PHRASE_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'c'", "'b'", "'a'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> t1, t2, t3;
t1 = asList(Arrays.asList(234, 239, 252, 257, 265, 281, 286, 340, 363, 367), Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
t2 = asList(Arrays.asList(212, 229, 252, 272), Arrays.asList(0, 0, 0, 0));
t3 = asList(Arrays.asList(1, 101, 202, 213, 251, 312, 336), Arrays.asList(0, 0, 0, 0, 0, 0, 0));
termOffSetMap.put("a", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), t1)));
termOffSetMap.put("b", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), t2)));
termOffSetMap.put("c", new TermFrequencyList(Maps.immutableEntry(new Zone("CONTENT", true, eventId), t3)));
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 testEvaluationPhraseThreeTerm.
@Test
public void testEvaluationPhraseThreeTerm() {
String query = buildFunction(phraseFunction, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'", "'rat'");
Expression expr = engine.createExpression(query);
List<TermWeightPosition> list1, list2, list3;
list1 = asList(1, 2, 4);
list2 = asList(5, 7, 9);
list3 = asList(6, 8, 10);
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, true));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationAdjacencySameTermWithSkipsSuccessTest.
@Test
public void testEvaluationAdjacencySameTermWithSkipsSuccessTest() {
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(Arrays.asList(1, 4), Arrays.asList(0, 1));
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));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationReverseOffsetAdjustment.
/**
* This tests the adjustment mechanism in the ContentOrderedEvaluator within the TraverseAndPrune method.
*/
@Test
public void testEvaluationReverseOffsetAdjustment() {
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(5, 9, 10, 25, 27, 29);
list2 = asList(3, 9, 10, 12, 13, 20, 23, 25);
list3 = asList(1, 12, 13, 27);
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, false));
}
use of org.hl7.elm.r1.Expression in project datawave by NationalSecurityAgency.
the class ContentFunctionsTest method testEvaluationAdjacent3.
@Test
public void testEvaluationAdjacent3() {
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, 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));
}
Aggregations