JFSIndexRepository indexes = jcas.getJFSIndexRepository();
Iterator<?> sentItr = indexes.getAnnotationIndex(Sentence.type)
.iterator();
Sentence prevSent = null;
Sentence currSent = null;
Map<Integer, Sentence> sentences = getSentencesOrderById(sentItr);
// find the first Sentence in the specified range
for (int i = 0; i < sentences.size(); i++) {
prevSent = currSent;
currSent = (Sentence) sentences.get(new Integer(i));
if (currSent == null)
iv_logger.error("Wow! some sentence is null");
if (prevSent == null)
continue; // got to have 2 sentences
// Added a check for the currSent being null which should not be happening, but apparently is for some reason 10/7/2011
if (prevSent.getCoveredText().endsWith(":") && currSent != null) {
int newEnd = -1;
if ((currSent.getSentenceNumber() - 1) == prevSent
.getSentenceNumber()) {
// System.out.println("Found adjecent sentence: " +
// prevSent.getSentenceNumber() + " is next to " +
// currSent.getSentenceNumber());
String textSent2 = currSent.getCoveredText().toLowerCase();
Iterator<String> itWordsInPattern = wordsInPattern
.iterator();
while (itWordsInPattern.hasNext()) {
String word = (String) itWordsInPattern.next();
// System.out.println("Checking for word: " + word);
if (textSent2.startsWith(word)) {
// System.out.println("Sentence begins with word: "
// + word);
newEnd = currSent.getEnd();
// System.out.println("Old Sentence ["+text.substring(prevSent.getBegin(),
// prevSent.getEnd())+"]");
prevSent.setEnd(newEnd);
// System.out.println("New Sentence ["+text.substring(prevSent.getBegin(),
// prevSent.getEnd())+"]");
currSent.removeFromIndexes();
}
}
}
}
}