Check capitalization for styles and sentences.
コード例 #1
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
コード例 #2
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
コード例 #3
0
		public void GetLengthOfChar()
		{
			CapitalizationProcessor processor = new CapitalizationProcessor(m_dataSource, null);

			Assert.AreEqual(1, ReflectionHelper.GetIntResult(processor, "GetLengthOfChar",
				new DummyTextToken("a has no diacritics.", TextType.Verse, true, false,
				"Paragraph"), 0));
			Assert.AreEqual(2, ReflectionHelper.GetIntResult(processor, "GetLengthOfChar",
				new DummyTextToken("a\u0303 has a tilde.", TextType.Verse, true, false,
				"Paragraph"), 0));
			Assert.AreEqual(3, ReflectionHelper.GetIntResult(processor, "GetLengthOfChar",
				new DummyTextToken("a\u0303\u0301 has a tilde and grave accent.",
				TextType.Verse, true, false, "Paragraph"), 0));
			Assert.AreEqual(4, ReflectionHelper.GetIntResult(processor, "GetLengthOfChar",
				new DummyTextToken("a\u0303\u0301\u0302 has a tilde, grave accent and circumflex accent.",
				TextType.Verse, true, false, "Paragraph"), 0));
		}