You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by ki...@apache.org on 2022/12/02 14:06:45 UTC

[opennlp] branch master updated: OPENNLP-1400 Enhance JavaDoc in opennlp.tools.sentdetect package

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

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/opennlp.git


The following commit(s) were added to refs/heads/master by this push:
     new d0675ed8 OPENNLP-1400 Enhance JavaDoc in opennlp.tools.sentdetect package
d0675ed8 is described below

commit d0675ed806d1d35cb89a4363ced80ea273edf834
Author: Martin Wiesner <ma...@hs-heilbronn.de>
AuthorDate: Fri Dec 2 14:55:57 2022 +0100

    OPENNLP-1400 Enhance JavaDoc in opennlp.tools.sentdetect package
    
    - adds missing JavaDoc
    - improves existing documentation for clarity
    - removes superfluous text
    - fixes typos
    - adjusts SentenceSample to implement Sample interface to be consistent with other cases (see changes in: OPENNLP-1394)
    - adds 'final' modifier where useful and applicable
    - removes deprecated constructors in SDCrossValidator
---
 .../main/java/opennlp/tools/postag/POSTagger.java  |  6 +--
 .../java/opennlp/tools/postag/POSTaggerME.java     |  8 ++--
 .../sentdetect/DefaultEndOfSentenceScanner.java    | 11 ++++--
 .../sentdetect/DefaultSDContextGenerator.java      | 29 +++++++-------
 .../sentdetect/EmptyLinePreprocessorStream.java    |  3 +-
 .../tools/sentdetect/EndOfSentenceScanner.java     | 20 +++++-----
 .../tools/sentdetect/NewlineSentenceDetector.java  |  4 +-
 .../tools/sentdetect/SDContextGenerator.java       |  2 +-
 .../opennlp/tools/sentdetect/SDCrossValidator.java | 45 +++-------------------
 .../opennlp/tools/sentdetect/SDEventStream.java    |  8 ++--
 .../opennlp/tools/sentdetect/SentenceDetector.java |  6 +--
 .../sentdetect/SentenceDetectorEvaluator.java      |  8 ++--
 .../tools/sentdetect/SentenceDetectorFactory.java  |  9 +++--
 .../tools/sentdetect/SentenceDetectorME.java       | 24 ++++++------
 .../opennlp/tools/sentdetect/SentenceSample.java   | 19 ++++-----
 .../tools/sentdetect/SentenceSampleStream.java     |  5 ++-
 .../opennlp/tools/sentdetect/package-info.java     |  2 +-
 .../opennlp/tools/postag/POSEvaluatorTest.java     |  4 +-
 .../uima/sentdetect/AbstractSentenceDetector.java  |  6 +--
 .../main/java/opennlp/uima/sentdetect/package.html |  2 +-
 20 files changed, 95 insertions(+), 126 deletions(-)

diff --git a/opennlp-tools/src/main/java/opennlp/tools/postag/POSTagger.java b/opennlp-tools/src/main/java/opennlp/tools/postag/POSTagger.java
index bc334ea0..e7599047 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/postag/POSTagger.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/postag/POSTagger.java
@@ -26,14 +26,14 @@ public interface POSTagger {
 
   /**
    * Assigns the sentence of tokens pos tags.
-   * @param sentence The sentece of tokens to be tagged.
+   * @param sentence The sentence of tokens to be tagged.
    * @return an array of pos tags for each token provided in sentence.
    */
   String[] tag(String[] sentence);
 
-  String[] tag(String[] sentence, Object[] additionaContext);
+  String[] tag(String[] sentence, Object[] additionalContext);
 
   Sequence[] topKSequences(String[] sentence);
 
-  Sequence[] topKSequences(String[] sentence, Object[] additionaContext);
+  Sequence[] topKSequences(String[] sentence, Object[] additionalContext);
 }
diff --git a/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerME.java b/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerME.java
index 95ffffef..655c2fde 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerME.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/postag/POSTaggerME.java
@@ -144,8 +144,8 @@ public class POSTaggerME implements POSTagger {
     return this.tag(sentence, null);
   }
 
