@Override
    protected void doExecute(ExecutionContext context) {
        StringFieldValue input = (StringFieldValue) context.getCurrentValue();
        if (input.getSpanTree(SpanTrees.LINGUISTICS) != null) {
            // This expression is already executed for this input instance
            return;
        }
        StringFieldValue output = input.clone();
        context.setCurrentValue(output);

        SpanList spanList = output.setSpanTree(new SpanTree(SpanTrees.LINGUISTICS)).spanList();
        int lastPosition = 0;
        for (Iterator<GramSplitter.Gram> it = linguistics.getGramSplitter().split(output.getString(), gramSize); it.hasNext();) {
            GramSplitter.Gram gram = it.next();
            // if there is a gap before this gram, then annotate the gram as punctuation
            // (technically it may be of various types, but it does not matter - we just
            // need to annotate it somehow (as a non-term) to make sure it is added to the summary)
            if (lastPosition < gram.getStart()) {
                typedSpan(lastPosition, gram.getStart() - lastPosition, TokenType.PUNCTUATION, spanList);
            }

            // annotate gram as a word term
            String gramString = gram.extractFrom(output.getString());
            typedSpan(gram.getStart(),
                      gram.getCodePointCount(),
                      TokenType.ALPHABETIC, spanList).annotate(LinguisticsAnnotator.termAnnotation(toLowerCase(gramString), gramString));

            lastPosition = gram.getStart() + gram.getCodePointCount();
        }
        // handle punctuation at the end
        if (lastPosition < output.toString().length()) {
            typedSpan(lastPosition, output.toString().length() - lastPosition, TokenType.PUNCTUATION, spanList);
        }
    }
Creates an executable ngram expression

@param linguistics the gram splitter to use, or null if this is used for representation and will not be executed
@param gramSize the gram size
indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/NGramExpression.java