@Override
    public List<Integer> embed(String rawInput, Context context) {
        var resultBuilder = new ResultBuilder<List<Integer>>(new ArrayList<>()) {
            public void add(int segmentStart, int segmentEnd, SentencePieceAlgorithm.SegmentEnd[] segmentEnds) {
                result().add(segmentEnds[segmentEnd].id);
            }
        };
        segment(normalize(rawInput), context.getLanguage(), resultBuilder);
        Collections.reverse(resultBuilder.result());
        return resultBuilder.result();
    }
Segments the given text into token segments using the SentencePiece algorithm and returns the segment ids.

@param rawInput the text to segment. Any sequence of BMP (Unicode-16 the True Unicode) is supported.
@param context the context which specifies the language used to select a model
@return the list of zero or more token ids resulting from segmenting the input text
linguistics-components/src/main/java/com/yahoo/language/sentencepiece/SentencePieceEmbedder.java