-  public String[] tag(String[] sentence, Object[] additionaContext) {
-    bestSequence = model.bestSequence(sentence, additionaContext, contextGen, sequenceValidator);
+  public String[] tag(String[] sentence, Object[] additionalContext) {
+    bestSequence = model.bestSequence(sentence, additionalContext, contextGen, sequenceValidator);
     List<String> t = bestSequence.getOutcomes();
     return t.toArray(new String[t.size()]);
   }
@@ -173,8 +173,8 @@ public class POSTaggerME implements POSTagger {
     return this.topKSequences(sentence, null);
   }
 
-  public Sequence[] topKSequences(String[] sentence, Object[] additionaContext) {
-    return model.bestSequences(size, sentence, additionaContext, contextGen, sequenceValidator);
+  public Sequence[] topKSequences(String[] sentence, Object[] additionalContext) {
+    return model.bestSequences(size, sentence, additionalContext, contextGen, sequenceValidator);
   }
 
   /**
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultEndOfSentenceScanner.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultEndOfSentenceScanner.java
index 2b8c0bee..bc9f004d 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultEndOfSentenceScanner.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultEndOfSentenceScanner.java
@@ -25,19 +25,19 @@ import java.util.Set;
 
 /**
  * Default implementation of the {@link EndOfSentenceScanner}.
- * It uses an character array with possible end of sentence chars
+ * It uses a character array with possible end of sentence chars
  * to identify potential sentence endings.
  */
 public class DefaultEndOfSentenceScanner implements EndOfSentenceScanner {
 
-  private Set<Character> eosCharacters;
+  private final Set<Character> eosCharacters;
   @Deprecated
-  private char[] eosChars;
+  private final char[] eosChars;
 
   /**
    * Initializes the current instance.
    *
-   * @param eosCharacters
+   * @param eosCharacters The characters to be used to detect sentence endings.
    */
   public DefaultEndOfSentenceScanner(char[] eosCharacters) {
     this.eosCharacters = new HashSet<>();
@@ -47,14 +47,17 @@ public class DefaultEndOfSentenceScanner implements EndOfSentenceScanner {
     this.eosChars = eosCharacters;
   }
 
+  @Override
   public List<Integer> getPositions(String s) {
     return getPositions(s.toCharArray());
   }
 
+  @Override
   public List<Integer> getPositions(StringBuffer buf) {
     return getPositions(buf.toString().toCharArray());
   }
 
+  @Override
   public List<Integer> getPositions(char[] cbuf) {
     List<Integer> l = new ArrayList<>();
     for (int i = 0; i < cbuf.length; i++) {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
index 8c2822bd..f972d575 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/DefaultSDContextGenerator.java
@@ -41,15 +41,14 @@ public class DefaultSDContextGenerator implements SDContextGenerator {
    */
   protected List<String> collectFeats;
 
-  private Set<String> inducedAbbreviations;
+  private final Set<String> inducedAbbreviations;
 
-  private Set<Character> eosCharacters;
+  private final Set<Character> eosCharacters;
 
   /**
-   * Creates a new <code>SDContextGenerator</code> instance with
-   * no induced abbreviations.
+   * Creates a new instance with no induced abbreviations.
    *
-   * @param eosCharacters
+   * @param eosCharacters The characters to be used to detect sentence endings.
    */
   public DefaultSDContextGenerator(char[] eosCharacters) {
     this(Collections.emptySet(), eosCharacters);
@@ -63,7 +62,7 @@ public class DefaultSDContextGenerator implements SDContextGenerator {
    *     representing induced abbreviations in the training data.
    *     Example: &quot;Mr.&quot;
    *
-   * @param eosCharacters
+   * @param eosCharacters The characters to be used to detect sentence endings.
    */
   public DefaultSDContextGenerator(Set<String> inducedAbbreviations, char[] eosCharacters) {
     this.inducedAbbreviations = inducedAbbreviations;
@@ -87,9 +86,7 @@ public class DefaultSDContextGenerator implements SDContextGenerator {
     return new String(new char[]{c});
   }
 
-  /* (non-Javadoc)
-   * @see opennlp.tools.sentdetect.SDContextGenerator#getContext(java.lang.StringBuffer, int)
-   */
+  @Override
   public String[] getContext(CharSequence sb, int position) {
 
     /*
@@ -164,7 +161,7 @@ public class DefaultSDContextGenerator implements SDContextGenerator {
   }
 
   /**
-   * Determines some of the features for the sentence detector and adds them to list features.
+   * Determines some features for the sentence detector and adds them to list features.
    *
    * @param prefix String preceding the eos character in the eos token.
    * @param suffix String following the eos character in the eos token.
@@ -178,13 +175,13 @@ public class DefaultSDContextGenerator implements SDContextGenerator {
   }
 
   /**
-   * Determines some of the features for the sentence detector and adds them to list features.
+   * Determines some features for the sentence detector and adds them to list features.
    *
-   * @param prefix String preceding the eos character in the eos token.
-   * @param suffix String following the eos character in the eos token.
-   * @param previous Space delimited token preceding token containing eos character.
-   * @param next Space delimited token following token containing eos character.
-   * @param eosChar the EOS character been analyzed
+   * @param prefix String preceding the {@code eosChar} in the eos token.
+   * @param suffix String following the {@code eosChar} in the eos token.
+   * @param previous Space delimited token preceding token containing {@code eosChar}.
+   * @param next Space delimited token following token containing {@code eosChar}.
+   * @param eosChar the EOS character been analyzed.
    */
   protected void collectFeatures(String prefix, String suffix, String previous,
       String next, Character eosChar) {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EmptyLinePreprocessorStream.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EmptyLinePreprocessorStream.java
index 9912155a..dc4cb61e 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EmptyLinePreprocessorStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EmptyLinePreprocessorStream.java
@@ -23,7 +23,7 @@ import opennlp.tools.util.FilterObjectStream;
 import opennlp.tools.util.ObjectStream;
 
 /**
- * Stream to to clean up empty lines for empty line separated document streams.<br>
+ * {@link ObjectStream} to clean up empty lines for empty line separated document streams.<br>
  *
  * - Skips empty line at training data start<br>
  * - Transforms multiple empty lines in a row into one <br>
@@ -48,6 +48,7 @@ public class EmptyLinePreprocessorStream extends FilterObjectStream<String, Stri
     return line.trim().length() == 0;
   }
 
+  @Override
   public String read() throws IOException {
 
     String line = samples.read();
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EndOfSentenceScanner.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EndOfSentenceScanner.java
index 7963e377..c1aee346 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EndOfSentenceScanner.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/EndOfSentenceScanner.java
@@ -32,15 +32,13 @@ import java.util.Set;
 public interface EndOfSentenceScanner {
 
   /**
-   * Returns an array of character which can indicate the end of a sentence.
    * @return an array of character which can indicate the end of a sentence.
    */
   @Deprecated
   char[] getEndOfSentenceCharacters();
 
   /**
-   * Returns a set of character which can indicate the end of a sentence.
-   * @return a set of character which can indicate the end of a sentence.
+   * @return a set of {@link Character characters} which can indicate the end of a sentence.
    */
   Set<Character> getEOSCharacters();
 
@@ -48,26 +46,26 @@ public interface EndOfSentenceScanner {
    * The receiver scans the specified string for sentence ending characters and
    * returns their offsets.
    *
-   * @param s a <code>String</code> value
-   * @return a <code>List</code> of Integer objects.
+   * @param s a {@link String} value
+   * @return a {@link List} of Integer objects.
    */
   List<Integer> getPositions(String s);
 
   /**
-   * The receiver scans `buf' for sentence ending characters and
+   * The receiver scans {@code buf} for sentence ending characters and
    * returns their offsets.
    *
-   * @param buf a <code>StringBuffer</code> value
-   * @return a <code>List</code> of Integer objects.
+   * @param buf a {@link StringBuffer} value
+   * @return a {@link List} of Integer objects.
    */
   List<Integer> getPositions(StringBuffer buf);
 
   /**
-   * The receiver scans `cbuf' for sentence ending characters and
+   * The receiver scans {@code cbuf} for sentence ending characters and
    * returns their offsets.
    *
-   * @param cbuf a <code>char[]</code> value
-   * @return a <code>List</code> of Integer objects.
+   * @param cbuf a {@code char[]} value
+   * @return a {@link List} of Integer objects.
    */
   List<Integer> getPositions(char[] cbuf);
 }
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/NewlineSentenceDetector.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/NewlineSentenceDetector.java
index 4f3c96c5..84cfa259 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/NewlineSentenceDetector.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/NewlineSentenceDetector.java
@@ -23,15 +23,17 @@ import java.util.List;
 import opennlp.tools.util.Span;
 
 /**
- * The Newline Sentence Detector assumes that sentences are line delimited and
+ * The Newline {@link SentenceDetector} assumes that sentences are line delimited and
  * recognizes one sentence per non-empty line.
  */
 public class NewlineSentenceDetector implements SentenceDetector {
 
+  @Override
   public String[] sentDetect(String s) {
     return Span.spansToStrings(sentPosDetect(s), s);
   }
 
+  @Override
   public Span[] sentPosDetect(String s) {
 
     List<Span> sentences = new ArrayList<>();
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDContextGenerator.java
index ade9d6a6..d0ca1f2f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDContextGenerator.java
@@ -31,7 +31,7 @@ public interface SDContextGenerator {
    * @param position An index into the specified string buffer when a sentence boundary may occur.
    *
    * @return an array of contextual features for the potential sentence boundary at the
-   * specified position within the specified string buffer.
+   * specified {@code position} within the specified string buffer.
    */
   String[] getContext(CharSequence s, int position);
 }
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDCrossValidator.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDCrossValidator.java
index 2f6daeca..9f0bdadf 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDCrossValidator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDCrossValidator.java
@@ -23,10 +23,9 @@ import opennlp.tools.util.ObjectStream;
 import opennlp.tools.util.TrainingParameters;
 import opennlp.tools.util.eval.CrossValidationPartitioner;
 import opennlp.tools.util.eval.FMeasure;
-import opennlp.tools.util.model.ModelUtil;
 
 /**
- * A cross validator for the sentence detector.
+ * A cross validator for {@link SentenceDetector sentence detectors}.
  */
 public class SDCrossValidator {
 
@@ -34,11 +33,11 @@ public class SDCrossValidator {
 
   private final TrainingParameters params;
 
-  private FMeasure fmeasure = new FMeasure();
+  private final FMeasure fmeasure = new FMeasure();
 
-  private SentenceDetectorEvaluationMonitor[] listeners;
+  private final SentenceDetectorEvaluationMonitor[] listeners;
 
-  private SentenceDetectorFactory sdFactory;
+  private final SentenceDetectorFactory sdFactory;
 
   public SDCrossValidator(String languageCode, TrainingParameters params,
       SentenceDetectorFactory sdFactory, SentenceDetectorEvaluationMonitor... listeners) {
@@ -47,39 +46,7 @@ public class SDCrossValidator {
     this.listeners = listeners;
     this.sdFactory = sdFactory;
   }
-
-  /**
-   * @deprecated Use
-   *             {@link #SDCrossValidator(String, TrainingParameters,
-   *             SentenceDetectorFactory, SentenceDetectorEvaluationMonitor...)}
-   *             and pass in a {@link SentenceDetectorFactory}.
-   */
-  public SDCrossValidator(String languageCode, TrainingParameters params) {
-    this(languageCode, params, new SentenceDetectorFactory(languageCode, true,
-        null, null));
-  }
-
-  /**
-   * @deprecated use
-   *             {@link #SDCrossValidator(String, TrainingParameters, SentenceDetectorFactory,
-   *             SentenceDetectorEvaluationMonitor...)}
-   *             instead and pass in a TrainingParameters object.
-   */
-  public SDCrossValidator(String languageCode, TrainingParameters params,
-      SentenceDetectorEvaluationMonitor... listeners) {
-    this(languageCode, params, new SentenceDetectorFactory(languageCode, true,
-        null, null), listeners);
-  }
-
-  /**
-   * @deprecated use {@link #SDCrossValidator(String, TrainingParameters,
-   *     SentenceDetectorFactory, SentenceDetectorEvaluationMonitor...)}
-   *     instead and pass in a TrainingParameters object.
-   */
-  public SDCrossValidator(String languageCode) {
-    this(languageCode, ModelUtil.createDefaultTrainingParameters());
-  }
-
+  
   /**
    * Starts the evaluation.
    *
@@ -88,7 +55,7 @@ public class SDCrossValidator {
    * @param nFolds
    *          number of folds
    *
-   * @throws IOException
+   * @throws IOException Thrown if IO errors occurred during processing.
    */
   public void evaluate(ObjectStream<SentenceSample> samples, int nFolds) throws IOException {
 
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDEventStream.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDEventStream.java
index a6561431..9c02ce43 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDEventStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SDEventStream.java
@@ -28,13 +28,15 @@ import opennlp.tools.util.Span;
 
 public class SDEventStream extends AbstractEventStream<SentenceSample> {
 
-  private SDContextGenerator cg;
-  private EndOfSentenceScanner scanner;
+  private final SDContextGenerator cg;
+  private final EndOfSentenceScanner scanner;
 
   /**
    * Initializes the current instance.
    *
-   * @param samples
+   * @param samples An {@link ObjectStream stream} of {@link SentenceSample samples}.
+   * @param cg The {@link SDContextGenerator} to be used.
+   * @param scanner The {@link EndOfSentenceScanner scanner} to be used.
    */
   public SDEventStream(ObjectStream<SentenceSample> samples, SDContextGenerator cg,
       EndOfSentenceScanner scanner) {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetector.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetector.java
index 01e3d99b..38cf3def 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetector.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetector.java
@@ -29,7 +29,7 @@ public interface SentenceDetector {
     /**
      * Sentence detect a string.
      *
-     * @param s The string to be sentence detected.
+     * @param s The string for which sentences shall to be detected.
      * @return  The String[] with the individual sentences as the array
      *          elements.
      */
@@ -38,9 +38,9 @@ public interface SentenceDetector {
     /**
      * Sentence detect a string.
      *
-     * @param s The string to be sentence detected.
+     * @param s The string for which sentences shall be detected.
      *
-     * @return The Span[] with the spans (offsets into s) for each
+     * @return The array of {@link Span spans} (offsets into {@code s}) for each
      * detected sentence as the individuals array elements.
      */
     Span[] sentPosDetect(String s);
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorEvaluator.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorEvaluator.java
index 3effda8b..eee3ece7 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorEvaluator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorEvaluator.java
@@ -32,18 +32,18 @@ import opennlp.tools.util.eval.FMeasure;
  */
 public class SentenceDetectorEvaluator extends Evaluator<SentenceSample> {
 
-  private FMeasure fmeasure = new FMeasure();
+  private final FMeasure fmeasure = new FMeasure();
 
   /**
    * The {@link SentenceDetector} used to predict sentences.
    */
-  private SentenceDetector sentenceDetector;
+  private final SentenceDetector sentenceDetector;
 
   /**
    * Initializes the current instance.
    *
-   * @param sentenceDetector
-   * @param listeners evaluation sample listeners
+   * @param sentenceDetector The {@link SentenceDetector} to be used for predicting sentences.
+   * @param listeners The {@link SentenceDetectorEvaluationMonitor evaluation sample listeners}.
    */
   public SentenceDetectorEvaluator(SentenceDetector sentenceDetector,
                                    SentenceDetectorEvaluationMonitor... listeners) {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorFactory.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorFactory.java
index 54dcc648..0276f931 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorFactory.java
@@ -28,7 +28,7 @@ import opennlp.tools.util.InvalidFormatException;
 import opennlp.tools.util.ext.ExtensionLoader;
 
 /**
- * The factory that provides SentenceDetecor default implementations and
+ * The factory that provides {@link SentenceDetector} default implementations and
  * resources
  */
 public class SentenceDetectorFactory extends BaseToolFactory {
@@ -53,9 +53,10 @@ public class SentenceDetectorFactory extends BaseToolFactory {
    * Creates a {@link SentenceDetectorFactory}. Use this constructor to
    * programmatically create a factory.
    *
-   * @param languageCode
-   * @param abbreviationDictionary
-   * @param eosCharacters
+   * @param languageCode The ISO language code to be used for this factory.
+   * @param useTokenEnd {@code true} if {@link #TOKEN_END_PROPERTY} shall be used, {@code false} otherwise.
+   * @param abbreviationDictionary The {@link Dictionary} which holds abbreviations.
+   * @param eosCharacters The characters to be used to detect sentence endings.
    */
   public SentenceDetectorFactory(String languageCode, boolean useTokenEnd,
       Dictionary abbreviationDictionary, char[] eosCharacters) {
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
index b15e08d3..b0cec962 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceDetectorME.java
@@ -60,7 +60,7 @@ public class SentenceDetectorME implements SentenceDetector {
   /**
    * The maximum entropy model to use to evaluate contexts.
    */
-  private MaxentModel model;
+  private final MaxentModel model;
 
   /**
    * The feature context generator.
@@ -75,7 +75,7 @@ public class SentenceDetectorME implements SentenceDetector {
   /**
    * The list of probabilities associated with each decision.
    */
-  private List<Double> sentProbs = new ArrayList<>();
+  private final List<Double> sentProbs = new ArrayList<>();
 
   protected boolean useTokenEnd;
 
@@ -131,7 +131,7 @@ public class SentenceDetectorME implements SentenceDetector {
   }
 
   /**
-   * Detect sentences in a String.
+   * Detect sentences in given input String.
    *
    * @param s  The string to be processed.
    *
@@ -168,10 +168,11 @@ public class SentenceDetectorME implements SentenceDetector {
    * Detect the position of the first words of sentences in a String.
    *
    * @param s  The string to be processed.
-   * @return   A integer array containing the positions of the end index of
+   * @return   An integer array containing the positions of the end index of
    *          every sentence
    *
    */
+  @Override
   public Span[] sentPosDetect(String s) {
     sentProbs.clear();
     StringBuffer sb = new StringBuffer(s);
@@ -278,10 +279,11 @@ public class SentenceDetectorME implements SentenceDetector {
 
   /**
    * Returns the probabilities associated with the most recent
-   * calls to sentDetect().
+   * calls to {@link SentenceDetectorME#sentDetect(String)}.
    *
-   * @return probability for each sentence returned for the most recent
-   *     call to sentDetect.  If not applicable an empty array is returned.
+   * @return The probability for each sentence returned for the most recent
+   *     call to {@link SentenceDetectorME#sentDetect(String)}.
+   *     If not applicable, an empty array is returned.
    */
   public double[] getSentenceProbabilities() {
     double[] sentProbArray = new double[sentProbs.size()];
@@ -296,13 +298,13 @@ public class SentenceDetectorME implements SentenceDetector {
    * trained) model from flagging obvious non-breaks as breaks based
    * on some boolean determination of a break's acceptability.
    *
-   * <p>The implementation here always returns true, which means
+   * <p>The implementation here always returns {@link true}, which means
    * that the MaxentModel's outcome is taken as is.</p>
    *
    * @param s the string in which the break occurred.
-   * @param fromIndex the start of the segment currently being evaluated
-   * @param candidateIndex the index of the candidate sentence ending
-   * @return true if the break is acceptable
+   * @param fromIndex the start of the segment currently being evaluated.
+   * @param candidateIndex the index of the candidate sentence ending.
+   * @return {@link true} if the break is acceptable.
    */
   protected boolean isAcceptableBreak(String s, int fromIndex, int candidateIndex) {
     return true;
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSample.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSample.java
index 100f807e..e00382ba 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSample.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSample.java
@@ -17,13 +17,13 @@
 
 package opennlp.tools.sentdetect;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
+import opennlp.tools.commons.Sample;
 import opennlp.tools.tokenize.Detokenizer;
 import opennlp.tools.util.Span;
 
@@ -31,17 +31,17 @@ import opennlp.tools.util.Span;
  * A {@link SentenceSample} contains a document with
  * begin indexes of the individual sentences.
  */
-public class SentenceSample implements Serializable {
+public class SentenceSample implements Sample {
 
-  private static final long serialVersionUID = -5386940708608341113L;
+  private static final long serialVersionUID = 1771522768104567531L;
   private final String document;
   private final List<Span> sentences;
 
   /**
    * Initializes the current instance.
    *
-   * @param document
-   * @param sentences
+   * @param document The document represented as plain {@link CharSequence}.
+   * @param sentences One or more {@link Span spans} that represent a sentence each.
    */
   public SentenceSample(CharSequence document, Span... sentences) {
     this.document = document.toString();
@@ -78,19 +78,14 @@ public class SentenceSample implements Serializable {
   }
 
   /**
-   * Retrieves the document.
-   *
-   * @return the document
+   * @return the document as a plain string.
    */
   public String getDocument() {
     return document;
   }
 
   /**
-   * Retrieves the sentences.
-   *
-   * @return the begin indexes of the sentences in the document.
-
+   * @return the {@link Span spans} of the sentences in a document.
    */
   public Span[] getSentences() {
     return sentences.toArray(new Span[sentences.size()]);
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSampleStream.java
index 10348bda..d073af2b 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/SentenceSampleStream.java
@@ -28,8 +28,8 @@ import opennlp.tools.util.Span;
 
 /**
  * This class is a stream filter which reads a sentence by line samples from
- * a <code>Reader</code> and converts them into {@link SentenceSample} objects.
- * An empty line indicates the begin of a new document.
+ * an {@link ObjectStream} and converts them into {@link SentenceSample} objects.
+ * An empty line indicates the beginning of a new document.
  */
 public class SentenceSampleStream extends FilterObjectStream<String, SentenceSample> {
 
@@ -41,6 +41,7 @@ public class SentenceSampleStream extends FilterObjectStream<String, SentenceSam
     return s.replace("<LF>", "\n").replace("<CR>", "\r");
   }
 
+  @Override
   public SentenceSample read() throws IOException {
 
     StringBuilder sentencesString = new StringBuilder();
diff --git a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/package-info.java b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/package-info.java
index d60d84fc..f8ad58b1 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/sentdetect/package-info.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/sentdetect/package-info.java
@@ -16,6 +16,6 @@
  */
 
 /**
- * Package related to identifying sentece boundries.
+ * Package related to identifying sentence boundaries.
  */
 package opennlp.tools.sentdetect;
diff --git a/opennlp-tools/src/test/java/opennlp/tools/postag/POSEvaluatorTest.java b/opennlp-tools/src/test/java/opennlp/tools/postag/POSEvaluatorTest.java
index b89f2014..482b4c31 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/postag/POSEvaluatorTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/postag/POSEvaluatorTest.java
@@ -85,11 +85,11 @@ public class POSEvaluatorTest {
       return null;
     }
 
-    public String[] tag(String[] sentence, Object[] additionaContext) {
+    public String[] tag(String[] sentence, Object[] additionalContext) {
       return tag(sentence);
     }
 
-    public Sequence[] topKSequences(String[] sentence, Object[] additionaContext) {
+    public Sequence[] topKSequences(String[] sentence, Object[] additionalContext) {
       return topKSequences(sentence);
     }
 
diff --git a/opennlp-uima/src/main/java/opennlp/uima/sentdetect/AbstractSentenceDetector.java b/opennlp-uima/src/main/java/opennlp/uima/sentdetect/AbstractSentenceDetector.java
index ab9095ae..e959d4fc 100644
--- a/opennlp-uima/src/main/java/opennlp/uima/sentdetect/AbstractSentenceDetector.java
+++ b/opennlp-uima/src/main/java/opennlp/uima/sentdetect/AbstractSentenceDetector.java
@@ -37,13 +37,13 @@ public abstract class AbstractSentenceDetector extends CasAnnotator_ImplBase {
 
   protected UimaContext context;
 
-  /**
-   * The type of the sentences to be created.
-   */
   protected Logger logger;
 
   protected Type containerType;
 
+  /**
+   * The type of the sentences to be created.
+   */
   protected Type sentenceType;
 
   private Boolean isRemoveExistingAnnotations;
diff --git a/opennlp-uima/src/main/java/opennlp/uima/sentdetect/package.html b/opennlp-uima/src/main/java/opennlp/uima/sentdetect/package.html
index 550112c6..f960fb81 100644
--- a/opennlp-uima/src/main/java/opennlp/uima/sentdetect/package.html
+++ b/opennlp-uima/src/main/java/opennlp/uima/sentdetect/package.html
@@ -27,6 +27,6 @@
 </head>
 <body bgcolor="white">
 
-Package related to identifying sentece boundries.
+Package related to identifying sentence boundaries.
 </body>
 </html>