public void RealData7()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("someone who sins against someone else and therefore 'owes' that person"));

            Assert.AreEqual(1, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "someone", "who", "sins", "against", "someone", "else", "and", "therefore", "owes", "that", "person");
        }
		public void OptionalLeadingWord()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(fun) stuff"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "stuff");
			VerifyKeyTermMatch(bldr, 1, "fun", "stuff");
		}
        public void TwoWordKeyTerm()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("fun stuff"));

            Assert.AreEqual(1, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "fun", "stuff");
        }
		public void TwoWordKeyTermWithImplicitOptionalInfinitiveMarker()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to cry"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "cry");
			VerifyKeyTermMatch(bldr, 1, "to", "cry");
		}
예제 #5
0
		public void CanRenderingBeDeleted_NonExistentRendering()
		{
			IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("having a blast");
			ktFun.Stub(kt => kt.Renderings).Return(new[] { "abc" });
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(ktFun);
			KeyTermMatch matchFun = bldr.Matches.First();
			Assert.IsFalse(matchFun.CanRenderingBeDeleted("xyz"));
		}
예제 #6
0
		public void AddRenderingFailsToAddDuplicate()
		{
			IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("good times");
			ktFun.Stub(kt => kt.Renderings).Return(new[] { "abc", "xyz" });
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(ktFun);
			KeyTermMatch matchFun = bldr.Matches.First();
			Assert.Throws(typeof(ArgumentException), () => matchFun.AddRendering("abc"));
		}
        public void OptionalPhrase()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(things of this) life"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "life");
            VerifyKeyTermMatch(bldr, 1, "things", "of", "this", "life");
        }
