Class FSAUtils


  • public final class FSAUtils
    extends java.lang.Object
    Other FSA-related utilities not directly associated with the class hierarchy.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FSAUtils.IntIntHolder  
    • Constructor Summary

      Constructors 
      Constructor Description
      FSAUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.TreeMap<java.lang.Integer,​java.lang.Integer> calculateFanOuts​(FSA fsa, int root)
      Calculate fan-out ratio (how many nodes have a given number of outgoing arcs).
      static com.carrotsearch.hppc.IntIntHashMap rightLanguageForAllStates​(FSA fsa)
      Calculate the size of "right language" for each state in an FSA.
      static void toDot​(java.io.Writer w, FSA fsa, int node)
      Saves the right-language reachable from a given FSA node, formatted as an input for the graphviz package (expressed in the dot language), to the given writer.
      static java.lang.String toDot​(FSA fsa, int node)
      Returns the right-language reachable from a given FSA node, formatted as an input for the graphviz package (expressed in the dot language).
      private static void visitNode​(java.io.Writer w, int d, FSA fsa, int s, java.util.BitSet visited)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FSAUtils

        public FSAUtils()
    • Method Detail

      • toDot

        public static java.lang.String toDot​(FSA fsa,
                                             int node)
        Returns the right-language reachable from a given FSA node, formatted as an input for the graphviz package (expressed in the dot language).
        Parameters:
        fsa - The automaton to visualize.
        node - Starting node (subgraph will be visualized unless it's the automaton's root node).
        Returns:
        Returns the dot language description of the automaton.
      • toDot

        public static void toDot​(java.io.Writer w,
                                 FSA fsa,
                                 int node)
                          throws java.io.IOException
        Saves the right-language reachable from a given FSA node, formatted as an input for the graphviz package (expressed in the dot language), to the given writer.
        Parameters:
        w - The writer to write dot language description of the automaton.
        fsa - The automaton to visualize.
        node - Starting node (subgraph will be visualized unless it's the automaton's root node).
        Throws:
        java.io.IOException - Rethrown if an I/O exception occurs.
      • visitNode

        private static void visitNode​(java.io.Writer w,
                                      int d,
                                      FSA fsa,
                                      int s,
                                      java.util.BitSet visited)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • calculateFanOuts

        public static java.util.TreeMap<java.lang.Integer,​java.lang.Integer> calculateFanOuts​(FSA fsa,
                                                                                                    int root)
        Calculate fan-out ratio (how many nodes have a given number of outgoing arcs).
        Parameters:
        fsa - The automaton to calculate fanout for.
        root - The starting node for calculations.
        Returns:
        The returned map contains keys for the number of outgoing arcs and an associated value being the number of nodes with that arc number.
      • rightLanguageForAllStates

        public static com.carrotsearch.hppc.IntIntHashMap rightLanguageForAllStates​(FSA fsa)
        Calculate the size of "right language" for each state in an FSA. The right language is the number of sequences encoded from a given node in the automaton.
        Parameters:
        fsa - The automaton to calculate right language for.
        Returns:
        Returns a map with node identifiers as keys and their right language counts as associated values.