예제 #1
0
        /// <summary>
        /// Caches a possibility label for each analysis occurrence that a tag applies to.
        /// </summary>
        /// <param name="ttag"></param>
        /// <returns></returns>
        internal void CacheTagString(ITextTag ttag)
        {
            var occurrences = ttag.GetOccurrences();
            var cwordArray  = occurrences.Count;

            if (cwordArray == 0)
            {
                return;                 // No words tagged! Again... shouldn't happen. :)
            }
            var       tagPossibility = ttag.TagRA;
            ITsString label;

            if (tagPossibility == null)
            {
                label = m_emptyAnalysisStr;
            }
            else
            {
                label = tagPossibility.Abbreviation.BestAnalysisAlternative;
            }

            // use 'for' loop because we need to know when we're at the beginning
            // and end of the loop
            for (var i = 0; i < cwordArray; i++)
            {
                // TODO: Someday when we handle more than one layer of tagging, this may change!
                var current = occurrences[i];
                if (current == null || !current.IsValid)
                {
                    continue;                     // Shouldn't happen...
                }
                var strBldr = label.GetBldr();
                if (i == 0)                 // First occurrence for this tag.
                {
                    StartTagSetup(strBldr);
                }
                else                 // Until someone has a better idea, only show the label on the first occurrence.
                                     // but I have a feeling the label will be shown on the left-most occurrence
                                     // whether it's a RTL or LTR language!
                {
                    //strBldr.Clear(); This didn't keep the WS!
                    label   = m_emptyAnalysisStr;
                    strBldr = label.GetBldr();
                }
                if (i == cwordArray - 1)                 // Last occurrence for this tag.
                {
                    EndTagSetup(strBldr);
                }
                var key = GetDictKey(current);
                if (m_tagStrings.ContainsKey(key))
                {
                    m_tagStrings.Remove(key);
                }
                m_tagStrings[key] = strBldr.GetString();
            }
        }
예제 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares TextTags in two segments to see if they are similar enough to be considered
		/// the same. Mostly designed for testing, but in production code because it has some
		/// application in charting (searches?). Tests wordforms tagged for same baseline text
		/// and checks to see that they both reference the same CmPossibility tag.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool IsAnalogousTo(ITextTag otherTag)
		{
			if (otherTag == null)
				return false;
			if (this.TagRA != otherTag.TagRA)
				return false;
			var myWordforms = this.GetOccurrences();
			var otherWordforms = otherTag.GetOccurrences();
			if (myWordforms == null || otherWordforms == null)
				throw new ArgumentException("Found an invalid TextTag.");
			if (myWordforms.Count != otherWordforms.Count)
				return false;
			// Below LINQ returns false if it finds any tagged wordforms in the two lists
			// that have different baseline text (at the same index)
			return !myWordforms.Where((t, i) => t.BaselineText.Text != otherWordforms[i].BaselineText.Text).Any();
		}
예제 #3
0
 /// <summary>
 /// Protected virtual so the testing subclass doesn't have to know about Views.
 /// </summary>
 /// <param name="textTag"></param>
 protected virtual void CacheNullTagString(ITextTag textTag)
 {
     // Cache a string for each occurrence this tag references. (PropChanged?)
     (m_vc as InterlinTaggingVc).CacheNullTagString(textTag.GetOccurrences());
 }
예제 #4
0
		/// <summary>
		/// Caches a possibility label for each analysis occurrence that a tag applies to.
		/// </summary>
		/// <param name="ttag"></param>
		/// <returns></returns>
		internal void CacheTagString(ITextTag ttag)
		{
			var occurrences = ttag.GetOccurrences();
			var cwordArray = occurrences.Count;
			if (cwordArray == 0)
				return; // No words tagged! Again... shouldn't happen. :)

			var tagPossibility = ttag.TagRA;
			ITsString label;
			if (tagPossibility == null)
				label = m_emptyAnalysisStr;
			else
				label = tagPossibility.Abbreviation.BestAnalysisAlternative;

			// use 'for' loop because we need to know when we're at the beginning
			// and end of the loop
			for(var i=0; i < cwordArray; i++)
			{
				// TODO: Someday when we handle more than one layer of tagging, this may change!
				var current = occurrences[i];
				if (current == null || !current.IsValid)
					continue; // Shouldn't happen...
				var strBldr = label.GetBldr();
				if (i == 0) // First occurrence for this tag.
				{
					StartTagSetup(strBldr);
				}
				else // Until someone has a better idea, only show the label on the first occurrence.
					// but I have a feeling the label will be shown on the left-most occurrence
					// whether it's a RTL or LTR language!
				{
					//strBldr.Clear(); This didn't keep the WS!
					label = m_emptyAnalysisStr;
					strBldr = label.GetBldr();
				}
				if (i == cwordArray - 1) // Last occurrence for this tag.
					EndTagSetup(strBldr);
				var key = GetDictKey(current);
				if (m_tagStrings.ContainsKey(key))
					m_tagStrings.Remove(key);
				m_tagStrings[key] = strBldr.GetString();
			}
		}
예제 #5
0
		/// <summary>
		/// Protected virtual so the testing subclass doesn't have to know about Views.
		/// </summary>
		/// <param name="textTag"></param>
		protected virtual void CacheNullTagString(ITextTag textTag)
		{
			// Cache a string for each occurrence this tag references. (PropChanged?)
			(m_vc as InterlinTaggingVc).CacheNullTagString(textTag.GetOccurrences());
		}