Esempio n. 1
0
        public virtual bool validate()
        {
            int num = 1;

            this.startNodeIterator();
            while (this.hasMoreNodes())
            {
                Node node = this.nextNode();
                num &= (node.validate() ? 1 : 0);
                int num2 = node.incomingEdgesSize();
                int num3 = node.outgoingEdgesSize();
                if (num2 < 1 && !this.isInitialNode(node))
                {
                    [email protected](new StringBuilder().append("No incoming edge: ").append(node).toString());
                    num = 0;
                }
                node.startIncomingEdgeIterator();
                while (node.hasMoreIncomingEdges())
                {
                    num &= (this.edges.contains(node.nextIncomingEdge()) ? 1 : 0);
                }
                if (num3 < 1 && !this.isFinalNode(node))
                {
                    [email protected](new StringBuilder().append("No outgoing edge: ").append(node).toString());
                    num = 0;
                }
                node.startOutgoingEdgeIterator();
                while (node.hasMoreOutgoingEdges())
                {
                    num &= (this.edges.contains(node.nextOutgoingEdge()) ? 1 : 0);
                }
            }
            this.startEdgeIterator();
            while (this.hasMoreEdges())
            {
                Edge edge = this.nextEdge();
                num &= (edge.validate() ? 1 : 0);
                num &= (this.nodes.contains(edge.getSource()) ? 1 : 0);
                num &= (this.nodes.contains(edge.getDestination()) ? 1 : 0);
            }
            return(num != 0);
        }
Esempio n. 2
0
        private TrainerScore[][] prepareScore()
        {
            ArrayList arrayList = new ArrayList();
            int       num       = this.graph.size();

            TrainerScore[] array = new TrainerScore[num];
            this.betas            = new float[num];
            this.outputProbs      = new float[num];
            this.probCurrentFrame = new float[num];
            Node initialNode = this.graph.getInitialNode();
            int  num2        = this.graph.indexOf(initialNode);

            for (int i = 0; i < num; i++)
            {
                this.probCurrentFrame[i] = float.MinValue;
            }
            this.probCurrentFrame[num2] = 0f;
            initialNode.startOutgoingEdgeIterator();
            while (initialNode.hasMoreOutgoingEdges())
            {
                Edge edge        = initialNode.nextOutgoingEdge();
                Node destination = edge.getDestination();
                int  num3        = this.graph.indexOf(destination);
                if (!destination.isType("STATE"))
                {
                    this.probCurrentFrame[num3] = 0f;
                }
                else
                {
                    HMMState hmmstate = (HMMState)destination.getObject();
                    if (!hmmstate.isEmitting())
                    {
                        this.probCurrentFrame[num3] = 0f;
                    }
                    if (!BaumWelchLearner.assertionsDisabled)
                    {
                        throw new AssertionError();
                    }
                }
            }
            this.lastFeatureIndex = 0;
            while (this.getFeature())
            {
                this.forwardPass(array);
                arrayList.add(array);
                this.lastFeatureIndex++;
            }
            BaumWelchLearner.logger.info(new StringBuilder().append("Feature frames read: ").append(this.lastFeatureIndex).toString());
            for (int i = 0; i < this.probCurrentFrame.Length; i++)
            {
                this.probCurrentFrame[i] = float.MinValue;
            }
            Node finalNode = this.graph.getFinalNode();
            int  num4      = this.graph.indexOf(finalNode);

            this.probCurrentFrame[num4] = 0f;
            finalNode.startIncomingEdgeIterator();
            while (finalNode.hasMoreIncomingEdges())
            {
                Edge edge2  = finalNode.nextIncomingEdge();
                Node source = edge2.getSource();
                int  num5   = this.graph.indexOf(source);
                if (!source.isType("STATE"))
                {
                    this.probCurrentFrame[num5] = 0f;
                    if (!BaumWelchLearner.assertionsDisabled)
                    {
                        throw new AssertionError();
                    }
                }
                else
                {
                    HMMState hmmstate2 = (HMMState)source.getObject();
                    if (!hmmstate2.isEmitting())
                    {
                        this.probCurrentFrame[num5] = 0f;
                    }
                }
            }
            return((TrainerScore[][])arrayList.toArray(new TrainerScore[arrayList.size()][]));
        }