Пример #1
0
        /**
         * /// Undo of the extend operation
         */
        public static void Undo(Fst fst)
        {
            State f         = null;
            int   numStates = fst.GetNumStates();

            for (int i = 0; i < numStates; i++)
            {
                State s = fst.GetState(i);
                if (s.FinalWeight != fst.Semiring.Zero)
                {
                    f = s;
                    break;
                }
            }

            if (f == null)
            {
                Logger.LogInfo <ExtendFinal>("Final state not found.");
                return;
            }
            for (int i = 0; i < numStates; i++)
            {
                State s = fst.GetState(i);
                for (int j = 0; j < s.GetNumArcs(); j++)
                {
                    Arc a = s.GetArc(j);
                    if (a.Ilabel == 0 && a.Olabel == 0 &&
                        a.NextState.GetId() == f.GetId())
                    {
                        s.FinalWeight = a.Weight;
                    }
                }
            }
            fst.DeleteState(f);
        }