Package morfologik.fsa.builders
Class FSABuilder
- java.lang.Object
-
- morfologik.fsa.builders.FSABuilder
-
public final class FSABuilder extends Object
Fast, memory-conservative finite state automaton builder, returning an in-memoryFSA
that is a tradeoff between construction speed and memory consumption. Use serializers to compress the returned automaton into more compact form.- See Also:
FSASerializer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FSABuilder.InfoEntry
Debug and information constants.
-
Field Summary
Fields Modifier and Type Field Description static Comparator<byte[]>
LEXICAL_ORDERING
A comparator comparing full byte arrays.
-
Constructor Summary
Constructors Constructor Description FSABuilder()
FSABuilder(int bufferGrowthSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(byte[] sequence, int start, int len)
Add a single sequence of bytes to the FSA.static FSA
build(byte[][] input)
Build a minimal, deterministic automaton from a sorted list of byte sequences.static FSA
build(Iterable<byte[]> input)
Build a minimal, deterministic automaton from an iterable list of byte sequences.FSA
complete()
Map<FSABuilder.InfoEntry,Object>
getInfo()
-
-
-
Field Detail
-
LEXICAL_ORDERING
public static final Comparator<byte[]> LEXICAL_ORDERING
A comparator comparing full byte arrays. Unsigned byte comparisons ('C'-locale).
-
-
Method Detail
-
add
public void add(byte[] sequence, int start, int len)
Add a single sequence of bytes to the FSA. 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 FSA complete()
- Returns:
- Finalizes the construction of the automaton and returns it.
-
build
public static FSA build(byte[][] input)
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 FSA build(Iterable<byte[]> input)
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.
-
getInfo
public Map<FSABuilder.InfoEntry,Object> getInfo()
- Returns:
- Returns various statistics concerning the FSA and its compilation.
- See Also:
FSABuilder.InfoEntry
-
-