Beispiel #1
0
        void ApplyIterative(PhoneticShape input, Direction dir, List <Subrule> subrules)
        {
            Match             match;
            PhoneticShapeNode node = input.GetFirst(dir);

            // iterate thru each LHS match
            while (FindNextMatchLHS(node, dir, out match))
            {
                IList <PhoneticShapeNode> nodes            = match.EntireMatch;
                VariableValues            instantiatedVars = match.VariableValues;
                bool matched = false;
                // check each subrule's environment
                foreach (Subrule sr in subrules)
                {
                    if (m_lhs.Count == 0
                                                ? sr.MatchEnvEmpty(nodes[0], dir, ModeType.SYNTHESIS, instantiatedVars)
                                                : sr.MatchEnvNonempty(nodes, dir, ModeType.SYNTHESIS, instantiatedVars))
                    {
                        sr.ApplyRHS(dir, nodes, instantiatedVars);
                        matched = true;
                        break;
                    }
                }

                if (matched)
                {
                    node = nodes[nodes.Count - 1].GetNext(dir);
                }
                else
                {
                    node = nodes[0].GetNext(dir);
                }
            }
        }
Beispiel #2
0
            bool UnapplyIterative(PhoneticShape input, Direction dir)
            {
                bool unapplied         = false;
                PhoneticShapeNode node = input.GetFirst(dir);
                Match             match;

                // iterate thru all matches
                while (FindNextMatchRHS(node, dir, out match))
                {
                    // unapply the subrule
                    IList <PhoneticShapeNode> nodes = match.EntireMatch;
                    UnapplyRHS(dir, nodes, match.VariableValues);
                    unapplied = true;
                    node      = nodes[nodes.Count - 1].GetNext(dir);
                }

                return(unapplied);
            }
Beispiel #3
0
        bool ProcessIterative(PhoneticShape input, Direction dir, PhoneticPattern ptemp, ModeType mode)
        {
            bool reordered         = false;
            PhoneticShapeNode node = input.GetFirst(dir);
            Match             match;

            // iterate thru each match
            while (FindNextMatch(node, dir, ptemp, mode, out match))
            {
                // reorder the matching segments
                Reorder(dir, match);
                reordered = true;
                IList <PhoneticShapeNode> nodes = match.EntireMatch;
                node = nodes[nodes.Count - 1].GetNext(dir);
            }

            return(reordered);
        }
Beispiel #4
0
 public IEnumerable <Match> SearchPartial(PhoneticShape shape)
 {
     return(new Set <Match>(m_root.Search(shape.GetFirst(m_dir), m_dir, true)));
 }
Beispiel #5
0
 /// <summary>
 /// Adds the specified lexical entry.
 /// </summary>
 /// <param name="entry">The lexical entry.</param>
 public void Add(PhoneticShape shape, T value)
 {
     m_root.Add(shape.GetFirst(m_dir), value, m_dir);
     m_numValues++;
 }