예제 #8
0
		public void GetNormalRenderings()
		{
			IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("diversion");
			ktFun.Stub(kt => kt.Renderings).Return(new [] {"abc", "xyz"});
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(ktFun);
			KeyTermMatch matchFun = bldr.Matches.First();
			Assert.IsTrue(matchFun.Renderings.SequenceEqual(ktFun.Renderings));
		}
        public void RealData12()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("olive oil (used as food"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "olive", "oil");
            VerifyKeyTermMatch(bldr, 1, "olive", "oil", "used", "as", "food");
        }
        public void OptionalInitialPart()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(loving)kindness"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "kindness");
            VerifyKeyTermMatch(bldr, 1, "lovingkindness");
        }
        public void RealData6()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("exempt, free from"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "exempt");
            VerifyKeyTermMatch(bldr, 1, "free", "from");
        }
        public void RealData4()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("Canaanean = Zealot"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "canaanean");
            VerifyKeyTermMatch(bldr, 1, "zealot");
        }
        public void RealData8()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("state of fearing, standing in awe"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "state", "of", "fearing");
            VerifyKeyTermMatch(bldr, 1, "standing", "in", "awe");
        }
        public void OptionalTrailingWord()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("morning (star)"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "morning");
            VerifyKeyTermMatch(bldr, 1, "morning", "star");
        }
        public void OptionalMiddlePart()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("anti(dis)establishment"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "antiestablishment");
            VerifyKeyTermMatch(bldr, 1, "antidisestablishment");
        }
        public void RealDataWithOr1()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("courtyard or sheepfold"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "courtyard");
            VerifyKeyTermMatch(bldr, 1, "sheepfold");
        }
        public void RealData14()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(one's own) burial-place"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "burial-place");
            VerifyKeyTermMatch(bldr, 1, "one's", "own", "burial-place");
        }
        public void OptionalFinal()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("kind(ness)"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "kind");
            VerifyKeyTermMatch(bldr, 1, "kindness");
        }
        public void RealDataWithOr2()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("give up or lay aside what one possesses"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "give", "up", "what", "one", "possesses");
            VerifyKeyTermMatch(bldr, 1, "lay", "aside", "what", "one", "possesses");
        }
        public void RealDataWithOr4()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("and the flowers are white or pink. The whole plant gives off an agreeable odour"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "and", "the", "flowers", "are", "white", "off", "an", "agreeable", "odour");
            VerifyKeyTermMatch(bldr, 1, "pink.", "the", "whole", "plant", "gives", "off", "an", "agreeable", "odour");
        }
        public void TwoWordKeyTermWithImplicitOptionalInfinitiveMarker()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to cry"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "cry");
            VerifyKeyTermMatch(bldr, 1, "to", "cry");
        }
        public void OptionalLeadingWord()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(fun) stuff"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "stuff");
            VerifyKeyTermMatch(bldr, 1, "fun", "stuff");
        }
        public void RealData5()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("dreadful event or sight"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "dreadful", "event");
            VerifyKeyTermMatch(bldr, 1, "dreadful", "sight");
        }
        public void RealData1()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("worm, maggot"));

            Assert.AreEqual(2, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "worm");
            VerifyKeyTermMatch(bldr, 1, "maggot");
        }
        public void RealData13()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(Lord, LORD, God of) hosts"));

            Assert.AreEqual(3, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "hosts");
            VerifyKeyTermMatch(bldr, 1, "lord", "of", "hosts");
            VerifyKeyTermMatch(bldr, 2, "god", "of", "hosts");
        }
        public void RealData2()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("castor oil plant (FF 106, 107)"));

            Assert.LessOrEqual(1, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "castor", "oil", "plant");
            // Ideally, we don't want to get anything for the junk in parentheses, but it
            // shouldn't really hurt anything, so we'll live with it.
        }
        public void RealData9()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to be favorably disposed to someone, or to experience an emotion of compassion towards other people"));

            Assert.AreEqual(4, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "be", "favorably", "disposed", "to", "someone");
            VerifyKeyTermMatch(bldr, 1, "to", "be", "favorably", "disposed", "to", "someone");
            VerifyKeyTermMatch(bldr, 2, "experience", "an", "emotion", "of", "compassion", "towards", "other", "people");
            VerifyKeyTermMatch(bldr, 3, "to", "experience", "an", "emotion", "of", "compassion", "towards", "other", "people");
        }
        public void RealDataWithOr3()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to perform the ritual of removing the state of guilt or uncleanness from oneself"));

            Assert.AreEqual(4, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "perform", "the", "ritual", "of", "removing", "the", "state", "of", "guilt");
            VerifyKeyTermMatch(bldr, 1, "to", "perform", "the", "ritual", "of", "removing", "the", "state", "of", "guilt");
            VerifyKeyTermMatch(bldr, 2, "perform", "the", "ritual", "of", "removing", "the", "uncleanness", "from", "oneself");
            VerifyKeyTermMatch(bldr, 3, "to", "perform", "the", "ritual", "of", "removing", "the", "uncleanness", "from", "oneself");
        }
예제 #29
0
        public void GetNormalRenderings()
        {
            IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("diversion");

            ktFun.Stub(kt => kt.Renderings).Return(new [] { "abc", "xyz" });
            KeyTermMatchBuilder bldr     = new KeyTermMatchBuilder(ktFun);
            KeyTermMatch        matchFun = bldr.Matches.First();

            Assert.IsTrue(matchFun.Renderings.SequenceEqual(ktFun.Renderings));
        }
예제 #30
0
        public void CanRenderingBeDeleted_NonExistentRendering()
        {
            IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("having a blast");

            ktFun.Stub(kt => kt.Renderings).Return(new[] { "abc" });
            KeyTermMatchBuilder bldr     = new KeyTermMatchBuilder(ktFun);
            KeyTermMatch        matchFun = bldr.Matches.First();

            Assert.IsFalse(matchFun.CanRenderingBeDeleted("xyz"));
        }
