Package morfologik.fsa.builders
Class CFSA2Serializer
- java.lang.Object
-
- morfologik.fsa.builders.CFSA2Serializer
-
- All Implemented Interfaces:
FSASerializer
public final class CFSA2Serializer extends Object implements FSASerializer
Serializes in-memoryFSA
graphs toCFSA2
.It is possible to serialize the automaton with numbers required for perfect hashing. See
withNumbers()
method.- See Also:
CFSA2
-
-
Constructor Summary
Constructors Constructor Description CFSA2Serializer()
-
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)
CFSA2Serializer
withAnnotationSeparator(byte annotationSeparator)
Sets the annotation separator (only ifFSASerializer.getFlags()
returnsFSAFlags.SEPARATORS
).CFSA2Serializer
withFiller(byte filler)
Sets the filler separator (only ifFSASerializer.getFlags()
returnsFSAFlags.SEPARATORS
).CFSA2Serializer
withNumbers()
Serialize the automaton with the number of right-language sequences in each node.
-
-
-
Method Detail
-
withNumbers
public CFSA2Serializer 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.
-
serialize
public <T extends OutputStream> T serialize(FSA fsa, T os) throws IOException
- 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).
-
withFiller
public CFSA2Serializer withFiller(byte filler)
Description copied from interface:FSASerializer
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 CFSA2Serializer withAnnotationSeparator(byte annotationSeparator)
Description copied from interface:FSASerializer
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.
-
-