@Override protected void doExecute(ExecutionContext context) { StringFieldValue input = (StringFieldValue)context.getValue(); StringFieldValue output = input.clone(); context.setValue(output); AnnotatorConfig cfg = new AnnotatorConfig(config); Language lang = context.resolveLanguage(linguistics); if (lang != null) { cfg.setLanguage(lang); } LinguisticsAnnotator annotator = new LinguisticsAnnotator(linguistics, cfg); annotator.annotate(output); }
@Override protected void doExecute(ExecutionContext ctx) { StringFieldValue input = (StringFieldValue)ctx.getValue(); if (input.getString().isEmpty()) { return; } StringFieldValue output = input.clone(); ctx.setValue(output); String prev = output.getString(); String next = toLowerCase(prev); SpanList root = new SpanList(); SpanTree tree = new SpanTree(SpanTrees.LINGUISTICS, root); SpanNode node = new Span(0, prev.length()); tree.annotate(node, new Annotation(AnnotationTypes.TERM, next.equals(prev) ? null : new StringFieldValue(next))); tree.annotate(node, new Annotation(AnnotationTypes.TOKEN_TYPE, new IntegerFieldValue(TokenType.ALPHABETIC.getValue()))); root.add(node); output.setSpanTree(tree); }