Пример #1
0
 public void Add(RootAllomorph allomorph)
 {
     _allomorphs[allomorph.ID] = allomorph;
     ShapeNode first = allomorph.Segments.Shape.GetFirst(n => _filter(n.Annotation));
     if (first == allomorph.Segments.Shape.End)
         _fsa.StartState.Arcs.Add(_fsa.CreateAcceptingState(allomorph.ID, (s, match) => true, _shapeCount));
     else
         AddNode(first, _fsa.StartState, allomorph.ID);
     _shapeCount++;
 }
Пример #2
0
        private void SetRootAllomorph(RootAllomorph rootAllomorph)
        {
            _rootAllomorph = rootAllomorph;
            var entry = (LexEntry)_rootAllomorph.Morpheme;

            Stratum = entry.Stratum;
            MarkMorph(_shape, _rootAllomorph);
            SyntacticFeatureStruct = entry.SyntacticFeatureStruct.DeepClone();
            _mprFeatures.Clear();
            _mprFeatures.UnionWith(entry.MprFeatures);
            _isPartial = entry.IsPartial;
        }
Пример #3
0
 public Word(RootAllomorph rootAllomorph, FeatureStruct realizationalFS)
 {
     _allomorphs  = new Dictionary <string, Allomorph>();
     _mprFeatures = new MprFeatureSet();
     _shape       = rootAllomorph.Segments.Shape.DeepClone();
     ResetDirty();
     SetRootAllomorph(rootAllomorph);
     RealizationalFeatureStruct = realizationalFS;
     _mrules                      = new Stack <IMorphologicalRule>();
     _mrulesUnapplied             = new Dictionary <IMorphologicalRule, int>();
     _mrulesApplied               = new Dictionary <IMorphologicalRule, int>();
     _nonHeads                    = new Stack <Word>();
     _obligatorySyntacticFeatures = new IDBearerSet <Feature>();
     _isLastAppliedRuleFinal      = null;
 }
Пример #4
0
        public void Add(RootAllomorph allomorph)
        {
            _allomorphs[allomorph.ID] = allomorph;
            ShapeNode first = allomorph.Segments.Shape.GetFirst(n => _filter(n.Annotation));

            if (first == allomorph.Segments.Shape.End)
            {
                _fsa.StartState.Arcs.Add(_fsa.CreateAcceptingState(allomorph.ID, (s, match) => true, _shapeCount));
            }
            else
            {
                AddNode(first, _fsa.StartState, allomorph.ID);
            }
            _shapeCount++;
        }
Пример #5
0
 protected Word(Word word)
 {
     _allomorphs                  = new Dictionary <string, Allomorph>(word._allomorphs);
     Stratum                      = word.Stratum;
     _shape                       = word._shape.DeepClone();
     _rootAllomorph               = word._rootAllomorph;
     SyntacticFeatureStruct       = word.SyntacticFeatureStruct.DeepClone();
     RealizationalFeatureStruct   = word.RealizationalFeatureStruct.DeepClone();
     _mprFeatures                 = word.MprFeatures.DeepClone();
     _mrules                      = new Stack <IMorphologicalRule>(word._mrules.Reverse());
     _mrulesUnapplied             = new Dictionary <IMorphologicalRule, int>(word._mrulesUnapplied);
     _mrulesApplied               = new Dictionary <IMorphologicalRule, int>(word._mrulesApplied);
     _nonHeads                    = new Stack <Word>(word._nonHeads.Reverse().DeepClone());
     _obligatorySyntacticFeatures = new IDBearerSet <Feature>(word._obligatorySyntacticFeatures);
     _isLastAppliedRuleFinal      = word._isLastAppliedRuleFinal;
     _isPartial                   = word._isPartial;
     CurrentTrace                 = word.CurrentTrace;
 }
Пример #6
0
 /// <summary>
 /// Adds the specified allomorph.
 /// </summary>
 /// <param name="allomorph">The allomorph.</param>
 public void AddAllomorph(RootAllomorph allomorph)
 {
     allomorph.Morpheme = this;
     allomorph.Index    = m_allomorphs.Count;
     m_allomorphs.Add(allomorph);
 }
Пример #7
0
		/// <summary>
		/// Adds the specified allomorph.
		/// </summary>
		/// <param name="allomorph">The allomorph.</param>
		public void AddAllomorph(RootAllomorph allomorph)
		{
			allomorph.Morpheme = this;
			allomorph.Index = m_allomorphs.Count;
			m_allomorphs.Add(allomorph);
		}
Пример #8
0
            public override bool ConstraintsEqual(Allomorph other)
            {
                RootAllomorph otherAllo = (RootAllomorph)other;

                return(m_shape.Equals(otherAllo.m_shape) && base.ConstraintsEqual(other));
            }
Пример #9
0
        private RootAllomorph LoadRootAllomorph(XElement alloElem, CharacterDefinitionTable table)
        {
            var shapeStr = (string) alloElem.Element("PhoneticShape");
            Segments segments = new Segments(table, shapeStr);
            if (segments.Shape.All(n => n.Type() == HCFeatureSystem.Boundary))
                throw new InvalidShapeException(shapeStr, 0);
            var allomorph = new RootAllomorph(segments)
            {
                IsBound = (bool?) alloElem.Attribute("isBound") ?? false
            };

            allomorph.Environments.AddRange(LoadAllomorphEnvironments(alloElem.Element("RequiredEnvironments"), ConstraintType.Require, table));
            allomorph.Environments.AddRange(LoadAllomorphEnvironments(alloElem.Element("ExcludedEnvironments"), ConstraintType.Exclude, table));

            var stemNameIDStr = (string) alloElem.Attribute("stemName");
            if (!string.IsNullOrEmpty(stemNameIDStr))
                allomorph.StemName = _stemNames[stemNameIDStr];

            LoadProperties(alloElem.Element("Properties"), allomorph.Properties);

            return allomorph;
        }