/// ------------------------------------------------------------------------------------ /// <summary></summary> /// ------------------------------------------------------------------------------------ public ITextToken Clone() { VerseTextToken verseToken = new VerseTextToken(); verseToken.m_fIsParagraphStart = m_fIsParagraphStart; verseToken.m_token = m_token; return(verseToken); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the references where capitalization errors occurred. /// </summary> /// <param name="tokens">The Scripture tokens.</param> /// <returns>list of capitalization errors.</returns> /// ------------------------------------------------------------------------------------ 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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the references where capitalization errors occurred. /// </summary> /// <param name="tokens">The Scripture tokens.</param> /// <returns>list of capitalization errors.</returns> /// ------------------------------------------------------------------------------------ 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; }
/// ------------------------------------------------------------------------------------ /// <summary></summary> /// ------------------------------------------------------------------------------------ public ITextToken Clone() { VerseTextToken verseToken = new VerseTextToken(); verseToken.m_fIsParagraphStart = m_fIsParagraphStart; verseToken.m_token = m_token; return verseToken; }
/// ------------------------------------------------------------------------------------ /// <summary> /// If the token starts a typographic paragraph, store it as a paragraph-start token and /// highlight (shows up on user interface) its text. Otherwise, if the token is /// a quotation mark (either opening or closing, as defined by the quotation /// categorizer), store it as a quotation mark token. /// </summary> /// <param name="tok">The token being processed</param> /// ------------------------------------------------------------------------------------ internal void ProcessToken(ITextToken tok, VerseTextToken verseTok) { if (tok == null) throw new ArgumentNullException("tok"); Debug.Assert(!(tok is VerseTextToken)); if (tok.IsParagraphStart) { TextTokenSubstring tts = new TextTokenSubstring(tok, 0, 0); ParaStartToken pstok = new ParaStartToken(tts, tok.ParaStyleName); m_quotationRelatedTokens.Add(pstok); } AddTextToParaStartTokens(tok); // Find the first non whitespace, non quotation mark character in the token's // text. This will be used in the following loop to determine what quotation // marks precede all other characters in the token (i.e. what quotation marks // begin the paragraph and are possible continuers). Match match = m_regExNonQuotes.Match(tok.Text); int iFirstNoneQMarkChar = (match.Success ? match.Index : -1); // Now find all the quotation marks in the token's text. MatchCollection mc = m_regExQuotes.Matches(tok.Text); // Go through all the quotation marks found, creating quotation tokens // for each. foreach (Match m in mc) { TextTokenSubstring tts = new TextTokenSubstring(tok, m.Index, m.Length); bool fIsParaStart = verseTok != null ? verseTok.IsParagraphStart : tok.IsParagraphStart; bool fIsOpener = m_qmCategorizer.IsInitialPunctuation(tts.Text); bool fPossibleContinuer = (m.Index < iFirstNoneQMarkChar && fIsParaStart); QuotationMarkToken qmt = new QuotationMarkToken(tts, m_qmCategorizer, fIsOpener, fPossibleContinuer); m_quotationRelatedTokens.Add(qmt); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets a list if TextTokenSubstrings containing the references and character offsets /// where quotation problems occur. /// </summary> /// <param name="tokens">The tokens (from the data source) to check for quotation problems.</param> /// <param name="desiredKey">empty string.</param> /// ------------------------------------------------------------------------------------ public List<TextTokenSubstring> GetReferences(IEnumerable<ITextToken> tokens, string desiredKey) { m_charCategorizer = m_chkDataSource.CharacterCategorizer; ValidItems = m_chkDataSource.GetParameterValue(m_validItemsParameter); InvalidItems = m_chkDataSource.GetParameterValue(m_invalidItemsParameter); QuotationMarkCategorizer qmCategorizer = new QuotationMarkCategorizer(m_chkDataSource); m_qmProblems = new List<TextTokenSubstring>(); QTokenProcessor bodyProcessor = new QTokenProcessor(m_chkDataSource, m_charCategorizer, qmCategorizer, desiredKey, m_qmProblems); QTokenProcessor noteProcessor = new QTokenProcessor(m_chkDataSource, m_charCategorizer, qmCategorizer, desiredKey, m_qmProblems); VerseTextToken scrToken = new VerseTextToken(); foreach (ITextToken tok in tokens) { if (tok.TextType == TextType.Note) { // If a new note is starting finalize any sequences from the previous note. if (tok.IsNoteStart) noteProcessor.FinalizeResult(); noteProcessor.ProcessToken(tok, null); } else if (tok.TextType == TextType.Verse || tok.TextType == TextType.Other || tok.IsParagraphStart) { scrToken.Token = tok; // body text: finalize any note that was in progress and continue with body text noteProcessor.FinalizeResult(); bodyProcessor.ProcessToken(tok, scrToken); } } noteProcessor.FinalizeResult(); bodyProcessor.FinalizeResult(); return m_qmProblems; }