Beispiel #1
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="margin">The margin.</param>
		public Margin(Margin margin)
			: base(margin)
		{
			m_marginType = margin.m_marginType;
		}
Beispiel #2
0
		public bool Equals(Margin other)
		{
			if (other == null)
				return false;
			return m_marginType == other.m_marginType;
		}
Beispiel #3
0
        /// <summary>
        /// Checks if the specified phonetic shape node matches this simple context.
        /// </summary>
        /// <param name="node">The phonetic shape node.</param>
        /// <param name="dir">The direction.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="instantiatedVars">The instantiated variables.</param>
        /// <returns>All matches.</returns>
        internal override IList <Match> Match(PhoneticShapeNode node, Direction dir, ModeType mode,
                                              VariableValues instantiatedVars)
        {
            switch (node.Type)
            {
            case PhoneticShapeNode.NodeType.BOUNDARY:
                // only check boundaries in synthesis mode when the pattern is a target,
                // otherwise skip
                if (mode == ModeType.SYNTHESIS)
                {
                    if (Owner.IsTarget)
                    {
                        return(new List <Match>());
                    }
                    else
                    {
                        IList <Match> bdryMatches = Match(node.GetNext(dir), dir, mode, instantiatedVars);
                        foreach (Match match in bdryMatches)
                        {
                            match.Add(node, m_partition);
                        }
                        return(bdryMatches);
                    }
                }
                else
                {
                    return(Match(node.GetNext(dir), dir, mode, instantiatedVars));
                }

            case PhoneticShapeNode.NodeType.MARGIN:
                Margin margin = node as Margin;
                if (dir == margin.MarginType)
                {
                    // we are at the end of the shape, so no match
                    return(new List <Match>());
                }
                else
                {
                    return(Match(node.GetNext(dir), dir, mode, instantiatedVars));
                }

            case PhoneticShapeNode.NodeType.SEGMENT:
                Segment seg = node as Segment;
                if (mode == ModeType.SYNTHESIS && Owner.IsTarget)
                {
                    // check segment to see if it has already been altered by another
                    // subrule, only matters for simultaneously applying rules
                    if (!seg.IsClean)
                    {
                        return(new List <Match>());
                    }
                }

                VariableValues tempVars = instantiatedVars.Clone();
                if (m_featSys.HasFeatures)
                {
                    if (!IsFeatureMatch(seg, tempVars, mode))
                    {
                        return(new List <Match>());
                    }
                }
                else
                {
                    if (!IsSegmentMatch(seg))
                    {
                        return(new List <Match>());
                    }
                }

                // move to the next node
                IList <Match> segMatches = MatchNext(node, dir, mode, tempVars);
                foreach (Match match in segMatches)
                {
                    match.Add(node, m_partition);
                }

                return(segMatches);
            }

            return(new List <Match>());
        }