Exemple #1
0
        private static void TrimEndEpsilons(Arc end, Backend backend)
        {
            Arc endArc = end;

            State endState = endArc.Start;

            if (endState != null)
            {
                // Remove the end arc if possible, check done by MoveSemanticTagRight
                if (endArc.IsEpsilonTransition && endState.OutArcs.CountIsOne && Graph.MoveSemanticTagLeft(endArc))
                {
                    // State has a single input epsilon transition
                    // Delete the input epsilon transition and delete state.
                    endArc.Start = null;

                    // Remove all the in arcs duplicate the arcs first
                    foreach (Arc inArc in endState.InArcs.ToList())
                    {
                        inArc.End = null;
                        TrimEndEpsilons(inArc, backend);
                    }

                    // Delete the input epsilon transition and delete state if appropriate.
                    backend.DeleteState(endState);
                }
            }
        }
Exemple #2
0
        private static void TrimEndEpsilons(Arc end, Backend backend)
        {
            State start = end.Start;

            if (start != null && end.IsEpsilonTransition && start.OutArcs.CountIsOne && Graph.MoveSemanticTagLeft(end))
            {
                end.Start = null;
                foreach (Arc item in start.InArcs.ToList())
                {
                    item.End = null;
                    TrimEndEpsilons(item, backend);
                }
                backend.DeleteState(start);
            }
        }