Package morfologik.fsa.builders
Class FSA5Serializer
- java.lang.Object
-
- morfologik.fsa.builders.FSA5Serializer
-
- All Implemented Interfaces:
FSASerializer
public final class FSA5Serializer extends Object implements FSASerializer
Serializes in-memoryFSA
graphs to a binary format compatible with Jan Daciuk'sfsa
's packageFSA5
format.It is possible to serialize the automaton with numbers required for perfect hashing. See
withNumbers()
method.- See Also:
FSA5
,FSA.read(java.io.InputStream)
-
-
Field Summary
Fields Modifier and Type Field Description byte
annotationByte
byte
fillerByte
-
Constructor Summary
Constructors Constructor Description FSA5Serializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<FSAFlags>
getFlags()
Return supported flags.<T extends OutputStream>
Tserialize(FSA fsa, T os)
Serialize root states
to an output stream inFSA5
format.FSA5Serializer
withAnnotationSeparator(byte annotationSeparator)
Sets the annotation separator (only ifFSASerializer.getFlags()
returnsFSAFlags.SEPARATORS
).FSA5Serializer
withFiller(byte filler)
Sets the filler separator (only ifFSASerializer.getFlags()
returnsFSAFlags.SEPARATORS
).FSA5Serializer
withNumbers()
Serialize the automaton with the number of right-language sequences in each node.
-
-
-
Field Detail
-
fillerByte
public byte fillerByte
- See Also:
FSA5.filler
-
annotationByte
public byte annotationByte
- See Also:
FSA5.annotation
-
-
Method Detail
-
withNumbers
public FSA5Serializer withNumbers()
Serialize the automaton with the number of right-language sequences in each node. This is required to implement perfect hashing. The numbering also preserves the order of input sequences.- Specified by:
withNumbers
in interfaceFSASerializer
- Returns:
- Returns the same object for easier call chaining.
-
withFiller
public FSA5Serializer withFiller(byte filler)
Sets the filler separator (only ifFSASerializer.getFlags()
returnsFSAFlags.SEPARATORS
).- Specified by:
withFiller
in interfaceFSASerializer
- Parameters:
filler
- The filler separator byte.- Returns:
- Returns
this
for call chaining.
-
withAnnotationSeparator
public FSA5Serializer withAnnotationSeparator(byte annotationSeparator)
Sets the annotation separator (only ifFSASerializer.getFlags()
returnsFSAFlags.SEPARATORS
).- Specified by:
withAnnotationSeparator
in interfaceFSASerializer
- Parameters:
annotationSeparator
- The filler separator byte.- Returns:
- Returns
this
for call chaining.
-
serialize
public <T extends OutputStream> T serialize(FSA fsa, T os) throws IOException
Serialize root states
to an output stream inFSA5
format.- Specified by:
serialize
in interfaceFSASerializer
- Type Parameters:
T
- A subclass ofOutputStream
, returned for chaining.- Parameters:
fsa
- The automaton to serialize.os
- The output stream to serialize to.- Returns:
- Returns
os
for chaining. - Throws:
IOException
- Rethrown if an I/O error occurs.- See Also:
withNumbers()
-
getFlags
public Set<FSAFlags> getFlags()
Return supported flags.- Specified by:
getFlags
in interfaceFSASerializer
- Returns:
- Returns the set of flags supported by the serializer (and the output automaton).
-
-