예제 #31
0
        public void AddRenderingFailsToAddDuplicate()
        {
            IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("good times");

            ktFun.Stub(kt => kt.Renderings).Return(new[] { "abc", "xyz" });
            KeyTermMatchBuilder bldr     = new KeyTermMatchBuilder(ktFun);
            KeyTermMatch        matchFun = bldr.Matches.First();

            Assert.Throws(typeof(ArgumentException), () => matchFun.AddRendering("abc"));
        }
        public void RealData3()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(loving)kindness, solidarity, joint liability, grace"));

            Assert.AreEqual(5, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "kindness");
            VerifyKeyTermMatch(bldr, 1, "lovingkindness");
            VerifyKeyTermMatch(bldr, 2, "solidarity");
            VerifyKeyTermMatch(bldr, 3, "joint", "liability");
            VerifyKeyTermMatch(bldr, 4, "grace");
        }
        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"), rules);

            Assert.AreEqual(0, bldr.Matches.Count());
        }
예제 #34
0
        public void CanRenderingBeDeleted_DefaultRendering()
        {
            IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("time of my life");

            ktFun.Stub(kt => kt.Renderings).Return(new[] { "abc" });
            KeyTermMatchBuilder bldr     = new KeyTermMatchBuilder(ktFun);
            KeyTermMatch        matchFun = bldr.Matches.First();

            matchFun.AddRendering("bestest");
            matchFun.BestRendering = "bestest";
            Assert.IsFalse(matchFun.CanRenderingBeDeleted("bestest"));
        }
        public void RealData10()
        {
            KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to recompense, to reward, to pay"));

            Assert.AreEqual(6, bldr.Matches.Count());
            VerifyKeyTermMatch(bldr, 0, "recompense");
            VerifyKeyTermMatch(bldr, 1, "to", "recompense");
            VerifyKeyTermMatch(bldr, 2, "reward");
            VerifyKeyTermMatch(bldr, 3, "to", "reward");
            VerifyKeyTermMatch(bldr, 4, "pay");
            VerifyKeyTermMatch(bldr, 5, "to", "pay");
        }
예제 #36
0
		public void AddAndRemoveRenderings()
		{
			IKeyTerm ktFun = KeyTermMatchBuilderTests.AddMockedKeyTerm("fun");
			ktFun.Stub(kt => kt.Renderings).Return(new [] { "abc", "xyz" });
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(ktFun);
			KeyTermMatch matchFun = bldr.Matches.First();
			matchFun.AddRendering("wunkyboo");
			Assert.AreEqual(3, matchFun.Renderings.Count());
			Assert.IsTrue(matchFun.Renderings.Contains("wunkyboo"));
			Assert.IsTrue(matchFun.CanRenderingBeDeleted("wunkyboo"));
			Assert.IsFalse(matchFun.CanRenderingBeDeleted("abc"));
			matchFun.DeleteRendering("wunkyboo");
			Assert.IsFalse(matchFun.Renderings.Contains("wunkyboo"));
		}
예제 #37
0
		public void TwoWordKeyTerm()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("fun stuff"));
			Assert.AreEqual(1, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "fun", "stuff");
		}
예제 #38
0
		public void RealData11()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to lift up (one's hand, heart, or soul) = to worship, pray"));
			Assert.AreEqual(7, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "lift", "up");
			VerifyKeyTermMatch(bldr, 1, "to", "lift", "up");
			VerifyKeyTermMatch(bldr, 2, "lift", "up", "one's", "hand", "heart", "soul");
			VerifyKeyTermMatch(bldr, 3, "to", "lift", "up", "one's", "hand", "heart", "soul");
			VerifyKeyTermMatch(bldr, 4, "worship");
			VerifyKeyTermMatch(bldr, 5, "to", "worship");
			VerifyKeyTermMatch(bldr, 6, "pray");
		}
예제 #39
0
		public void RealData10()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to recompense, to reward, to pay"));
			Assert.AreEqual(6, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "recompense");
			VerifyKeyTermMatch(bldr, 1, "to", "recompense");
			VerifyKeyTermMatch(bldr, 2, "reward");
			VerifyKeyTermMatch(bldr, 3, "to", "reward");
			VerifyKeyTermMatch(bldr, 4, "pay");
			VerifyKeyTermMatch(bldr, 5, "to", "pay");
		}
