예제 #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);
        }
예제 #2
0
파일: Word.cs 프로젝트: papeh/hermitcrab
        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);
        }
예제 #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();
 }
예제 #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));
            }
예제 #5
0
 protected override Morpheme GetMorphObject(Allomorph morph)
 {
     return(morph.Morpheme);
 }
예제 #6
0
 /// <summary>
 /// Adds the allomorph.
 /// </summary>
 /// <param name="allomorph">The allomorph.</param>
 public void AddAllomorph(Allomorph allomorph)
 {
     m_allomorphs.Add(allomorph);
 }
예제 #7
0
파일: Word.cs 프로젝트: papeh/hermitcrab
        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);
        }
예제 #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;
 }
예제 #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();
 }
예제 #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);
예제 #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);
            }
        }
예제 #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);
                }
            }
        }
예제 #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);
        }
예제 #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);
                }
            }
        }
예제 #15
0
 protected abstract T GetMorphObject(Allomorph morph);
예제 #16
0
            public override bool ConstraintsEqual(Allomorph other)
            {
                RootAllomorph otherAllo = (RootAllomorph)other;

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