Exemplo n.º 1
0
        /**
         * /// Internal routine used when loading Lattices from .LAT files
         *
         * /// @param lattice
         * /// @param tokens
         */
        public static void load(Lattice lattice, StringTokenizer tokens)
        {
            String id    = tokens.nextToken();
            String label = tokens.nextToken();

            lattice.addNode(id, label, 0, 0);
        }
Exemplo n.º 2
0
        /**
         * /// Self test for LatticeOptimizer
         *
         * /// @param args
         */
        public static void main(String[] args)
        {
            Lattice lattice = new Lattice(args[0]);

            LatticeOptimizer optimizer = new LatticeOptimizer(lattice);

            optimizer.optimize();

            lattice.dump(args[1]);
        }
Exemplo n.º 3
0
        /**
         * /// Internal routine used when creating a Lattice from a .LAT file
         *
         * /// @param lattice
         * /// @param tokens
         */
        public static void load(Lattice lattice, StringTokenizer tokens)
        {
            String from  = tokens.nextToken();
            String to    = tokens.nextToken();
            int    score = int.Parse(tokens.nextToken());

            Node fromNode = lattice.getNode(from);

            if (fromNode == null)
            {
                throw new Exception("Edge fromNode \"" + from + "\" does not exist");
            }

            Node toNode = lattice.getNode(to);

            if (toNode == null)
            {
                throw new Exception("Edge toNode \"" + to + "\" does not exist");
            }

            lattice.addEdge(fromNode, toNode, score, 0.0);
        }
Exemplo n.º 4
0
 public Nbest(Lattice lattice)
 {
     this.lattice = lattice;
 }
Exemplo n.º 5
0
 /**
  * /// Create a new Lattice optimizer
  *
  * /// @param lattice
  */
 public LatticeOptimizer(Lattice lattice)
 {
     this.lattice = lattice;
 }
Exemplo n.º 6
0
 /**
  * /// Returns true if the given Lattice is equivalent to this Lattice. Two lattices are equivalent if all their nodes
  * /// and edges are equivalent.
  *
  * /// @param other the Lattice to compare this Lattice against
  * /// @return true if the Lattices are equivalent; false otherwise
  */
 public Boolean isEquivalent(Lattice other)
 {
     return(checkNodesEquivalent(initialNode, other.getInitialNode()));
 }