예제 #40
0
		public void RealData13()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(Lord, LORD, God of) hosts"));
			Assert.AreEqual(3, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "hosts");
			VerifyKeyTermMatch(bldr, 1, "lord", "of", "hosts");
			VerifyKeyTermMatch(bldr, 2, "god", "of", "hosts");
		}
예제 #41
0
		public void RealData12()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("olive oil (used as food"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "olive", "oil");
			VerifyKeyTermMatch(bldr, 1, "olive", "oil", "used", "as", "food");
		}
예제 #42
0
		public void RealData7()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("someone who sins against someone else and therefore 'owes' that person"));
			Assert.AreEqual(1, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "someone", "who", "sins", "against", "someone", "else", "and", "therefore", "owes", "that", "person");
		}
예제 #43
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Verifies the key term match.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private static void VerifyKeyTermMatch(KeyTermMatchBuilder bldr, int iMatch,
			params string[] words)
		{
			VerifyKeyTermMatch(bldr, iMatch, true, words);
		}
예제 #44
0
		public void RealDataWithOr1()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("courtyard or sheepfold"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "courtyard");
			VerifyKeyTermMatch(bldr, 1, "sheepfold");
		}
예제 #45
0
		public void RealData1()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("worm, maggot"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "worm");
			VerifyKeyTermMatch(bldr, 1, "maggot");
		}
예제 #46
0
		public void RuleToReplaceOriginalTermWithAlternates()
		{
			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), rules);
			Assert.AreEqual(3, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "worship");
			VerifyKeyTermMatch(bldr, 1, "praise", "exuberantly");
			VerifyKeyTermMatch(bldr, 2, "pray");
		}
예제 #47
0
		public void RealDataWithOr2()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("give up or lay aside what one possesses"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "give", "up", "what", "one", "possesses");
			VerifyKeyTermMatch(bldr, 1, "lay", "aside", "what", "one", "possesses");
		}
예제 #48
0
		public void RealDataWithOr3()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to perform the ritual of removing the state of guilt or uncleanness from oneself"));
			Assert.AreEqual(4, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "perform", "the", "ritual", "of", "removing", "the", "state", "of", "guilt");
			VerifyKeyTermMatch(bldr, 1, "to", "perform", "the", "ritual", "of", "removing", "the", "state", "of", "guilt");
			VerifyKeyTermMatch(bldr, 2, "perform", "the", "ritual", "of", "removing", "the", "uncleanness", "from", "oneself");
			VerifyKeyTermMatch(bldr, 3, "to", "perform", "the", "ritual", "of", "removing", "the", "uncleanness", "from", "oneself");
		}
예제 #49
0
		public void RealDataWithOr4()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("and the flowers are white or pink. The whole plant gives off an agreeable odour"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "and", "the", "flowers", "are", "white", "off", "an", "agreeable", "odour");
			VerifyKeyTermMatch(bldr, 1, "pink.", "the", "whole", "plant", "gives", "off", "an", "agreeable", "odour");
		}
예제 #50
0
		public void RealData2()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("castor oil plant (FF 106, 107)"));
			Assert.LessOrEqual(1, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "castor", "oil", "plant");
			// Ideally, we don't want to get anything for the junk in parentheses, but it
			// shouldn't really hurt anything, so we'll live with it.
		}
예제 #51
0
		public void RealData9()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("to be favorably disposed to someone, or to experience an emotion of compassion towards other people"));
			Assert.AreEqual(4, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "be", "favorably", "disposed", "to", "someone");
			VerifyKeyTermMatch(bldr, 1, "to", "be", "favorably", "disposed", "to", "someone");
			VerifyKeyTermMatch(bldr, 2, "experience", "an", "emotion", "of", "compassion", "towards", "other", "people");
			VerifyKeyTermMatch(bldr, 3, "to", "experience", "an", "emotion", "of", "compassion", "towards", "other", "people");
		}
