SILUBS.ScriptureChecks.CapitalizationCheck.GetReferences C# (CSharp) Method

GetReferences() public method

Gets the references where capitalization errors occurred.
public GetReferences ( IEnumerable tokens ) : List
tokens IEnumerable The Scripture tokens.
return List
		public List<TextTokenSubstring> GetReferences(IEnumerable<ITextToken> tokens)
		{
//			m_SentenceFinalPunc = m_chkDataSource.GetParameterValue(kSentenceFinalPuncParameter);
			if (m_stylePropsInfo == null)
			{
				string styleInfo = m_chkDataSource.GetParameterValue(kStyleSheetInfoParameter);
				Debug.Assert(!string.IsNullOrEmpty(styleInfo), "Style information not provided.");
				m_stylePropsInfo = StylePropsInfo.Load(styleInfo);
				CreateCapitalStyleDictionary();
				Debug.Assert(m_allCapitalizedStyles.Count > 0, "No styles require capitalization.");
			}

			CapitalizationProcessor bodyPuncProcessor = new CapitalizationProcessor(m_chkDataSource, m_allCapitalizedStyles);
			CapitalizationProcessor notePuncProcessor = new CapitalizationProcessor(m_chkDataSource, m_allCapitalizedStyles);
			notePuncProcessor.ProcessParagraphsSeparately = true;

			m_capitalizationErrors = new List<TextTokenSubstring>();
			VerseTextToken scrTok = new VerseTextToken();

			ITextToken tok;
			foreach (ITextToken token in tokens)
			{
				if (token.TextType == TextType.Note || token.TextType == TextType.PictureCaption)
					tok = token;
				else
				{
					// Make the token one of our special capitalization text tokens.
					scrTok.Token = token;
					tok = scrTok;
				}

				if (tok.TextType == TextType.Note)
					notePuncProcessor.ProcessToken(tok, m_capitalizationErrors);
				else if (tok.TextType == TextType.Verse || tok.TextType == TextType.Other)
					bodyPuncProcessor.ProcessToken(tok, m_capitalizationErrors);
			}

			return m_capitalizationErrors;
		}

Usage Example

		void Test(string[] result, string text)
		{
			source.Text = text;

			source.SetParameterValue("StylesInfo", stylesInfo);
			source.SetParameterValue("SentenceFinalPunctuation", ".!?");
			CapitalizationCheck check = new CapitalizationCheck(source);
			List<TextTokenSubstring> tts =
				check.GetReferences(source.TextTokens());

			Assert.AreEqual(result.Length, tts.Count,
				"A different number of results was returned from what was expected." );

			for (int i = 0; i < result.Length; i++)
				Assert.AreEqual(result[i], tts[i].InventoryText, "Result number: " + i);
		}
All Usage Examples Of SILUBS.ScriptureChecks.CapitalizationCheck::GetReferences