Class FSA5Serializer

java.lang.Object
morfologik.fsa.builders.FSA5Serializer
All Implemented Interfaces:
FSASerializer

public final class FSA5Serializer extends Object implements FSASerializer
Serializes in-memory FSA graphs to a binary format compatible with Jan Daciuk's fsa's package FSA5 format.

It is possible to serialize the automaton with numbers required for perfect hashing. See withNumbers() method.

See Also:
  • Field Details

  • Constructor Details

    • FSA5Serializer

      public FSA5Serializer()
  • Method Details

    • 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 interface FSASerializer
      Returns:
      Returns the same object for easier call chaining.
    • withFiller

      public FSA5Serializer withFiller(byte filler)
      Sets the filler separator (only if FSASerializer.getFlags() returns FSAFlags.SEPARATORS).
      Specified by:
      withFiller in interface FSASerializer
      Parameters:
      filler - The filler separator byte.
      Returns:
      Returns this for call chaining.
    • withAnnotationSeparator

      public FSA5Serializer withAnnotationSeparator(byte annotationSeparator)
      Sets the annotation separator (only if FSASerializer.getFlags() returns FSAFlags.SEPARATORS).
      Specified by:
      withAnnotationSeparator in interface FSASerializer
      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 state s to an output stream in FSA5 format.
      Specified by:
      serialize in interface FSASerializer
      Type Parameters:
      T - A subclass of OutputStream, 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:
    • getFlags

      public Set<FSAFlags> getFlags()
      Return supported flags.
      Specified by:
      getFlags in interface FSASerializer
      Returns:
      Returns the set of flags supported by the serializer (and the output automaton).