timgrein opened a new pull request, #13170: URL: https://github.com/apache/lucene/pull/13170
The method [`preceding`](https://github.com/apache/lucene/blob/6445bc0a14ee22d107c072f4ef7b133faf780fe1/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPSentenceBreakIterator.java#L151) and [`following`](https://github.com/apache/lucene/blob/6445bc0a14ee22d107c072f4ef7b133faf780fe1/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPSentenceBreakIterator.java#L89) calculate the middle of a sentence differently. If the input text contains two sentences trying to get the preceding sentence to the second sentence will lead to an `ArrayIndexOutOfBoundsException` in this [line](https://github.com/apache/lucene/blob/6445bc0a14ee22d107c072f4ef7b133faf780fe1/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/OpenNLPSentenceBreakIterator.java#L103) as `currentSentence` will be `1` and `currentSentence + 1` will be `2`, which is out of bounds by 1. I've added a test case, which fails for the old logic and passes for the new logic. Closes https://github.com/apache/lucene/issues/12210. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
