/// <summary> /// Applies the simple context to the input partition and copies it over to the output /// phonetic shape. /// </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) { IList <PhoneticShapeNode> nodes = match.GetPartition(m_partition); if (nodes != null && nodes.Count > 0) { Morph morph = null; if (allomorph != null) { morph = new Morph(allomorph); output.Morphs.Add(morph); } for (PhoneticShapeNode node = nodes[0]; node != nodes[nodes.Count - 1].Next; node = node.Next) { PhoneticShapeNode newNode = node.Clone(); if (node.Type == PhoneticShapeNode.NodeType.SEGMENT) { Segment seg = newNode as Segment; // sets the context's features on the segment m_ctxt.Apply(seg, match.VariableValues); seg.IsClean = false; seg.Partition = morph == null ? -1 : morph.Partition; } if (morph != null) { morph.Shape.Add(newNode.Clone()); } output.Shape.Add(newNode); } } }
/// <summary> /// Initializes a new instance of the <see cref="WordSynthesis"/> class. /// </summary> /// <param name="rootAllomorph">The root allomorph.</param> /// <param name="nonHead">The non-head synthesis.</param> /// <param name="rzFeatures">The realizational features.</param> /// <param name="mrules">The morphological rules to apply.</param> /// <param name="curTrace">The current trace record.</param> internal WordSynthesis(LexEntry.RootAllomorph rootAllomorph, WordSynthesis nonHead, FeatureValues rzFeatures, IEnumerable <MorphologicalRule> mrules, Trace curTrace) { m_root = (LexEntry)rootAllomorph.Morpheme; m_mprFeatures = m_root.MPRFeatures != null?m_root.MPRFeatures.Clone() : new MPRFeatureSet(); m_headFeatures = m_root.HeadFeatures != null?m_root.HeadFeatures.Clone() : new FeatureValues(); m_footFeatures = m_root.FootFeatures != null?m_root.FootFeatures.Clone() : new FeatureValues(); m_pos = m_root.POS; m_stratum = m_root.Stratum; m_nonHead = nonHead; m_morphs = new Morphs(); Morph morph = new Morph(rootAllomorph); morph.Shape.AddMany(rootAllomorph.Shape.Segments); m_morphs.Add(morph); m_shape = new PhoneticShape(); m_shape.Add(new Margin(Direction.LEFT)); m_shape.AddPartition(rootAllomorph.Shape.Segments, morph.Partition); m_shape.Add(new Margin(Direction.RIGHT)); m_obligHeadFeatures = new HCObjectSet <Feature>(); m_mrules = new List <MorphologicalRule>(mrules); m_rzFeatures = rzFeatures; m_curTrace = curTrace; m_mrulesApplied = new Dictionary <MorphologicalRule, int>(); }
public bool Equals(Morph other) { if (other == null) { return(false); } return(m_allomorph == other.m_allomorph); }
HCObject GetMorphObject(Morph morph) { switch (m_objectType) { case ObjectType.ALLOMORPH: return(morph.Allomorph); case ObjectType.MORPHEME: return(morph.Allomorph.Morpheme); } return(null); }
/// <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); }
/// <summary> /// Copies a partition from the input phonetic shape to the output phonetic shape. /// </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) { IList <PhoneticShapeNode> nodes = match.GetPartition(m_partition); if (nodes != null && nodes.Count > 0) { Morph morph = null; for (PhoneticShapeNode node = nodes[0]; node != nodes[nodes.Count - 1].Next; node = node.Next) { PhoneticShapeNode newNode = node.Clone(); // mark the reduplicated segments with the gloss partition if (m_redup) { if (allomorph != null) { if (morph == null) { morph = new Morph(allomorph); output.Morphs.Add(morph); } newNode.Partition = morph.Partition; morph.Shape.Add(node.Clone()); } else { newNode.Partition = -1; } } else if (node.Partition != -1) { if (morph == null || morph.Partition != node.Partition) { morph = input.Morphs[node.Partition].Clone(); morph.Shape.Clear(); output.Morphs.Add(morph); } newNode.Partition = morph.Partition; morph.Shape.Add(node.Clone()); } output.Shape.Add(newNode); } } }
/// <summary> /// Inserts the segments and boundaries in to the output phonetic shape. /// </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) { Morph morph = null; if (allomorph != null) { morph = new Morph(allomorph); output.Morphs.Add(morph); } for (PhoneticShapeNode node = m_pshape.Begin; node != m_pshape.Last; node = node.Next) { PhoneticShapeNode newNode = node.Clone(); if (morph != null) { newNode.Partition = morph.Partition; morph.Shape.Add(node.Clone()); } else { newNode.Partition = -1; } output.Shape.Add(newNode); } }
/// <summary> /// Copy constructor. /// </summary> /// <param name="morph">The morph.</param> public Morph(Morph morph) { m_partition = morph.m_partition; m_shape = morph.m_shape.Clone(); m_allomorph = morph.m_allomorph; }