GetReferences() public method

Get all instances of the item being checked in the token list passed. This includes both valid and invalid instances. This is used 1) to create an inventory of these items. To show the user all instance of an item with a specified key. 2) With a "desiredKey" in order to fetch instance of a specific item (e.g. all the places where "the" is a repeated word.
public GetReferences ( IEnumerable tokens, string desiredKey ) : List
tokens IEnumerable Tokens for text to be scanned
desiredKey string If you only want instance of a specific key (e.g. one word, /// one punctuation pattern, one character, etc.) place it here. Empty string returns /// all items.
return List
Ejemplo n.º 1
0
        public void ChangeCharacterCategorizerAfterInstantiationOfCheck()
        {
            MixedCapitalizationCheck check = new MixedCapitalizationCheck(m_source);

            m_source.Text = @"\p \v 1 w!Forming";

            List <TextTokenSubstring> tts = check.GetReferences(m_source.TextTokens(), null);

            Assert.AreEqual(0, tts.Count);

            m_source.m_extraWordFormingCharacters = "!";

            tts = check.GetReferences(m_source.TextTokens(), null);

            Assert.AreEqual(1, tts.Count);
            Assert.AreEqual("w!Forming", tts[0].Text);
        }
		void Test(string[] result, string text, string desiredKey)
		{
			m_source.Text = text;

			MixedCapitalizationCheck check = new MixedCapitalizationCheck(m_source);
			List<TextTokenSubstring> tts =
				check.GetReferences(m_source.TextTokens(), desiredKey);

			Assert.AreEqual(result.GetUpperBound(0)+1, tts.Count,
				"A different number of results was returned than what was expected." );

			for (int i = 0; i <= result.GetUpperBound(0); ++i)
				Assert.AreEqual(result[i], tts[i].InventoryText, "Result number: " + i.ToString());
		}
Ejemplo n.º 3
0
        void Test(string[] result, string text, string desiredKey)
        {
            m_source.Text = text;

            MixedCapitalizationCheck  check = new MixedCapitalizationCheck(m_source);
            List <TextTokenSubstring> tts   =
                check.GetReferences(m_source.TextTokens(), desiredKey);

            Assert.AreEqual(result.GetUpperBound(0) + 1, tts.Count,
                            "A different number of results was returned than what was expected.");

            for (int i = 0; i <= result.GetUpperBound(0); ++i)
            {
                Assert.AreEqual(result[i], tts[i].InventoryText, "Result number: " + i.ToString());
            }
        }
		public void ChangeCharacterCategorizerAfterInstantiationOfCheck()
		{
			MixedCapitalizationCheck check = new MixedCapitalizationCheck(m_source);

			m_source.Text = @"\p \v 1 w!Forming";

			List<TextTokenSubstring> tts = check.GetReferences(m_source.TextTokens(), null);

			Assert.AreEqual(0, tts.Count);

			m_source.m_extraWordFormingCharacters = "!";

			tts = check.GetReferences(m_source.TextTokens(), null);

			Assert.AreEqual(1, tts.Count);
			Assert.AreEqual("w!Forming", tts[0].Text);
		}