Exemplo n.º 1
0
            /// <summary>
            /// Checks if the subrule will be unapplied vacuously. Vacuous unapplication means that
            /// the subrule will actually make changes to the phonetic shape. This is important to know
            /// for self-opaquing, simultaneously applying subrules, since we unapply these subrules
            /// until they unapply nonvacuously.
            /// </summary>
            /// <param name="match">The match.</param>
            /// <param name="dir">The direction.</param>
            /// <returns></returns>
            bool CheckVacuousUnapplication(Match match, Direction dir)
            {
                PhoneticPatternNode       rhsNode = m_rhs.GetFirst(dir);
                IList <PhoneticShapeNode> nodes   = match.EntireMatch;
                int i = 0;

                while (i < nodes.Count)
                {
                    if (Type == ChangeType.EPENTHESIS)
                    {
                        // for epenthesis subrules, simply check if the epenthesized segment is
                        // already marked as optional
                        if (!nodes[i++].IsOptional)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        switch (rhsNode.Type)
                        {
                        case PhoneticPatternNode.NodeType.SIMP_CTXT:
                            SimpleContext ctxt = rhsNode as SimpleContext;
                            Segment       seg  = nodes[i] as Segment;
                            if (ctxt.IsUnapplicationVacuous(seg, match.VariableValues))
                            {
                                return(true);
                            }
                            i++;
                            break;

                        case PhoneticPatternNode.NodeType.BDRY_CTXT:
                            break;
                        }

                        rhsNode = rhsNode.GetNext(dir);
                    }
                }

                return(false);
            }