예제 #52
0
		public void RealData5()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("dreadful event or sight"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "dreadful", "event");
			VerifyKeyTermMatch(bldr, 1, "dreadful", "sight");
		}
예제 #53
0
		public void RealData8()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("state of fearing, standing in awe"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "state", "of", "fearing");
			VerifyKeyTermMatch(bldr, 1, "standing", "in", "awe");
		}
예제 #54
0
		public void RealData4()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("Canaanean = Zealot"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "canaanean");
			VerifyKeyTermMatch(bldr, 1, "zealot");
		}
예제 #55
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Populates the key terms table.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void PopulateKeyTermsTable(IEnumerable<IKeyTerm> keyTerms, KeyTermRules rules)
		{
			Dictionary<string, KeyTermRule> ktRules = new Dictionary<string, KeyTermRule>();
			if (rules != null)
			{
				foreach (KeyTermRule keyTermRule in rules.Items.Where(keyTermRule => !String.IsNullOrEmpty(keyTermRule.id)))
					ktRules[keyTermRule.id] = keyTermRule;
			}

			KeyTermMatchBuilder matchBuilder;

			foreach (IKeyTerm keyTerm in keyTerms)
			{
				matchBuilder = new KeyTermMatchBuilder(keyTerm, ktRules);

				foreach (KeyTermMatch matcher in matchBuilder.Matches)
				{
					if (!matcher.Words.Any())
						continue;

					List<KeyTermMatch> foundMatchers;
					Word firstWord = matcher.Words.First();
					if (!m_keyTermsTable.TryGetValue(firstWord, out foundMatchers))
						m_keyTermsTable[firstWord] = foundMatchers = new List<KeyTermMatch>();

					KeyTermMatch existingMatcher = foundMatchers.FirstOrDefault(m => m.Equals(matcher));
					if (existingMatcher == null)
						foundMatchers.Add(matcher);
					else
						existingMatcher.AddTerm(keyTerm);
				}
			}
		}
예제 #56
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Verifies the key term match.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private static KeyTermMatch VerifyKeyTermMatch(KeyTermMatchBuilder bldr, int iMatch,
			bool matchAnywhere, params string[] words)
		{
			KeyTermMatch ktm = bldr.Matches.ElementAt(iMatch);
			Assert.AreEqual(words.Length, ktm.Words.Count());
			for (int i = 0; i < words.Length; i++)
				Assert.AreEqual(words[i], ktm.Words.ElementAt(i).Text);
			if (matchAnywhere)
			{
				Random r = new Random(DateTime.Now.Millisecond);
				Assert.IsTrue(ktm.AppliesTo(r.Next(), r.Next()));
			}
			return ktm;
		}
예제 #57
0
		public void RealData6()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("exempt, free from"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "exempt");
			VerifyKeyTermMatch(bldr, 1, "free", "from");
		}
예제 #58
0
		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), rules);
			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));
		}
예제 #59
0
		public void RealData3()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(loving)kindness, solidarity, joint liability, grace"));
			Assert.AreEqual(5, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "kindness");
			VerifyKeyTermMatch(bldr, 1, "lovingkindness");
			VerifyKeyTermMatch(bldr, 2, "solidarity");
			VerifyKeyTermMatch(bldr, 3, "joint", "liability");
			VerifyKeyTermMatch(bldr, 4, "grace");
		}
예제 #60
0
		public void RealData14()
		{
			KeyTermMatchBuilder bldr = new KeyTermMatchBuilder(AddMockedKeyTerm("(one's own) burial-place"));
			Assert.AreEqual(2, bldr.Matches.Count());
			VerifyKeyTermMatch(bldr, 0, "burial-place");
			VerifyKeyTermMatch(bldr, 1, "one's", "own", "burial-place");
		}