Example #1
0
        internal override bool IsWordValid(Morpher morpher, Word word)
        {
            if (!base.IsWordValid(morpher, word))
            {
                return(false);
            }

            if (IsBound && word.Allomorphs.Count == 1)
            {
                if (morpher.TraceManager.IsTracing)
                {
                    morpher.TraceManager.Failed(morpher.Language, word, FailureReason.BoundRoot, this, null);
                }
                return(false);
            }

            if (StemName != null && !StemName.IsRequiredMatch(word.SyntacticFeatureStruct))
            {
                if (morpher.TraceManager.IsTracing)
                {
                    morpher.TraceManager.Failed(morpher.Language, word, FailureReason.RequiredStemName, this, StemName);
                }
                return(false);
            }

            foreach (RootAllomorph otherAllo in ((LexEntry)Morpheme).Allomorphs.Where(a => a != this && a.StemName != null))
            {
                if (!otherAllo.StemName.IsExcludedMatch(word.SyntacticFeatureStruct, StemName))
                {
                    if (morpher.TraceManager.IsTracing)
                    {
                        morpher.TraceManager.Failed(morpher.Language, word, FailureReason.ExcludedStemName, this, otherAllo.StemName);
                    }
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
 public bool IsExcludedMatch(FeatureStruct fs, StemName stemName)
 {
     return(_regions.Except(stemName == null ? Enumerable.Empty <FeatureStruct>() : stemName.Regions, FreezableEqualityComparer <FeatureStruct> .Default).All(r => !r.Subsumes(fs)));
 }