You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by GitBox <gi...@apache.org> on 2023/01/20 08:27:06 UTC

[GitHub] [opennlp-sandbox] rzo1 commented on a diff in pull request #59: Updates sandbox component 'opennlp-wsd' to be compatible with latest opennlp-tools release

rzo1 commented on code in PR #59:
URL: https://github.com/apache/opennlp-sandbox/pull/59#discussion_r1082216933


##########
opennlp-wsd/pom.xml:
##########
@@ -25,20 +25,20 @@
 	<parent>
 		<groupId>org.apache</groupId>
 		<artifactId>apache</artifactId>
-		<version>13</version>
+		<version>18</version>

Review Comment:
   Can we go for `29` ? We can update it in `opennlp` as well (mostly build support, etc.)



##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDHelper.java:
##########
@@ -480,14 +482,10 @@ public static HashMap<String, Object> getEnglishWords(String dict) {
    */
   public static POS getPOS(String posTag) {
 
-    ArrayList<String> adjective = new ArrayList<String>(Arrays.asList("JJ",
-        "JJR", "JJS"));
-    ArrayList<String> adverb = new ArrayList<String>(Arrays.asList("RB", "RBR",
-        "RBS"));
-    ArrayList<String> noun = new ArrayList<String>(Arrays.asList("NN", "NNS",
-        "NNP", "NNPS"));
-    ArrayList<String> verb = new ArrayList<String>(Arrays.asList("VB", "VBD",
-        "VBG", "VBN", "VBP", "VBZ"));
+    List<String> adjective = new ArrayList<>(Arrays.asList("JJ", "JJR", "JJS"));

Review Comment:
   The `new ArrayList()` calls are not needed. 



##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDHelper.java:
##########
@@ -631,7 +629,7 @@ public static ArrayList<WordPOS> getAllRelevantWords(String[] sentence) {
   public static ArrayList<String> StemWordWithWordNet(WordPOS wordToStem) {
     if (wordToStem == null)
       return null;
-    ArrayList<String> stems = new ArrayList<String>();
+    ArrayList<String> stems = new ArrayList<>();

Review Comment:
   List?



##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDHelper.java:
##########
@@ -606,7 +604,7 @@ public static boolean areStringArraysEqual(String[] array1, String[] array2) {
 
   public static ArrayList<WordPOS> getAllRelevantWords(String[] sentence) {
 
-    ArrayList<WordPOS> relevantWords = new ArrayList<WordPOS>();
+    ArrayList<WordPOS> relevantWords = new ArrayList<>();

Review Comment:
   List?



##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/SensevalReader.java:
##########
@@ -218,9 +240,9 @@ public ArrayList<WSDSample> getSensevalData(String wordTag) {
                       String textAfter = nChild.getChildNodes().item(2)
                           .getTextContent();
 
-                      ArrayList<String> textBeforeTokenzed = new ArrayList<String>(
+                      ArrayList<String> textBeforeTokenzed = new ArrayList<>(

Review Comment:
   No need for `new` Operator, if we use `List` interface



##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDHelper.java:
##########
@@ -68,11 +72,11 @@ public class WSDHelper {
       "RBR", "RBS", "VB", "VBD", "VBG", "VBN", "VBP", "VBZ" };
 
   // List of Negation Words
-  public static ArrayList<String> negationWords = new ArrayList<String>(
+  public static ArrayList<String> negationWords = new ArrayList<>(

Review Comment:
   There is a switch from `HashMap` to `Map` -> also switch from `ArrayList` to `List` ?



##########
opennlp-wsd/src/main/java/opennlp/tools/disambiguator/datareader/SemcorReaderExtended.java:
##########
@@ -200,7 +202,7 @@ private ArrayList<Sentence> readFile(String file) {
    */
   private ArrayList<WSDSample> getSemcorOneFileData(String file, String wordTag) {
 
-    ArrayList<WSDSample> setInstances = new ArrayList<WSDSample>();
+    ArrayList<WSDSample> setInstances = new ArrayList<>();

Review Comment:
   List?



-- 
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-unsubscribe@opennlp.apache.org

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