Search in sources :

Example 41 with TermWeightPosition

use of datawave.ingest.protobuf.TermWeightPosition in project datawave by NationalSecurityAgency.

the class ContentFunctionsTest method testEvaluationAdjacent2.

@Test
public void testEvaluationAdjacent2() {
    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, 6, 7);
    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));
}
Also used : Expression(org.apache.commons.jexl2.Expression) Zone(datawave.query.jexl.functions.TermFrequencyList.Zone) TermWeightPosition(datawave.ingest.protobuf.TermWeightPosition) Test(org.junit.Test)

Example 42 with TermWeightPosition

use of datawave.ingest.protobuf.TermWeightPosition in project datawave by NationalSecurityAgency.

the class ContentFunctionsTest method testEvaluationPhraseBasicWithSkips.

@Test
public void testEvaluationPhraseBasicWithSkips() {
    String query = buildFunction(ContentFunctions.CONTENT_PHRASE_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'dog'", "'cat'");
    Expression expr = engine.createExpression(query);
    List<TermWeightPosition> list1, list2;
    list1 = asList(Arrays.asList(1, 2, 3), Arrays.asList(0, 1, 0));
    list2 = asList(Arrays.asList(5, 6, 7), Arrays.asList(2, 2, 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));
}
Also used : Expression(org.apache.commons.jexl2.Expression) Zone(datawave.query.jexl.functions.TermFrequencyList.Zone) TermWeightPosition(datawave.ingest.protobuf.TermWeightPosition) Test(org.junit.Test)

Example 43 with TermWeightPosition

use of datawave.ingest.protobuf.TermWeightPosition in project datawave by NationalSecurityAgency.

the class ContentFunctionsTest method testEvaluationPhraseBasic3FavorContentOrderedFunction.

@Test
public void testEvaluationPhraseBasic3FavorContentOrderedFunction() {
    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(1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39);
    list2 = asList(2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40);
    list3 = asList(41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61);
    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, true));
}
Also used : Expression(org.apache.commons.jexl2.Expression) Zone(datawave.query.jexl.functions.TermFrequencyList.Zone) TermWeightPosition(datawave.ingest.protobuf.TermWeightPosition) Test(org.junit.Test)

Example 44 with TermWeightPosition

use of datawave.ingest.protobuf.TermWeightPosition in project datawave by NationalSecurityAgency.

the class ContentFunctionsTest method reverseAllSharedTokenIndex.

@Test
public void reverseAllSharedTokenIndex() {
    String query = buildFunction(ContentFunctions.CONTENT_PHRASE_FUNCTION_NAME, Constants.TERM_OFFSET_MAP_JEXL_VARIABLE_NAME, "'a'", "'b'", "'c'");
    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, 252, 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));
}
Also used : Expression(org.apache.commons.jexl2.Expression) Zone(datawave.query.jexl.functions.TermFrequencyList.Zone) TermWeightPosition(datawave.ingest.protobuf.TermWeightPosition) Test(org.junit.Test)

Example 45 with TermWeightPosition

use of datawave.ingest.protobuf.TermWeightPosition in project datawave by NationalSecurityAgency.

the class ContentFunctionsTest method testEvaluationPhraseBasicOrderFail3.

@Test
public void testEvaluationPhraseBasicOrderFail3() {
    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(2);
    list2 = asList(4);
    list3 = asList(3);
    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));
}
Also used : Expression(org.apache.commons.jexl2.Expression) Zone(datawave.query.jexl.functions.TermFrequencyList.Zone) TermWeightPosition(datawave.ingest.protobuf.TermWeightPosition) Test(org.junit.Test)

Aggregations

TermWeightPosition (datawave.ingest.protobuf.TermWeightPosition)69 Zone (datawave.query.jexl.functions.TermFrequencyList.Zone)67 Test (org.junit.Test)67 Expression (org.apache.commons.jexl2.Expression)66 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 TermFrequencyIterator (datawave.core.iterators.TermFrequencyIterator)1 TermWeight (datawave.ingest.protobuf.TermWeight)1 Content (datawave.query.attributes.Content)1 Document (datawave.query.attributes.Document)1 TermFrequencyList (datawave.query.jexl.functions.TermFrequencyList)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 NavigableSet (java.util.NavigableSet)1 Key (org.apache.accumulo.core.data.Key)1 Range (org.apache.accumulo.core.data.Range)1