private Item stem(BlockItem current, StemContext context, Index index) {
        var parameters = new LinguisticsParameters(context.language, index.getStemMode(), index.getNormalize(), index.isLowercase());
        Item blockAsItem = (Item)current;
        CompositeItem composite;
        List<StemList> segments = linguistics.getStemmer().stem(current.stringValue(), parameters);
        if (segments.isEmpty()) return blockAsItem;

        String indexName = current.getIndexName();
        Substring substring = getOffsets(current);
        if (segments.size() == 1) {
            TaggableItem w = singleWordSegment(current, segments.get(0), index, substring, context.insidePhrase);
            setMetaData(current, context.reverseConnectivity, w);
            return (Item)w;
        }

        if (context.isCJK)
            composite = chooseCompositeForCJK(current, ((Item) current).getParent(), indexName);
        else
            composite = chooseComposite(current, ((Item) current).getParent(), indexName);

        for (StemList segment : segments) {
            TaggableItem w = singleWordSegment(current, segment, index, substring, context.insidePhrase);

            if (composite instanceof AndSegmentItem) {
                setSignificanceAndDocumentFrequency(w, current);
            }
            composite.addItem((Item) w);
        }
        if (composite instanceof AndSegmentItem) {
            andSegmentConnectivity(current, context.reverseConnectivity, composite);
        }
        copyAttributes(blockAsItem, composite);
        composite.lock();

        if (composite instanceof PhraseSegmentItem replacement) {
            setSignificanceAndDocumentFrequency(replacement, current);
            phraseSegmentConnectivity(current, context.reverseConnectivity, replacement);
        }
        return composite;
    }
Replaces query terms with their stems

@author Mathias Lidal
@author bratseth
@author Steinar Knutsen
container-search/src/main/java/com/yahoo/prelude/querytransform/StemmingSearcher.java