use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class ExecutionContextTestCase method requireThatExplicitLanguagePreventsDetection.
@Test
public void requireThatExplicitLanguagePreventsDetection() {
ExecutionContext ctx = new ExecutionContext();
ctx.setLanguage(Language.ARABIC);
ctx.setValue(new StringFieldValue("\u3072\u3089\u304c\u306a"));
assertEquals(Language.ARABIC, ctx.resolveLanguage(new SimpleLinguistics()));
ctx.setValue(new StringFieldValue("\ud55c\uae00\uacfc"));
assertEquals(Language.ARABIC, ctx.resolveLanguage(new SimpleLinguistics()));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class FlattenTestCase method requireThatNonSpanAnnotationsAreIgnored.
@Test
public void requireThatNonSpanAnnotationsAreIgnored() {
SpanTree tree = new SpanTree(SpanTrees.LINGUISTICS);
tree.annotate(new Annotation(AnnotationTypes.TERM, new StringFieldValue("oof")));
StringFieldValue val = new StringFieldValue("foo");
val.setSpanTree(tree);
assertEquals(new StringFieldValue("foo"), new FlattenExpression().execute(val));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class FlattenTestCase method requireThatAnnotationsAreFlattened.
@Test
public void requireThatAnnotationsAreFlattened() {
SpanTree tree = new SpanTree(SpanTrees.LINGUISTICS);
tree.annotate(new Span(0, 3), new Annotation(AnnotationTypes.TERM, new StringFieldValue("oof")));
tree.annotate(new Span(4, 3), new Annotation(AnnotationTypes.TERM, new StringFieldValue("rab")));
tree.annotate(new Span(8, 3), new Annotation(AnnotationTypes.TERM, new StringFieldValue("zab")));
StringFieldValue val = new StringFieldValue("foo bar baz");
val.setSpanTree(tree);
assertEquals(new StringFieldValue("foo[oof] bar[rab] baz[zab]"), new FlattenExpression().execute(val));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class FlattenTestCase method requireThatAnnotationsAreSorted.
@Test
public void requireThatAnnotationsAreSorted() {
SpanTree tree = new SpanTree(SpanTrees.LINGUISTICS);
tree.annotate(new Span(0, 3), new Annotation(AnnotationTypes.TERM, new StringFieldValue("cox")));
tree.annotate(new Span(0, 3), new Annotation(AnnotationTypes.TERM, new StringFieldValue("baz")));
tree.annotate(new Span(0, 3), new Annotation(AnnotationTypes.TERM, new StringFieldValue("bar")));
StringFieldValue val = new StringFieldValue("foo");
val.setSpanTree(tree);
assertEquals(new StringFieldValue("foo[bar, baz, cox]"), new FlattenExpression().execute(val));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class GuardTestCase method requireThatInputFieldsAreIncludedByUpdate.
@Test
public void requireThatInputFieldsAreIncludedByUpdate() throws ParseException {
DocumentType docType = new DocumentType("my_input");
docType.addField(new Field("my_lng", DataType.LONG));
docType.addField(new Field("my_str", DataType.STRING));
DocumentUpdate docUpdate = new DocumentUpdate(docType, "doc:scheme:");
docUpdate.addFieldUpdate(FieldUpdate.createAssign(docType.getField("my_str"), new StringFieldValue("69")));
assertNotNull(docUpdate = Expression.execute(Expression.fromString("guard { input my_str | to_int | attribute my_lng }"), docUpdate));
assertEquals(0, docUpdate.getFieldPathUpdates().size());
assertEquals(1, docUpdate.getFieldUpdates().size());
FieldUpdate fieldUpd = docUpdate.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_lng"), fieldUpd.getField());
assertEquals(1, fieldUpd.getValueUpdates().size());
ValueUpdate valueUpd = fieldUpd.getValueUpdate(0);
assertNotNull(valueUpd);
assertTrue(valueUpd instanceof AssignValueUpdate);
assertEquals(new LongFieldValue(69), valueUpd.getValue());
}
Aggregations