Example #1
0
			private bool IsIdenticalObjectInfo(TwficInfo twficInfo)
			{
				return m_hvoPara != 0 && m_hvoInstanceOf != 0 &&
					twficInfo.Object.BeginObjectRAHvo == m_hvoPara &&
					twficInfo.Object.InstanceOfRAHvo == m_hvoInstanceOf &&
					twficInfo.Object.BeginOffset == m_beginOffset &&
					twficInfo.Object.EndOffset == m_endOffset;
			}
Example #2
0
		/// <summary>
		/// Return the matching segments for the given twfics in order.
		/// We could enhance the performance of this routine, but we currently expect the user
		/// to be trying to identify segments for tons of twfics at one time (for LexExampleSentences).
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="twfics"></param>
		static public List<int> TwficSegments(FdoCache cache, List<int> twfics)
		{
			/*
			 * //Enhancement 1: do an SQL query to find the real segment ides for the given (real) twfics.
			 * // return the segment ids, corresponding to given twfic(s). (null ids are given for those not found).
			 * // for each twfic with a null segment, load/parse its paragraph.
			 * select segment.Id, segment.BeginOffset, segment.EndOffset from CmBaseAnnotation_ twfic
					left outer join CmBaseAnnotation_ segment on segment.AnnotationType={}
					and twfic.BeginObject = segment.BeginObject
					and twfic.BeginOffset >= segment.BeginOffset
					and twfic.EndOffset <= segment.EndOffset
					where twfic.AnnotationType={} and twfic.Id in ()
			 */
			// Enhance: Preload/parse any out-of-date paragraphs for these twfics.
			// Enhance: Preload basic twfic info. (e.g. BeginObject)
			List<int> twficSegments = new List<int>(twfics.Count);
			bool fPreloaded = false;
			// first try to find existing real
			foreach (CmBaseAnnotation twfic in new FdoObjectSet<CmBaseAnnotation>(cache, twfics.ToArray(), !fPreloaded))
			{
				// get the segment for this twfic.
				TwficInfo twficInfo = new TwficInfo(cache, twfic.Hvo);
				twficSegments.Add(twficInfo.SegmentHvo);
			}
			return twficSegments;
		}
Example #3
0
		private void GetAdjacentWficInfo(int hvoStartingAnnotation, out int hvoSeg, out int iSegForm, out ICmBaseAnnotation currentAnnotation, out ICmBaseAnnotation nextAnnotation, out int hvoOldWordform1, out int hvoOldWordform2)
		{
			TwficInfo twficInfo = new TwficInfo(Cache, hvoStartingAnnotation);
			hvoSeg = twficInfo.SegmentHvo;
			iSegForm = twficInfo.SegmentFormIndex;
			List<int> segForms = this.SegmentForms(hvoSeg);
			if (iSegForm < 0 || iSegForm + 1 >= segForms.Count)
				throw new ArgumentException(String.Format("Can't find adjacent annotation to merge with {0}.", hvoStartingAnnotation));
			int hvoNextAnnotation = segForms[iSegForm + 1];
			currentAnnotation = CmBaseAnnotation.CreateFromDBObject(Cache, hvoStartingAnnotation, false) as CmBaseAnnotation;
			nextAnnotation = CmBaseAnnotation.CreateFromDBObject(Cache, hvoNextAnnotation, false) as CmBaseAnnotation;
			int twficType = CmAnnotationDefn.Twfic(Cache).Hvo;
			if (currentAnnotation.AnnotationTypeRAHvo != twficType ||
				nextAnnotation.AnnotationTypeRAHvo != twficType)
			{
				throw new ArgumentException(String.Format("Can only support merging annotations of twfic type{0}.\nAnnotation({1}).Type({2}) Annotation({3}).Type({4})",
						twficType, currentAnnotation.Hvo, currentAnnotation.AnnotationTypeRAHvo, nextAnnotation.Hvo, nextAnnotation.AnnotationTypeRAHvo));
			}
			hvoOldWordform1 = WfiWordform.GetWfiWordformFromInstanceOf(Cache, currentAnnotation.Hvo);
			hvoOldWordform2 = WfiWordform.GetWfiWordformFromInstanceOf(Cache, nextAnnotation.Hvo);
		}