SILUBS.ScriptureChecks.ProcessMatchedPairTokens.ProcessToken C# (CSharp) Method

ProcessToken() public method

public ProcessToken ( ITextToken tok, string desiredKey, List result ) : void
tok ITextToken
desiredKey string
result List
return void
		public void ProcessToken(ITextToken tok, string desiredKey, List<TextTokenSubstring> result)
		{
			if (AnyFoundPairsClosedByPara && tok.IsParagraphStart &&
				!m_styleCategorizer.IsPoeticStyle(tok.ParaStyleName))
			{
				FinalizeResult(desiredKey, result);
			}

			for (int i = 0; i < tok.Text.Length; i++)
			{
				string cc = tok.Text.Substring(i, 1);
				if (m_pairList.BelongsToPair(cc))
				{
					StoreFoundPairToken(tok, i);
					RemoveMatchedPunctAtEndOfFirstWordInIntroOutline(tok, i);
					RemoveIfMatchedPairFound();
					RecordOverlappingPairs();
				}
			}
		}

Usage Example

Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public List <TextTokenSubstring> GetReferences(IEnumerable <ITextToken> tokens, string desiredKey)
        {
#if DEBUG
            List <ITextToken> AllTokens = new List <ITextToken>(tokens);
            if (AllTokens.Count == 0)
            {
                // Keep the compiler from complaining about assigning to a variable, but not using it.
            }
#endif
//			m_characterCategorizer = m_checksDataSource.CharacterCategorizer;
            ValidItems   = m_checksDataSource.GetParameterValue(kValidItemsParameter);
            InvalidItems = m_checksDataSource.GetParameterValue(kInvalidItemsParameter);

            string preferredLocale =
                m_checksDataSource.GetParameterValue("PreferredLocale") ?? string.Empty;

            string poeticStyles =
                m_checksDataSource.GetParameterValue("PoeticStyles");

            string introductionOutlineStyles =
                m_checksDataSource.GetParameterValue("IntroductionOutlineStyles");

            MatchedPairList pairList =
                MatchedPairList.Load(m_checksDataSource.GetParameterValue("MatchedPairs"),
                                     m_checksDataSource.GetParameterValue("DefaultWritingSystemName"));

            StyleCategorizer styleCategorizer =
                new StyleCategorizer(poeticStyles, introductionOutlineStyles);

            ProcessMatchedPairTokens bodyProcessor = new ProcessMatchedPairTokens(
                m_checksDataSource, pairList, styleCategorizer);

            ProcessMatchedPairTokens noteProcessor = new ProcessMatchedPairTokens(
                m_checksDataSource, pairList, styleCategorizer);

            m_unmatchedPairs = new List <TextTokenSubstring>();

            foreach (ITextToken tok in tokens)
            {
                if (tok.Text == null || (tok.Locale ?? string.Empty) != preferredLocale)
                {
                    continue;
                }

                if (tok.TextType == TextType.Note)
                {
                    // if a new note is starting finalize any sequences from the previous note
                    if (tok.IsNoteStart)
                    {
                        noteProcessor.FinalizeResult(desiredKey, m_unmatchedPairs);
                    }
                    noteProcessor.ProcessToken(tok, desiredKey, m_unmatchedPairs);
                }
                else if (tok.TextType == TextType.Verse || tok.TextType == TextType.Other || tok.IsParagraphStart)
                {
                    // body text: finalize any note that was in progress and continue with body text
                    noteProcessor.FinalizeResult(desiredKey, m_unmatchedPairs);
                    bodyProcessor.ProcessToken(tok, desiredKey, m_unmatchedPairs);
                }
            }

            noteProcessor.FinalizeResult(desiredKey, m_unmatchedPairs);
            bodyProcessor.FinalizeResult(desiredKey, m_unmatchedPairs);

            return(m_unmatchedPairs);
        }
All Usage Examples Of SILUBS.ScriptureChecks.ProcessMatchedPairTokens::ProcessToken