Beispiel #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Subrule"/> class.
            /// </summary>
            /// <param name="id">The id.</param>
            /// <param name="desc">The description.</param>
            /// <param name="morpher">The morpher.</param>
            /// <param name="headLhs">The head LHS.</param>
            /// <param name="nonHeadLhs">The non-head LHS.</param>
            /// <param name="rhs">The RHS.</param>
            /// <param name="alphaVars">The alpha variables.</param>
            public Subrule(string id, string desc, Morpher morpher, IEnumerable <PhoneticPattern> headLhs,
                           IEnumerable <PhoneticPattern> nonHeadLhs, IEnumerable <MorphologicalOutput> rhs, AlphaVariables alphaVars)
                : base(id, desc, morpher)
            {
                m_alphaVars = alphaVars;

                List <PhoneticPattern> lhs = new List <PhoneticPattern>();

                lhs.AddRange(headLhs);
                lhs.AddRange(nonHeadLhs);

                m_transform = new MorphologicalTransform(lhs, rhs, MorphologicalTransform.RedupMorphType.IMPLICIT);

                // the LHS template is generated by simply concatenating all of the
                // LHS partitions; it matches the entire word, so we check for both the
                // left and right margins.
                m_headLhsTemp = new PhoneticPattern();
                m_headLhsTemp.Add(new MarginContext(Direction.LEFT));
                int partition = 0;

                foreach (PhoneticPattern pat in headLhs)
                {
                    m_headLhsTemp.AddPartition(pat, partition++);
                }
                m_headLhsTemp.Add(new MarginContext(Direction.RIGHT));

                m_firstNonHeadPartition = partition;
                m_nonHeadLhsTemp        = new PhoneticPattern();
                m_nonHeadLhsTemp.Add(new MarginContext(Direction.LEFT));
                foreach (PhoneticPattern pat in nonHeadLhs)
                {
                    m_nonHeadLhsTemp.AddPartition(pat, partition++);
                }
                m_nonHeadLhsTemp.Add(new MarginContext(Direction.RIGHT));
            }
Beispiel #2
0
 /// <summary>
 /// Generates the RHS template of a morphological rule.
 /// </summary>
 /// <param name="rhsTemp">The RHS template.</param>
 /// <param name="lhs">The LHS.</param>
 /// <param name="modifyFromCtxts">The modify-from contexts.</param>
 /// <param name="redup">The reduplication flag.</param>
 public override void GenerateRHSTemplate(PhoneticPattern rhsTemp, IList <PhoneticPattern> lhs,
                                          IDictionary <int, SimpleContext> modifyFromCtxts)
 {
     // copy LHS partition over the RHS, only indicate the partition if this is
     // the first time this partition is being copied
     rhsTemp.AddPartition(lhs[m_partition], m_redup ? -1 : m_partition);
 }
Beispiel #3
0
        /// <summary>
        /// Generates the RHS template of a morphological rule.
        /// </summary>
        /// <param name="rhsTemp">The RHS template.</param>
        /// <param name="lhs">The LHS.</param>
        /// <param name="modifyFromCtxts">The modify-from contexts.</param>
        /// <param name="redup">The reduplication flag.</param>
        public override void GenerateRHSTemplate(PhoneticPattern rhsTemp, IList <PhoneticPattern> lhs,
                                                 IDictionary <int, SimpleContext> modifyFromCtxts)
        {
            PhoneticPattern ctxtPattern = new PhoneticPattern();

            ctxtPattern.Add(m_ctxt);
            // combines the simple context with all of the simple contexts on the LHS
            // and adds the results to the RHS template
            PhoneticPattern pattern = GenerateChangePartition(lhs[m_partition], ctxtPattern);

            rhsTemp.AddPartition(pattern, m_redup ? -1 : m_partition);
            // add context to the modify-from contexts
            modifyFromCtxts[m_partition] = m_ctxt;
        }
Beispiel #4
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Subrule"/> class.
            /// </summary>
            /// <param name="id">The id.</param>
            /// <param name="desc">The description.</param>
            /// <param name="morpher">The morpher.</param>
            /// <param name="lhs">The LHS.</param>
            /// <param name="rhs">The RHS.</param>
            /// <param name="alphaVars">The alpha variables.</param>
            /// <param name="redupMorphType">The full reduplication type.</param>
            public Subrule(string id, string desc, Morpher morpher, IEnumerable <PhoneticPattern> lhs,
                           IEnumerable <MorphologicalOutput> rhs, AlphaVariables alphaVars, MorphologicalTransform.RedupMorphType redupMorphType)
                : base(id, desc, morpher)
            {
                m_alphaVars = alphaVars;

                m_transform = new MorphologicalTransform(lhs, rhs, redupMorphType);

                // the LHS template is generated by simply concatenating all of the
                // LHS partitions; it matches the entire word, so we check for both the
                // left and right margins.
                m_lhsTemp = new PhoneticPattern();
                m_lhsTemp.Add(new MarginContext(Direction.LEFT));
                int partition = 0;

                foreach (PhoneticPattern pat in lhs)
                {
                    m_lhsTemp.AddPartition(pat, partition, m_transform.IsGreedy(partition));
                    partition++;
                }
                m_lhsTemp.Add(new MarginContext(Direction.RIGHT));
            }