public void GetNonconformities_MorphemeRule() { AdTree adTree = new AdTree(new Morpheme(myAttributesModel, "green", EnglishAttributes.A.Lexeme), EnglishPattern.Morpheme(EnglishAttributes.A.Lexeme)); List <IAdTree> nonconformities = adTree.GetNonconformities(myAttributesModel).ToList(); Assert.AreEqual(0, nonconformities.Count); // Empty string does not match the rule. adTree = new AdTree(new Morpheme(myAttributesModel, "", EnglishAttributes.A.Lexeme), EnglishPattern.Morpheme(EnglishAttributes.A.Lexeme)); nonconformities = adTree.GetNonconformities(myAttributesModel).ToList(); Assert.AreEqual(1, nonconformities.Count); // Morpheme attributes does not match the rule. adTree = new AdTree(new Morpheme(myAttributesModel, "bla", EnglishAttributes.A.NonLexeme), EnglishPattern.Morpheme(EnglishAttributes.A.Lexeme)); nonconformities = adTree.GetNonconformities(myAttributesModel).ToList(); Assert.AreEqual(1, nonconformities.Count); // Attached right children violates the rule. adTree = new AdTree(new Morpheme(myAttributesModel, "green", EnglishAttributes.A.Lexeme), EnglishPattern.Morpheme(EnglishAttributes.A.Lexeme)) { // Note: the rule is nothing so having this attached violates the rule. Right = new AdTree(new Morpheme(myAttributesModel, "", 0), new Pattern()) }; nonconformities = adTree.GetNonconformities(myAttributesModel).ToList(); Assert.AreEqual(1, nonconformities.Count); }
public void GetNonconformities_MonoTransference() { AdTree adTree = new AdTree(Morpheme.Epsilon(myAttributesModel), EnglishPattern.EpsilonAdPosition("A-O", "", EnglishAttributes.A.Lexeme, EnglishAttributes.O.Lexeme)) { Right = new AdTree(new Morpheme(myAttributesModel, "car", EnglishAttributes.O.Lexeme), EnglishPattern.Morpheme(EnglishAttributes.O.Lexeme)), Left = new AdTree(new Morpheme(myAttributesModel, "", EnglishAttributes.A.Lexeme), EnglishPattern.MonoTransference("O>A", EnglishAttributes.A.Lexeme, EnglishAttributes.O.Lexeme)) { Right = new AdTree(new Morpheme(myAttributesModel, "race", EnglishAttributes.O.Lexeme), EnglishPattern.Morpheme(EnglishAttributes.O.Lexeme)), Left = null, }, }; List <IAdTree> nonconformities = adTree.GetNonconformities(myAttributesModel).ToList(); Assert.AreEqual(0, nonconformities.Count); }