mawiesne commented on code in PR #200:
URL: https://github.com/apache/opennlp-sandbox/pull/200#discussion_r1892669148


##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/FeaturesExtractor.java:
##########
@@ -155,31 +158,43 @@ public List<String> 
extractTrainingSurroundingWords(List<WTDIMS> trainingData) {
   }
 
   /**
-   * This method generates the different set of features related to the IMS
-   * approach and store them in the corresponding attributes of the {@link 
WTDIMS}.
+   * Generates the different set of features related to the IMS
+   * approach and puts them in the corresponding attributes of
+   * the {@link WTDIMS word to disambiguate} object.
    * 
    * @param wtd The {@link WTDIMS word to disambiguate}.
    * @param windowSize The parameter required to generate the features 
qualified of
    *                   "PoS of Surrounding Words".
    * @param ngram The parameter required to generate the features qualified of
    *              "Local Collocations".
+   *
+   * @throws IllegalArgumentException Thrown if parameters were invalid.
    */
   public void extractIMSFeatures(WTDIMS wtd, int windowSize, int ngram) {
+    if (wtd == null) {
+      throw new IllegalArgumentException("WTD must not be null");
+    }
     wtd.setPosOfSurroundingWords(extractPosOfSurroundingWords(wtd, 
windowSize));
     wtd.setSurroundingWords(extractSurroundingWords(wtd));
     wtd.setLocalCollocations(extractLocalCollocations(wtd, ngram));
   }
 
   /**
-   * This generates the context of IMS. It supposes that the features have
-   * already been extracted and stored in the {@link WTDIMS} object, therefore 
it
-   * doesn't require any parameters.
+   * Generates the context for the {@link WTDIMS word to disambiguate}.
+   *
+   * @implNote It is assumed that the features have already been extracted and
+   * wrapped in the {@link WTDIMS word to disambiguate}.
+   * Therefore, it doesn't require any parameters.
    *
-   * @param wtd The {@link WTDIMS wtd to disambiguate}.
+   * @param wtd The {@link WTDIMS word to disambiguate}.
    * @param listSurrWords The full list of surrounding words of the training 
data.
+   *
+   * @throws IllegalArgumentException Thrown if parameters were invalid.
    */
   public void serializeIMSFeatures(WTDIMS wtd, List<String> listSurrWords) {
-
+    if (wtd == null) {

Review Comment:
   Yes, separate follow-up Jira for parameter checking / validation, pls.



-- 
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: dev-unsubscr...@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to