Exemple #1
0
        /// <summary>
        /// Inserts a segment based on a simple context to the output.
        /// </summary>
        /// <param name="match">The match.</param>
        /// <param name="input">The input word synthesis.</param>
        /// <param name="output">The output word synthesis.</param>
        /// <param name="morpheme">The morpheme info.</param>
        public override void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph)
        {
            Segment newSeg = m_ctxt.ApplyInsertion(match.VariableValues);

            if (allomorph != null)
            {
                Morph morph = new Morph(allomorph);
                output.Morphs.Add(morph);
                morph.Shape.Add(newSeg.Clone());
                newSeg.Partition = morph.Partition;
            }
            output.Shape.Add(newSeg);
        }
Exemple #2
0
            void ApplyInsertion(Direction dir, IList <PhoneticShapeNode> match, VariableValues instantiatedVars)
            {
                PhoneticShapeNode cur = match[match.Count - 1];

                for (PhoneticPatternNode pseqNode = m_rhs.GetFirst(dir); pseqNode != null;
                     pseqNode = pseqNode.GetNext(dir))
                {
                    PhoneticShapeNode newNode = null;
                    switch (pseqNode.Type)
                    {
                    case PhoneticPatternNode.NodeType.SIMP_CTXT:
                        SimpleContext ctxt = pseqNode as SimpleContext;
                        newNode = ctxt.ApplyInsertion(instantiatedVars);
                        break;

                    case PhoneticPatternNode.NodeType.BDRY_CTXT:
                        newNode = new Boundary(pseqNode as BoundaryContext);
                        break;
                    }

                    if (newNode != null)
                    {
                        try
                        {
                            cur.Insert(newNode, dir);
                        }
                        catch (InvalidOperationException ioe)
                        {
                            MorphException me = new MorphException(MorphException.MorphErrorType.TOO_MANY_SEGS, m_rule.Morpher,
                                                                   string.Format(HCStrings.kstidTooManySegs, m_rule.ID), ioe);
                            me.Data["rule"] = m_rule.ID;
                            throw me;
                        }
                        cur = newNode;
                    }
                }
            }