/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the specified Scripture tokens for capitalization within styles. /// </summary> /// <param name="toks">The tokens from scripture.</param> /// <param name="record">The record.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { GetReferences(toks); foreach (TextTokenSubstring tts in m_capitalizationErrors) { record(new RecordErrorEventArgs(tts, CheckId)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="toks"></param> /// <param name="record"></param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { m_unmatchedPairs = GetReferences(toks, string.Empty); foreach (TextTokenSubstring tts in m_unmatchedPairs) { if (!m_validItemsList.Contains(tts.ToString())) { record(new RecordErrorEventArgs(tts, CheckId)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Execute the check. Call 'RecordError' for every error found. /// </summary> /// <param name="toks">ITextTokens corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { m_mixedCapitalization = GetReferences(toks, string.Empty); string msg = Localize("Word has mixed capitalization"); foreach (TextTokenSubstring tts in m_mixedCapitalization) { if (!m_validItemsList.Contains(tts.ToString())) { tts.Message = msg; record(new RecordErrorEventArgs(tts, CheckId)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Find all repeated words. Ignore any found in 'validItemsList'. Call RecordError /// delegate whenever any other repeated key is found. /// </summary> /// <param name="toks">ITextToken's corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { // Find all repeated words. Put them in 'm_repeatedWords'. GetReferences(toks, string.Empty); string msg = Localize("Repeated word"); foreach (TextTokenSubstring tts in m_repeatedWords) { if (!goodWords.Contains(tts.ToString())) { tts.Message = msg; record(new RecordErrorEventArgs(tts, CheckId)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Runs the Characters Scripture checks. /// </summary> /// <param name="toks">The Scripture tokens to check.</param> /// <param name="record">Method to record the error.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { // This method is called in ScrChecksDataSource.cs - RunCheck(IScriptureCheck check) m_categorizer = m_checksDataSource.CharacterCategorizer; // Get parameters needed to run this check. GetParameters(); // Find all invalid characters and place them in 'm_characterSequences' GetReferences(toks, string.Empty, true); foreach (TextTokenSubstring tts in m_characterSequences) { tts.Message = (tts.ToString().Length > 1) ? m_checksDataSource.GetLocalizedString("Invalid or unknown character diacritic combination") : m_checksDataSource.GetLocalizedString("Invalid or unknown character"); record(new RecordErrorEventArgs(tts, CheckId)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Execute the check. Call 'RecordError' for every error found. /// </summary> /// <param name="toks">ITextToken's corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { m_punctuationSequences = GetReferences(toks, string.Empty); string msgInvalid = Localize("Invalid punctuation pattern"); string msgUnspecified = Localize("Unspecified use of punctuation pattern"); foreach (TextTokenSubstring tts in m_punctuationSequences) { string punctCharacter = tts.InventoryText; if (!m_validItemsList.Contains(punctCharacter)) { tts.Message = m_invalidItemsList.Contains(punctCharacter) ? msgInvalid : msgUnspecified; record(new RecordErrorEventArgs(tts, CheckId)); } } }
public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { throw new NotImplementedException(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:ChapterVerseCheck"/> class. This /// overload of the constructor is only used for testing. /// </summary> /// <param name="checksDataSource">The checks data source.</param> /// <param name="recErrHandler">The error recording handler.</param> /// ------------------------------------------------------------------------------------ public ChapterVerseCheck(IChecksDataSource checksDataSource, RecordErrorHandler recErrHandler) { m_checksDataSource = checksDataSource; m_recordError = recErrHandler; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the given tokens for chapter/verse errors and calls the given RecordError /// handler for each one. /// </summary> /// <param name="toks">The tokens to check.</param> /// <param name="record">Method to call to record errors.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { GetParameters(); m_recordError = record; m_versesFound = new List <int>(); m_chapTokens.Clear(); ChapterToken currChapterToken = null; VerseToken currVerseToken = null; foreach (ITextToken token in toks) { // This token is only necessary when a chapter one is missing // and we need a token to use for reporting that it's missing. if (m_fallbackToken == null) { m_fallbackToken = token; } if (token.TextType == TextType.ChapterNumber) { currChapterToken = new ChapterToken(token, m_chapterNumberFormat); currVerseToken = null; m_chapTokens.Add(currChapterToken); } else if (token.TextType == TextType.VerseNumber) { if (currChapterToken == null) { //assume chapter one currChapterToken = new ChapterToken(token, 1); m_chapTokens.Add(currChapterToken); } currVerseToken = new VerseToken(token); currChapterToken.VerseTokens.Add(currVerseToken); } else if (token.TextType == TextType.Verse) { if (currChapterToken == null) { // no chapter token and no verse number token // oh no! use verse text token as default, but system // should error on missing verse first. if (currVerseToken == null) { //assume chapter one currChapterToken = new ChapterToken(token, 1); m_chapTokens.Add(currChapterToken); //assume verse one currVerseToken = new VerseToken(token, 1); currChapterToken.VerseTokens.Add(currVerseToken); } // no chapter token, but we have verse number token // then use the verse number token else { // this case should not happen because chapter tokens // are automatically created if a verse number token is // encountered first Debug.Assert(false, "verse number token found without chapter number token"); } } else { // we have a chapter token, but no verse number token // use the chapter token as the default token. if (currVerseToken == null) { //assume verse one currVerseToken = new VerseToken(token, 1); currChapterToken.VerseTokens.Add(currVerseToken); } // we have a chapter token, and a verse number token // we are happy else { // do nothing } } currVerseToken.IncrementVerseTextCount(token); } } CheckChapterNumbers(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Execute the check. Call 'RecordError' for every error found. /// </summary> /// <param name="toks">ITextToken's corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { m_punctuationSequences = GetReferences(toks, string.Empty); string msgInvalid = Localize("Invalid punctuation pattern"); string msgUnspecified = Localize("Unspecified use of punctuation pattern"); foreach (TextTokenSubstring tts in m_punctuationSequences) { string punctCharacter = tts.InventoryText; if (!m_validItemsList.Contains(punctCharacter)) { tts.Message = m_invalidItemsList.Contains(punctCharacter) ? msgInvalid : msgUnspecified; record(new RecordErrorEventArgs(tts, CheckId)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Execute the check and call 'RecordError' for every error found. /// </summary> /// <param name="toks">ITextToken's corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { foreach (DummyError error in m_ErrorsToReport) { TextTokenSubstring tts = new TextTokenSubstring(error.m_token, error.m_ichStart, error.m_length, error.m_sMessage); record(new RecordErrorEventArgs(tts, m_checkId)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Runs the Characters Scripture checks. /// </summary> /// <param name="toks">The Scripture tokens to check.</param> /// <param name="record">Method to record the error.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { // This method is called in ScrChecksDataSource.cs - RunCheck(IScriptureCheck check) m_categorizer = m_checksDataSource.CharacterCategorizer; // Get parameters needed to run this check. GetParameters(); // Find all invalid characters and place them in 'm_characterSequences' GetReferences(toks, string.Empty, true); foreach (TextTokenSubstring tts in m_characterSequences) { tts.Message = (tts.ToString().Length > 1) ? m_checksDataSource.GetLocalizedString("Invalid or unknown character diacritic combination") : m_checksDataSource.GetLocalizedString("Invalid or unknown character"); record(new RecordErrorEventArgs(tts, CheckId)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the specified Scripture tokens for capitalization within styles. /// </summary> /// <param name="toks">The tokens from scripture.</param> /// <param name="record">The record.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { GetReferences(toks); foreach (TextTokenSubstring tts in m_capitalizationErrors) record(new RecordErrorEventArgs(tts, CheckId)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the specified tokens. /// </summary> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable <ITextToken> toks, RecordErrorHandler record) { throw new Exception("The method or operation is not implemented."); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the given tokens for chapter/verse errors and calls the given RecordError /// handler for each one. /// </summary> /// <param name="toks">The tokens to check.</param> /// <param name="record">Method to call to record errors.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { GetParameters(); m_recordError = record; // m_versesFound = new List<int>(); m_chapTokens.Clear(); ChapterToken currChapterToken = null; VerseToken currVerseToken = null; foreach (ITextToken token in toks) { // This token is only necessary when a chapter one is missing // and we need a token to use for reporting that it's missing. if (m_fallbackToken == null) m_fallbackToken = token; if (token.TextType == TextType.ChapterNumber) { currChapterToken = new ChapterToken(token, m_chapterNumberFormat); currVerseToken = null; m_chapTokens.Add(currChapterToken); } else if (token.TextType == TextType.VerseNumber) { if (currChapterToken == null) { //assume chapter one currChapterToken = new ChapterToken(token, 1); m_chapTokens.Add(currChapterToken); } currVerseToken = new VerseToken(token); currChapterToken.VerseTokens.Add(currVerseToken); } else if (token.TextType == TextType.Verse) { if (currChapterToken == null) { // no chapter token and no verse number token // oh no! use verse text token as default, but system // should error on missing verse first. if (currVerseToken == null) { //assume chapter one currChapterToken = new ChapterToken( token, 1); m_chapTokens.Add(currChapterToken); //assume verse one currVerseToken = new VerseToken(token, 1); currChapterToken.VerseTokens.Add(currVerseToken); } // no chapter token, but we have verse number token // then use the verse number token else { // this case should not happen because chapter tokens // are automatically created if a verse number token is // encountered first Debug.Assert(false, "verse number token found without chapter number token"); } } else { // we have a chapter token, but no verse number token // use the chapter token as the default token. if (currVerseToken == null) { //assume verse one currVerseToken = new VerseToken(token, 1); currChapterToken.VerseTokens.Add(currVerseToken); } // we have a chapter token, and a verse number token // we are happy else { // do nothing } } currVerseToken.IncrementVerseTextCount(token); } } CheckChapterNumbers(); }
public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { throw new NotImplementedException(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the specified tokens. /// </summary> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { throw new Exception("The method or operation is not implemented."); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Execute the check. Call 'RecordError' for every error found. /// </summary> /// <param name="toks">ITextTokens corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { m_mixedCapitalization = GetReferences(toks, string.Empty); string msg = Localize("Word has mixed capitalization"); foreach (TextTokenSubstring tts in m_mixedCapitalization) { if (!m_validItemsList.Contains(tts.ToString())) { tts.Message = msg; record(new RecordErrorEventArgs(tts, CheckId)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="toks"></param> /// <param name="record"></param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { m_unmatchedPairs = GetReferences(toks, string.Empty); foreach (TextTokenSubstring tts in m_unmatchedPairs) { if (!m_validItemsList.Contains(tts.ToString())) record(new RecordErrorEventArgs(tts, CheckId)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Find all repeated words. Ignore any found in 'validItemsList'. Call RecordError /// delegate whenever any other repeated key is found. /// </summary> /// <param name="toks">ITextToken's corresponding to the text to be checked. /// Typically this is one books worth.</param> /// <param name="record">Call this delegate to report each error found.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { // Find all repeated words. Put them in 'm_repeatedWords'. GetReferences(toks, string.Empty); string msg = Localize("Repeated word"); foreach (TextTokenSubstring tts in m_repeatedWords) { if (!goodWords.Contains(tts.ToString())) { tts.Message = msg; record(new RecordErrorEventArgs(tts, CheckId)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the given tokens for quotation errors. Ignores any found in 'validItemsList'. /// Calls the given RecordError handler for each one. /// </summary> /// <param name="toks">The tokens to check.</param> /// <param name="record">Method to call to record errors.</param> /// ------------------------------------------------------------------------------------ public void Check(IEnumerable<ITextToken> toks, RecordErrorHandler record) { foreach (TextTokenSubstring tts in GetReferences(toks, string.Empty)) { string punctChar = tts.ToString(); if (!m_validItemsList.Contains(punctChar)) record(new RecordErrorEventArgs(tts, CheckId)); } }