예제 #1
0
        internal static bool MoveSemanticTagLeft(Arc arc)
        {
            State start = arc.Start;
            Arc   first = start.InArcs.First;

            if (start.InArcs.CountIsOne && start.OutArcs.CountIsOne && CanTagsBeMoved(first, arc))
            {
                Arc.CopyTags(arc, first, Direction.Left);
                return(true);
            }
            return(arc.IsPropertylessTransition);
        }
예제 #2
0
        internal static bool MoveSemanticTagRight(Arc arc)
        {
            State end   = arc.End;
            Arc   first = end.OutArcs.First;

            if (end.InArcs.CountIsOne && end.OutArcs.CountIsOne && CanTagsBeMoved(arc, first))
            {
                Arc.CopyTags(arc, first, Direction.Right);
                return(true);
            }
            return(arc.IsPropertylessTransition);
        }
예제 #3
0
        private void MergeDuplicateOutputTransitions(ArcList arcs, Stack <State> mergeStates)
        {
            List <Arc> list = null;
            Arc        arc  = null;
            bool       flag = false;

            foreach (Arc arc5 in arcs)
            {
                bool flag2 = arc5.End == null || !arc5.End.InArcs.CountIsOne;
                if (arc != null && Arc.CompareContent(arc5, arc) == 0)
                {
                    if (!flag2)
                    {
                        if (list == null)
                        {
                            list = new List <Arc>();
                        }
                        if (!flag)
                        {
                            list.Add(arc);
                            flag = true;
                        }
                        list.Add(arc5);
                    }
                }
                else
                {
                    arc  = (flag2 ? null : arc5);
                    flag = false;
                }
            }
            if (list != null)
            {
                list.Sort(Arc.CompareForDuplicateOutputTransitions);
                arc = null;
                Arc   arc3  = null;
                State state = null;
                bool  flag3 = false;
                foreach (Arc item in list)
                {
                    if (arc == null || Arc.CompareContent(item, arc) != 0)
                    {
                        arc = item;
                        if (flag3)
                        {
                            AddToMergeStateList(mergeStates, state);
                        }
                        arc3  = null;
                        state = null;
                        flag3 = false;
                    }
                    Arc   arc4 = item;
                    State end  = arc4.End;
                    if (end != end.Rule._firstState && MoveSemanticTagRight(arc4))
                    {
                        if (arc3 != null)
                        {
                            if (!flag3)
                            {
                                foreach (Arc outArc in state.OutArcs)
                                {
                                    outArc.Weight *= arc3.Weight;
                                }
                                flag3 = true;
                            }
                            foreach (Arc outArc2 in end.OutArcs)
                            {
                                outArc2.Weight *= arc4.Weight;
                            }
                            arc4.Weight += arc3.Weight;
                            Arc.CopyTags(arc3, arc4, Direction.Right);
                            DeleteTransition(arc3);
                            MoveOutputTransitionsAndDeleteState(state, end);
                        }
                        arc3  = arc4;
                        state = end;
                    }
                }
                if (flag3)
                {
                    AddToMergeStateList(mergeStates, state);
                }
            }
        }