use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class Rot13DocumentProcessor method process.
@Override
public Progress process(Processing processing) {
int oldVal = counter.getAndIncrement();
if ((oldVal % 3) != 0) {
return Progress.LATER;
}
for (DocumentOperation op : processing.getDocumentOperations()) {
if (op instanceof DocumentPut) {
Document document = ((DocumentPut) op).getDocument();
StringFieldValue oldTitle = (StringFieldValue) document.getFieldValue(FIELD_NAME);
if (oldTitle != null) {
document.setFieldValue(FIELD_NAME, rot13(oldTitle.getString()));
}
}
}
return Progress.DONE;
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class LinguisticsAnnotatorTestCase method requireThatCompositeTokensAreFlattened.
@Test
public void requireThatCompositeTokensAreFlattened() {
SpanTree expected = new SpanTree(SpanTrees.LINGUISTICS);
expected.spanList().span(0, 3).annotate(new Annotation(AnnotationTypes.TERM, new StringFieldValue("foo")));
expected.spanList().span(3, 3).annotate(new Annotation(AnnotationTypes.TERM, new StringFieldValue("bar")));
expected.spanList().span(6, 3).annotate(new Annotation(AnnotationTypes.TERM, new StringFieldValue("baz")));
SimpleToken token = newToken("FOOBARBAZ", "foobarbaz", TokenType.ALPHABETIC).addComponent(newToken("FOO", "foo", TokenType.ALPHABETIC).setOffset(0)).addComponent(newToken("BARBAZ", "barbaz", TokenType.ALPHABETIC).setOffset(3).addComponent(newToken("BAR", "bar", TokenType.ALPHABETIC).setOffset(3)).addComponent(newToken("BAZ", "baz", TokenType.ALPHABETIC).setOffset(6)));
assertAnnotations(expected, "foobarbaz", token);
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class LinguisticsAnnotatorTestCase method requireThatExistingAnnotationsAreKept.
@Test
public void requireThatExistingAnnotationsAreKept() {
SpanTree spanTree = new SpanTree(SpanTrees.LINGUISTICS);
spanTree.spanList().span(0, 3).annotate(new Annotation(AnnotationTypes.TERM, new StringFieldValue("baz")));
StringFieldValue val = new StringFieldValue("foo");
val.setSpanTree(spanTree);
Linguistics linguistics = newLinguistics(Arrays.asList(newToken("foo", "bar", TokenType.ALPHABETIC, false)), Collections.<String, String>emptyMap());
new LinguisticsAnnotator(linguistics, CONFIG).annotate(val);
assertTrue(new LinguisticsAnnotator(linguistics, CONFIG).annotate(val));
assertEquals(spanTree, val.getSpanTree(SpanTrees.LINGUISTICS));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class LinguisticsAnnotatorTestCase method assertAnnotations.
private static void assertAnnotations(SpanTree expected, String str, Linguistics linguistics) {
StringFieldValue val = new StringFieldValue(str);
assertEquals(expected != null, new LinguisticsAnnotator(linguistics, CONFIG).annotate(val));
assertEquals(expected, val.getSpanTree(SpanTrees.LINGUISTICS));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class LinguisticsAnnotatorTestCase method requireThatCompositeSpecialTokensAreNotFlattened.
@Test
public void requireThatCompositeSpecialTokensAreNotFlattened() {
SpanTree expected = new SpanTree(SpanTrees.LINGUISTICS);
expected.spanList().span(0, 9).annotate(new Annotation(AnnotationTypes.TERM, new StringFieldValue("foobarbaz")));
SimpleToken token = newToken("FOOBARBAZ", "foobarbaz", TokenType.ALPHABETIC).setSpecialToken(true).addComponent(newToken("FOO", "foo", TokenType.ALPHABETIC).setOffset(0)).addComponent(newToken("BARBAZ", "barbaz", TokenType.ALPHABETIC).setOffset(3).addComponent(newToken("BAR", "bar", TokenType.ALPHABETIC).setOffset(3)).addComponent(newToken("BAZ", "baz", TokenType.ALPHABETIC).setOffset(6)));
assertAnnotations(expected, "foobarbaz", token);
}
Aggregations