public void RuleToExcludeTermCompletely() { Dictionary <string, KeyTermRule> rules = new Dictionary <string, KeyTermRule>(); KeyTermRule rule = new KeyTermRule(); rule.id = "Jesus"; rule.Rule = KeyTermRule.RuleType.Exclude; rules[rule.id] = rule; KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("Jesus"), new ReadonlyDictionary <string, KeyTermRule>(rules), null); Assert.AreEqual(0, bldr.Matches.Count()); }
public void RuleToKeepOriginalTermAndAddAnAlternate() { Dictionary <string, KeyTermRule> rules = new Dictionary <string, KeyTermRule>(); KeyTermRule rule = new KeyTermRule(); rule.id = "Jesus"; rule.Alternates = new [] { new KeyTermRulesKeyTermRuleAlternate() }; rule.Alternates[0].Name = "Jesus Christ"; rules[rule.id] = rule; KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("Jesus"), new ReadonlyDictionary <string, KeyTermRule>(rules), null); Assert.AreEqual(2, bldr.Matches.Count()); VerifyKeyTermMatch(bldr, 0, "jesus", "christ"); VerifyKeyTermMatch(bldr, 1, "jesus"); }
public void RuleToReplaceOriginalTermWithAlternates_PreventFurtherParsingOfAlts() { Dictionary <string, KeyTermRule> rules = new Dictionary <string, KeyTermRule>(); KeyTermRule rule = new KeyTermRule(); rule.id = "fast; fasting"; rule.Rule = KeyTermRule.RuleType.Exclude; rule.Alternates = new[] { new KeyTermRulesKeyTermRuleAlternate(), new KeyTermRulesKeyTermRuleAlternate() }; rule.Alternates[0].Name = "to fast"; rule.Alternates[1].Name = "fast or pray"; rules[rule.id] = rule; KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm(rule.id), new ReadonlyDictionary <string, KeyTermRule>(rules), null); Assert.AreEqual(2, bldr.Matches.Count()); VerifyKeyTermMatch(bldr, 0, true, "to", "fast"); VerifyKeyTermMatch(bldr, 1, true, "fast", "or", "pray"); }
public void RuleToLimitMatchToTermRefs() { Dictionary <string, KeyTermRule> rules = new Dictionary <string, KeyTermRule>(); KeyTermRule rule = new KeyTermRule(); rule.id = "ask"; rule.Rule = KeyTermRule.RuleType.MatchForRefOnly; rules[rule.id] = rule; KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm(rule.id, 34), new ReadonlyDictionary <string, KeyTermRule>(rules), null); Assert.AreEqual(1, bldr.Matches.Count()); KeyTermMatch ktm = VerifyKeyTermMatch(bldr, 0, false, "ask"); Assert.IsFalse(ktm.AppliesTo(30, 33)); Assert.IsTrue(ktm.AppliesTo(34, 34)); Assert.IsFalse(ktm.AppliesTo(35, 39)); }
public void RuleToReplaceOriginalTermWithAlternates_AltWithMatchForRefOnly() { Dictionary <string, KeyTermRule> rules = new Dictionary <string, KeyTermRule>(); KeyTermRule rule = new KeyTermRule(); rule.id = "ask; pray"; rule.Rule = KeyTermRule.RuleType.Exclude; rule.Alternates = new[] { new KeyTermRulesKeyTermRuleAlternate(), new KeyTermRulesKeyTermRuleAlternate() }; rule.Alternates[0].Name = "ask"; rule.Alternates[0].MatchForRefOnly = true; rule.Alternates[1].Name = "pray"; rules[rule.id] = rule; KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm(rule.id), new ReadonlyDictionary <string, KeyTermRule>(rules), null); Assert.AreEqual(2, bldr.Matches.Count()); VerifyKeyTermMatch(bldr, 0, false, "ask"); VerifyKeyTermMatch(bldr, 1, true, "pray"); }
public void RuleToReplaceOriginalTermWithAlternates_Basic() { Dictionary <string, KeyTermRule> rules = new Dictionary <string, KeyTermRule>(); KeyTermRule rule = new KeyTermRule(); rule.id = "to lift up (one's hand, heart, or soul) = to worship, pray"; rule.Rule = KeyTermRule.RuleType.Exclude; rule.Alternates = new[] { new KeyTermRulesKeyTermRuleAlternate(), new KeyTermRulesKeyTermRuleAlternate(), new KeyTermRulesKeyTermRuleAlternate() }; rule.Alternates[0].Name = "worship"; rule.Alternates[1].Name = "praise exuberantly"; rule.Alternates[2].Name = "pray"; rules[rule.id] = rule; KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm(rule.id), new ReadonlyDictionary <string, KeyTermRule>(rules), null); Assert.AreEqual(3, bldr.Matches.Count()); VerifyKeyTermMatch(bldr, 0, "worship"); VerifyKeyTermMatch(bldr, 1, "praise", "exuberantly"); VerifyKeyTermMatch(bldr, 2, "pray"); }