Ejemplo n.º 1
0
        protected override bool ConstraintsEqual(Allomorph other)
        {
            var otherAllo = other as RootAllomorph;

            if (otherAllo == null)
            {
                return(false);
            }

            return(base.ConstraintsEqual(other) && IsBound == otherAllo.IsBound);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
            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));
            }
Ejemplo n.º 5
0
 protected override Morpheme GetMorphObject(Allomorph morph)
 {
     return(morph.Morpheme);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds the allomorph.
 /// </summary>
 /// <param name="allomorph">The allomorph.</param>
 public void AddAllomorph(Allomorph allomorph)
 {
     m_allomorphs.Add(allomorph);
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 /// <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;
 }
Ejemplo n.º 9
0
 /// <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();
 }
Ejemplo n.º 10
0
 /// <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);
Ejemplo n.º 11
0
        /// <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);
            }
        }
Ejemplo n.º 12
0
        /// <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);
                }
            }
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        /// <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);
                }
            }
        }
Ejemplo n.º 15
0
 protected abstract T GetMorphObject(Allomorph morph);
Ejemplo n.º 16
0
            public override bool ConstraintsEqual(Allomorph other)
            {
                RootAllomorph otherAllo = (RootAllomorph)other;

                return(m_shape.Equals(otherAllo.m_shape) && base.ConstraintsEqual(other));
            }