/// ------------------------------------------------------------------------------------ /// <summary> /// Shrinks the reference in the text from the end to the previous Analysis. If it /// returns false, the reference should be deleted because it couldn't shrink anymore. /// </summary> /// <param name="fignorePunct">True if it should keep shrinking until its endpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if this AnalysisReference should be deleted because it no longer /// refers to any analyses.</returns> /// ------------------------------------------------------------------------------------ public bool ShrinkFromEnd(bool fignorePunct, IAnalysisReference reference) { var endPoint = reference.EndRef(); endPoint = fignorePunct ? endPoint.PreviousWordform() : endPoint.PreviousAnalysisOccurrence(); if (endPoint == null || reference.BegRef().IsAfter(endPoint)) return false; if (reference.EndRef().Segment.Hvo != endPoint.Segment.Hvo) reference.ChangeToDifferentSegment(endPoint.Segment, false, true); if (reference.EndRef().Index != endPoint.Index) reference.ChangeToDifferentIndex(endPoint.Index, false, true); return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Expands the reference in the text from the end to the next Analysis, if possible. /// </summary> /// <param name="fignorePunct">True if it should keep expanding until its endpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if there was no room to grow that direction in this text.</returns> /// ------------------------------------------------------------------------------------ public bool GrowFromEnd(bool fignorePunct, IAnalysisReference reference) { var endPoint = reference.EndRef(); endPoint = fignorePunct ? endPoint.NextWordform() : endPoint.NextAnalysisOccurrence(); if (endPoint == null) return false; if (reference.EndRef().Segment.Hvo != endPoint.Segment.Hvo) reference.ChangeToDifferentSegment(endPoint.Segment, false, true); if (reference.EndRef().Index != endPoint.Index) reference.ChangeToDifferentIndex(endPoint.Index, false, true); return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Expands the reference in the text from the beginning to the previous Analysis, if /// not already at the beginning of the text. /// </summary> /// <param name="fignorePunct">True if it should keep expanding until its beginpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if there was no room to grow that direction in this text.</returns> /// ------------------------------------------------------------------------------------ public bool GrowFromBeginning(bool fignorePunct, IAnalysisReference reference) { var begPoint = reference.BegRef(); begPoint = fignorePunct ? begPoint.PreviousWordform() : begPoint.PreviousAnalysisOccurrence(); if (begPoint == null) return false; if (reference.BegRef().Segment.Hvo != begPoint.Segment.Hvo) reference.ChangeToDifferentSegment(begPoint.Segment, true, false); if (reference.BegRef().Index != begPoint.Index) reference.ChangeToDifferentIndex(begPoint.Index, true, false); return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns true if this reference occurs after the parameter's reference in the text. /// </summary> /// <param name="otherReference"></param> /// ------------------------------------------------------------------------------------ public bool IsAfter(IAnalysisReference otherReference) { var otherBegPoint = otherReference.BegRef(); var myEndPoint = EndRef(); // Test to see if we're at least in the same paragraph! if (myEndPoint.Segment.Owner.Hvo == otherBegPoint.Segment.Owner.Hvo) { return(myEndPoint.GetMyBeginOffsetInPara() > otherBegPoint.GetMyEndOffsetInPara()); } // Different paragraphs return(myEndPoint.Segment.Owner.IndexInOwner > otherBegPoint.Segment.Owner.IndexInOwner); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shrinks the reference in the text from the end to the previous Analysis. If it /// returns false, the reference should be deleted because it couldn't shrink anymore. /// </summary> /// <param name="fignorePunct">True if it should keep shrinking until its endpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if this AnalysisReference should be deleted because it no longer /// refers to any analyses.</returns> /// ------------------------------------------------------------------------------------ public bool ShrinkFromEnd(bool fignorePunct, IAnalysisReference reference) { var endPoint = reference.EndRef(); endPoint = fignorePunct ? endPoint.PreviousWordform() : endPoint.PreviousAnalysisOccurrence(); if (endPoint == null || reference.BegRef().IsAfter(endPoint)) { return(false); } if (reference.EndRef().Segment.Hvo != endPoint.Segment.Hvo) { reference.ChangeToDifferentSegment(endPoint.Segment, false, true); } if (reference.EndRef().Index != endPoint.Index) { reference.ChangeToDifferentIndex(endPoint.Index, false, true); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Expands the reference in the text from the beginning to the previous Analysis, if /// not already at the beginning of the text. /// </summary> /// <param name="fignorePunct">True if it should keep expanding until its beginpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if there was no room to grow that direction in this text.</returns> /// ------------------------------------------------------------------------------------ public bool GrowFromBeginning(bool fignorePunct, IAnalysisReference reference) { var begPoint = reference.BegRef(); begPoint = fignorePunct ? begPoint.PreviousWordform() : begPoint.PreviousAnalysisOccurrence(); if (begPoint == null) { return(false); } if (reference.BegRef().Segment.Hvo != begPoint.Segment.Hvo) { reference.ChangeToDifferentSegment(begPoint.Segment, true, false); } if (reference.BegRef().Index != begPoint.Index) { reference.ChangeToDifferentIndex(begPoint.Index, true, false); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Expands the reference in the text from the end to the next Analysis, if possible. /// </summary> /// <param name="fignorePunct">True if it should keep expanding until its endpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if there was no room to grow that direction in this text.</returns> /// ------------------------------------------------------------------------------------ public bool GrowFromEnd(bool fignorePunct, IAnalysisReference reference) { var endPoint = reference.EndRef(); endPoint = fignorePunct ? endPoint.NextWordform() : endPoint.NextAnalysisOccurrence(); if (endPoint == null) { return(false); } if (reference.EndRef().Segment.Hvo != endPoint.Segment.Hvo) { reference.ChangeToDifferentSegment(endPoint.Segment, false, true); } if (reference.EndRef().Index != endPoint.Index) { reference.ChangeToDifferentIndex(endPoint.Index, false, true); } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shrinks the reference in the text from the beginning to the next Analysis. If it /// returns false, the reference should be deleted because it couldn't shrink anymore. /// </summary> /// <param name="fignorePunct">True if it should keep shrinking until its beginpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if this AnalysisReference should be deleted because it no longer /// refers to any analyses.</returns> /// ------------------------------------------------------------------------------------ public bool ShrinkFromBeginning(bool fignorePunct, IAnalysisReference reference) { var begPoint = reference.BegRef(); var endPoint = reference.EndRef(); begPoint = fignorePunct ? begPoint.NextWordform() : begPoint.NextAnalysisOccurrence(); if (begPoint == null || begPoint.IsAfter(endPoint)) { return(false); } if (reference.BegRef().Segment.Hvo != begPoint.Segment.Hvo) { reference.ChangeToDifferentSegment(begPoint.Segment, true, false); } if (reference.BegRef().Index != begPoint.Index) { reference.ChangeToDifferentIndex(begPoint.Index, true, false); } return(true); }
private static int GetReferenceEndOffsetInPara(IAnalysisReference refToAnalyses) { return refToAnalyses.EndRef().GetMyEndOffsetInPara(); }
private static int GetReferenceBeginOffsetInPara(IAnalysisReference refToAnalyses) { return refToAnalyses.BegRef().GetMyBeginOffsetInPara(); }
/// <summary> /// Delete any IAnalysisReference objects whose begin and end references fall within /// the range of indices removed and not added back in. /// Example: Old text: the big red pickup truck /// New text: the VW /// Index in Segment: 0 1 2 3 4 /// This method will delete any objects whose begin AND end references fall within /// the range 2 to 4 (inclusive). In this example, ifirstAnalysisInSegToFix would be 1. /// </summary> /// <param name="iar"></param> /// <param name="ifirstAnalysisInSegToFix"></param> /// <param name="cRemovedAnalyses"></param> /// <param name="cAddedAnalyses"></param> /// <returns></returns> private bool CheckForDeleteableIAR(IAnalysisReference iar, int ifirstAnalysisInSegToFix, int cRemovedAnalyses, int cAddedAnalyses) { if (cAddedAnalyses >= cRemovedAnalyses) return false; // In order to qualify we need more bits deleted than added. var ibegSeg = iar.BegRef().Segment.IndexInOwner; var iendSeg = iar.EndRef().Segment.IndexInOwner; if (ibegSeg < m_iFirstDeletedSegment || ibegSeg > m_iNewSegLastModified || iendSeg < m_iFirstDeletedSegment || iendSeg > m_iNewSegLastModified) return false; // One of our endpoints isn't even in the modified section! var imax = ifirstAnalysisInSegToFix + cRemovedAnalyses - 1; var imin = ifirstAnalysisInSegToFix + cAddedAnalyses; var ibeg = iar.BegRef().Index; // If FixHangingReferences adjusted the endRef index back already, // we need to take that into account here. Perhaps the BegRef IS within deleted // range, and the EndRef appears to be within the deleted range because of FHR 'adjustment'. // In this case, we need to not delete an 'iar' whose EndRef will be re-adjusted out // of the deleted range later. int adjustment; m_finalEndIndexAdjustments.TryGetValue(iar, out adjustment); var iend = iar.EndRef().Index + adjustment; if (ibeg < imin || ibeg > imax || iend < imin || iend > imax) return false; return true; // Delete this feller! }
private static void AdjustReferenceEndPoint(ISegment seg, IAnalysisReference iar, int newIndex, bool fbeg) { while (true) { var newSeg = SegmentServices.GetNextSegmentOrNull(seg); // Check to see if we need to move this reference to the next segment if (newIndex >= seg.AnalysesRS.Count && newSeg != null) { iar.ChangeToDifferentSegment(newSeg, fbeg, !fbeg); newIndex -= seg.AnalysesRS.Count; seg = newSeg; // Continue the loop in case we need to move forward yet another segment // And also to set the analysis index. } else { iar.ChangeToDifferentIndex(newIndex, fbeg, !fbeg); break; } } }
internal bool SegmentIsOutsideOfRange(IAnalysisReference refObj) { ISegment endSeg = null, begSeg = null; var endRef = refObj.EndRef(); if (endRef != null) // added for LT-13414 - one segment had a null endRef endSeg = refObj.EndRef().Segment; var begRef = refObj.BegRef(); if (begRef != null) // added for LT-16136 - one segment had a null begRef begSeg = refObj.BegRef().Segment; return endSeg != null && begSeg != null && (endSeg.IndexInOwner < m_iSegFirstModified || begSeg.IndexInOwner > m_iOldSegLastModified); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shrinks the reference in the text from the beginning to the next Analysis. If it /// returns false, the reference should be deleted because it couldn't shrink anymore. /// </summary> /// <param name="fignorePunct">True if it should keep shrinking until its beginpoint /// reaches an Analysis that has a wordform.</param> /// <param name="reference"></param> /// <returns>False if this AnalysisReference should be deleted because it no longer /// refers to any analyses.</returns> /// ------------------------------------------------------------------------------------ public bool ShrinkFromBeginning(bool fignorePunct, IAnalysisReference reference) { var begPoint = reference.BegRef(); var endPoint = reference.EndRef(); begPoint = fignorePunct ? begPoint.NextWordform() : begPoint.NextAnalysisOccurrence(); if (begPoint == null || begPoint.IsAfter(endPoint)) return false; if (reference.BegRef().Segment.Hvo != begPoint.Segment.Hvo) reference.ChangeToDifferentSegment(begPoint.Segment, true, false); if (reference.BegRef().Index != begPoint.Index) reference.ChangeToDifferentIndex(begPoint.Index, true, false); return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns true if this reference occurs after the parameter's reference in the text. /// </summary> /// <param name="otherReference"></param> /// ------------------------------------------------------------------------------------ public bool IsAfter(IAnalysisReference otherReference) { var otherBegPoint = otherReference.BegRef(); var myEndPoint = EndRef(); // Test to see if we're at least in the same paragraph! if (myEndPoint.Segment.Owner.Hvo == otherBegPoint.Segment.Owner.Hvo) { return myEndPoint.GetMyBeginOffsetInPara() > otherBegPoint.GetMyEndOffsetInPara(); } // Different paragraphs return myEndPoint.Segment.Owner.IndexInOwner > otherBegPoint.Segment.Owner.IndexInOwner; }