This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opennlp-sandbox.git


The following commit(s) were added to refs/heads/main by this push:
     new a759354  Sanitizes deprecation of 
SentenceDetectorME#getSentenceProbabilities() method
a759354 is described below

commit a75935418463eb0d316701b319ee90fbe15241bf
Author: Martin Wiesner <martin.wies...@hs-heilbronn.de>
AuthorDate: Mon Jul 14 20:06:24 2025 +0200

    Sanitizes deprecation of SentenceDetectorME#getSentenceProbabilities() 
method
---
 .../caseditor/sentdetect/SentenceDetectorJob.java  | 23 +++++++++++-----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
index b52de98..df7f7db 100644
--- 
a/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
+++ 
b/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
@@ -94,13 +94,10 @@ public class SentenceDetectorJob extends Job {
     
     detectedSentences = new ArrayList<>();
     for (Span para : paragraphs) {
-
       List<Span> textBlocks = new ArrayList<>();
 
       int textBlockBeginIndex = 0;
-      
       for (Span exclusionSpan : exclusionSpans) {
-        
         Span textBlockSpan = new Span(textBlockBeginIndex, 
exclusionSpan.getStart());
         
         // TODO: Filter out whitespace sentences ...
@@ -117,18 +114,20 @@ public class SentenceDetectorJob extends Job {
       }
       
       for (Span textBlock : textBlocks) {
-        Span[] sentenceSpans = sentenceDetector.sentPosDetect(
+        final Span[] sentenceSpans = sentenceDetector.sentPosDetect(
             textBlock.getCoveredText(text).toString());
-        
-        double[] confidence = sentenceDetector.getSentenceProbabilities();
+        final double[] confidence = sentenceDetector.probs();
         
         for (int i = 0; i < sentenceSpans.length; i++) {
-          Span sentenceSpan = sentenceSpans[i];
-          String sentenceText = text.substring(textBlock.getStart() + 
sentenceSpan.getStart(),
-              textBlock.getStart() + sentenceSpan.getEnd());
-          detectedSentences.add(new PotentialAnnotation(textBlock.getStart() + 
sentenceSpan.getStart(), 
-              textBlock.getStart() + sentenceSpan.getEnd(), sentenceText,
-              confidence[i], sentenceType));
+          final Span sentenceSpan = sentenceSpans[i];
+          int textStart = textBlock.getStart();
+          int spanStart = sentenceSpan.getStart();
+          int spanEnd = sentenceSpan.getEnd();
+          String sentenceText = this.text.substring(textStart + spanStart, 
textStart + spanEnd);
+          PotentialAnnotation pa = new PotentialAnnotation(
+                  textStart + spanStart, textStart + spanEnd,
+                  sentenceText, confidence[i], sentenceType);
+          detectedSentences.add(pa);
         }
       }
     }

Reply via email to