Beispiel #1
0
        public virtual Collection getNbest(int n)
        {
            HashSet hashSet = new HashSet();
            BoundedPriorityQueue boundedPriorityQueue = new BoundedPriorityQueue(n);

            boundedPriorityQueue.add(new Nbest.NBestPath(this, "<s>", this.lattice.getInitialNode(), (double)0f, (double)0f));
            while (hashSet.size() < n && boundedPriorityQueue.size() > 0)
            {
                Nbest.NBestPath nbestPath = (Nbest.NBestPath)boundedPriorityQueue.poll();
                if (nbestPath.node.equals(this.lattice.terminalNode))
                {
                    hashSet.add(nbestPath.path);
                }
                else
                {
                    Iterator iterator = nbestPath.node.getLeavingEdges().iterator();
                    while (iterator.hasNext())
                    {
                        Edge            edge          = (Edge)iterator.next();
                        Node            toNode        = edge.getToNode();
                        double          num           = nbestPath.forwardScore + edge.getAcousticScore() + edge.getLMScore();
                        double          num2          = num + toNode.getBackwardScore();
                        string          newPathString = this.getNewPathString(nbestPath, toNode);
                        Nbest.NBestPath item          = new Nbest.NBestPath(this, newPathString, toNode, num2, num);
                        boundedPriorityQueue.add(item);
                    }
                }
            }
            return(hashSet);
        }
Beispiel #2
0
        private void printQueue(BoundedPriorityQueue boundedPriorityQueue)
        {
            [email protected]();
            Iterator iterator = boundedPriorityQueue.iterator();

            while (iterator.hasNext())
            {
                Nbest.NBestPath nbestPath = (Nbest.NBestPath)iterator.next();
                [email protected](nbestPath);
            }
        }