protected override bool ConstraintsEqual(Allomorph other) { var otherAllo = other as RootAllomorph; if (otherAllo == null) { return(false); } return(base.ConstraintsEqual(other) && IsBound == otherAllo.IsBound); }
internal Annotation <ShapeNode> MarkMorph(IEnumerable <ShapeNode> nodes, Allomorph allomorph) { ShapeNode[] nodeArray = nodes.ToArray(); Annotation <ShapeNode> ann = null; if (nodeArray.Length > 0) { ann = new Annotation <ShapeNode>(_shape.SpanFactory.Create(nodeArray[0], nodeArray[nodeArray.Length - 1]), FeatureStruct.New() .Symbol(HCFeatureSystem.Morph) .Feature(HCFeatureSystem.Allomorph).EqualTo(allomorph.ID).Value); ann.Children.AddRange(nodeArray.Select(n => n.Annotation)); _shape.Annotations.Add(ann, false); } _allomorphs[allomorph.ID] = allomorph; return(ann); }
protected virtual void Write(string localName, Allomorph allo) { m_xmlWriter.WriteStartElement(localName); m_xmlWriter.WriteAttributeString("id", allo.ID); m_xmlWriter.WriteElementString("Description", allo.Description); Write("Morpheme", allo.Morpheme); m_xmlWriter.WriteStartElement("Properties"); foreach (KeyValuePair <string, string> prop in allo.Properties) { m_xmlWriter.WriteStartElement("Property"); m_xmlWriter.WriteElementString("Key", prop.Key); m_xmlWriter.WriteElementString("Value", prop.Value); m_xmlWriter.WriteEndElement(); } m_xmlWriter.WriteEndElement(); m_xmlWriter.WriteEndElement(); }
public override bool ConstraintsEqual(Allomorph other) { Subrule otherSubrule = (Subrule)other; if (m_requiredMPRFeatures == null) { if (otherSubrule.m_requiredMPRFeatures != null) { return(false); } } else { if (!m_requiredMPRFeatures.Equals(otherSubrule.m_requiredMPRFeatures)) { return(false); } } if (m_excludedMPRFeatures == null) { if (otherSubrule.m_excludedMPRFeatures != null) { return(false); } } else { if (!m_excludedMPRFeatures.Equals(otherSubrule.m_excludedMPRFeatures)) { return(false); } } return(m_lhsTemp.Equals(otherSubrule.m_lhsTemp) && base.ConstraintsEqual(other)); }
protected override Morpheme GetMorphObject(Allomorph morph) { return(morph.Morpheme); }
/// <summary> /// Adds the allomorph. /// </summary> /// <param name="allomorph">The allomorph.</param> public void AddAllomorph(Allomorph allomorph) { m_allomorphs.Add(allomorph); }
internal Annotation <ShapeNode> MarkSubsumedMorph(Annotation <ShapeNode> morph, Allomorph allomorph) { Annotation <ShapeNode> ann = new Annotation <ShapeNode>(morph.Span, FeatureStruct.New() .Symbol(HCFeatureSystem.Morph) .Feature(HCFeatureSystem.Allomorph).EqualTo(allomorph.ID).Value); morph.Children.Add(ann, false); _allomorphs[allomorph.ID] = allomorph; return(ann); }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="Morph"/> class. /// </summary> /// <param name="allomorph">The allomorph.</param> public Morph(Allomorph allomorph) { m_allomorph = allomorph; m_shape = new PhoneticShape(); }
/// <summary> /// Applies this output record to the specified word synthesis. /// </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 abstract void Apply(Match match, WordSynthesis input, WordSynthesis output, Allomorph allomorph);
/// <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> /// 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> /// 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); } } }
protected abstract T GetMorphObject(Allomorph morph);
public override bool ConstraintsEqual(Allomorph other) { RootAllomorph otherAllo = (RootAllomorph)other; return(m_shape.Equals(otherAllo.m_shape) && base.ConstraintsEqual(other)); }