public static boolean isSameSentence(JCas aJcas,int aReferenceOffset,int aCompareOffset){
  if (aReferenceOffset == aCompareOffset) {
    return true;
  }
  int offset1=Math.min(aReferenceOffset,aCompareOffset);
  int offset2=Math.max(aReferenceOffset,aCompareOffset);
  Iterator<Sentence> si=JCasUtil.iterator(aJcas,Sentence.class);
  while (si.hasNext()) {
    Sentence s=si.next();
    if (s.getBegin() <= offset1 && offset1 <= s.getEnd()) {
      return s.getBegin() <= offset2 && offset2 <= s.getEnd();
    }
    if (offset1 < s.getBegin()) {
      return false;
    }
  }
  return false;
}

public static boolean isSameSentence ( JCas aJcas , int aReferenceOffset , int aCompareOffset ) { if ( aReferenceOffset == aCompareOffset ) { return true ; } int offset1 = Math . min ( aReferenceOffset , aCompareOffset ) ; int offset2 = Math . max ( aReferenceOffset , aCompareOffset ) ; Iterator < Sentence > si = JCasUtil . iterator ( aJcas , Sentence . class ) ; while ( si . hasNext ( ) ) { Sentence s = si . next ( ) ; if ( s . getBegin ( ) <= offset1 && offset1 <= s . getEnd ( ) ) { return s . getBegin ( ) <= offset2 && offset2 <= s . getEnd ( ) ; } if ( offset1 < s . getBegin ( ) ) { return false ; } } return false ; }
check if the two given offsets are within the same sentence .
