Class FSTBuilder


  • public final class FSTBuilder
    extends Object
    Fast, memory-conservative finite state transducer builder, returning an in-memory FST that is a tradeoff between construction speed and memory consumption. Use serializers to compress the returned automaton into more compact form.
    See Also:
    FSTSerializer
    • Field Detail

      • LEXICAL_ORDERING

        public static final Comparator<byte[]> LEXICAL_ORDERING
        A comparator comparing full byte arrays. Unsigned byte comparisons ('C'-locale).
    • Constructor Detail

      • FSTBuilder

        public FSTBuilder()
      • FSTBuilder

        public FSTBuilder​(int bufferGrowthSize)
        Parameters:
        bufferGrowthSize - Buffer growth size (in bytes) when constructing the automaton.
    • Method Detail

      • build

        public static FST build​(byte[][] input,
                                int[] outputSymbols)
        Build a minimal, deterministic automaton from a sorted list of byte sequences.
        Parameters:
        input - Input sequences to build automaton from.
        Returns:
        Returns the automaton encoding all input sequences.
      • build

        public static FST build​(Iterable<byte[]> input,
                                int[] outputSymbols)
        Build a minimal, deterministic automaton from an iterable list of byte sequences.
        Parameters:
        input - Input sequences to build automaton from.
        Returns:
        Returns the automaton encoding all input sequences.
      • add

        public void add​(byte[] sequence,
                        int start,
                        int len,
                        int outputSymbol)
        Add a single sequence of bytes to the FST. The input must be lexicographically greater than any previously added sequence.
        Parameters:
        sequence - The array holding input sequence of bytes.
        start - Starting offset (inclusive)
        len - Length of the input sequence (at least 1 byte).
      • complete

        public FST complete()
        Returns:
        Finalizes the construction of the automaton and returns it.