Exemplo n.º 1
0
        void Untruncate(PhoneticPattern lhs, PhoneticShape output, bool optional, VariableValues instantiatedVars)
        {
            // create segments from the LHS partition pattern and append them to the output
            foreach (PhoneticPatternNode node in lhs)
            {
                switch (node.Type)
                {
                case PhoneticPatternNode.NodeType.SIMP_CTXT:
                    SimpleContext ctxt   = node as SimpleContext;
                    Segment       newSeg = ctxt.UnapplyDeletion(instantiatedVars);
                    newSeg.IsOptional = optional;
                    output.Add(newSeg);
                    break;

                case PhoneticPatternNode.NodeType.PATTERN:
                    NestedPhoneticPattern nestedPattern = node as NestedPhoneticPattern;
                    // untruncate nested partitions the maximum number of times it can occur,
                    // marking any segments that occur after the minimum number of occurrences
                    // as optional
                    for (int j = 0; j < nestedPattern.MaxOccur; j++)
                    {
                        Untruncate(nestedPattern.Pattern, output, j >= nestedPattern.MinOccur, instantiatedVars);
                    }
                    break;

                case PhoneticPatternNode.NodeType.BDRY_CTXT:
                    // skip boundaries
                    break;
                }
            }
        }
Exemplo n.º 2
0
            bool UnapplyNarrow(PhoneticShape input)
            {
                List <Match>      matches = new List <Match>();
                PhoneticShapeNode node    = input.First;
                Match             match;

                // deletion subrules are always treated like simultaneous subrules during unapplication
                while (FindNextMatchRHS(node, Direction.RIGHT, out match))
                {
                    matches.Add(match);
                    node = match.EntireMatch[0].Next;
                }

                foreach (Match m in matches)
                {
                    PhoneticShapeNode cur = m.EntireMatch[m.EntireMatch.Count - 1];
                    foreach (PhoneticPatternNode lhsNode in m_rule.m_lhs)
                    {
                        if (lhsNode.Type != PhoneticPatternNode.NodeType.SIMP_CTXT)
                        {
                            continue;
                        }

                        SimpleContext ctxt   = lhsNode as SimpleContext;
                        Segment       newSeg = ctxt.UnapplyDeletion(m.VariableValues);
                        // mark the undeleted segment as optional
                        newSeg.IsOptional = true;
                        cur.Insert(newSeg, Direction.RIGHT);
                        cur = newSeg;
                    }

                    if (m_analysisTarget.Count > 0)
                    {
                        foreach (PhoneticShapeNode matchNode in m.EntireMatch)
                        {
                            matchNode.IsOptional = true;
                        }
                    }
                }

                return(matches.Count > 0);
            }