@@ -31,7 +31,6 @@ public class Word : Freezable<Word>, IAnnotatedData<ShapeNode>, ICloneable<Word>
3131 private bool _isPartial ;
3232 private readonly Dictionary < string , HashSet < int > > _disjunctiveAllomorphIndices ;
3333 private int _mruleAppCount = 0 ;
34- private readonly Word _cloneOf = null ;
3534 private readonly IList < Word > _alternatives = new List < Word > ( ) ;
3635
3736 public Word ( RootAllomorph rootAllomorph , FeatureStruct realizationalFS )
@@ -74,6 +73,8 @@ protected Word(Word word)
7473 {
7574 _allomorphs = new Dictionary < string , Allomorph > ( word . _allomorphs ) ;
7675 Stratum = word . Stratum ;
76+ Source = word ;
77+ // Don't copy Alternatives.
7778 _shape = word . _shape . Clone ( ) ;
7879 _rootAllomorph = word . _rootAllomorph ;
7980 SyntacticFeatureStruct = word . SyntacticFeatureStruct . Clone ( ) ;
@@ -94,7 +95,6 @@ protected Word(Word word)
9495 kvp => new HashSet < int > ( kvp . Value )
9596 ) ;
9697 _mruleAppCount = word . _mruleAppCount ;
97- _cloneOf = word ;
9898 }
9999
100100 public IEnumerable < Annotation < ShapeNode > > Morphs
@@ -399,10 +399,7 @@ internal void NonHeadUnapplied(Word nonHead)
399399 _nonHeadAppIndex ++ ;
400400 }
401401
402- internal Word CloneOf
403- {
404- get { return _cloneOf ; }
405- }
402+ internal Word Source { get ; set ; }
406403
407404 internal IList < Word > Alternatives
408405 {
@@ -412,8 +409,8 @@ internal IList<Word> Alternatives
412409 internal IList < Word > ExpandAlternatives ( )
413410 {
414411 IList < Word > alternatives = new List < Word > ( ) ;
415- IList < Word > originals = _cloneOf ? . ExpandAlternatives ( ) ;
416- // Update the alternatives of _cloneOf with any changes made since the clone.
412+ IList < Word > originals = Source ? . ExpandAlternatives ( ) ;
413+ // Update the alternatives of CloneOf with any changes made since the clone.
417414 if ( originals == null || originals . Count < 2 )
418415 {
419416 // Special case.
@@ -426,18 +423,17 @@ internal IList<Word> ExpandAlternatives()
426423 Word alternative = original . Clone ( ) ;
427424 alternative . _shape = this . Shape ;
428425 // Add new rules to alternative.
429- foreach ( IMorphologicalRule rule in MorphologicalRules )
430- {
431- if ( _cloneOf != null && _cloneOf . MorphologicalRules . Contains ( rule ) )
432- continue ;
433- alternative . MorphologicalRuleUnapplied ( rule ) ;
434- }
426+ int m_start = Source == null ? 0 : Source . _mruleApps . Count ( ) ;
427+ for ( int i = m_start ; i < _mruleApps . Count ( ) ; i ++ )
428+ alternative . MorphologicalRuleUnapplied ( _mruleApps [ i ] ) ;
429+ int nh_start = Source == null ? 0 : Source . _nonHeadApps . Count ( ) ;
430+ for ( int i = nh_start ; i < _nonHeadApps . Count ( ) ; i ++ )
431+ alternative . NonHeadUnapplied ( _nonHeadApps [ i ] ) ;
435432 if ( RootAllomorph != null )
436433 alternative . RootAllomorph = RootAllomorph ;
437434 alternative . Freeze ( ) ;
438435 alternatives . Add ( alternative ) ;
439436 }
440-
441437 }
442438 // Add local alternatives.
443439 foreach ( Word alternative in _alternatives )
0 commit comments