[ 
https://issues.apache.org/jira/browse/OPENNLP-1413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17649596#comment-17649596
 ] 

ASF GitHub Bot commented on OPENNLP-1413:
-----------------------------------------

mawiesne commented on code in PR #459:
URL: https://github.com/apache/opennlp/pull/459#discussion_r1052961165


##########
opennlp-tools/src/main/java/opennlp/tools/util/DownloadUtil.java:
##########
@@ -144,29 +158,20 @@ public static BaseModel downloadModel(URL url, Class<?> 
type) throws IOException
     final Path localFile = Paths.get(homeDirectory.toString(), filename);
 
     if (!Files.exists(localFile)) {
-
       System.out.println("Downloading model " + url + " to " + localFile);
 
       try (final InputStream in = url.openStream()) {
         Files.copy(in, localFile, StandardCopyOption.REPLACE_EXISTING);
       }
 
       System.out.println("Download complete.");
-
     }
 
-    if (type == TokenizerModel.class) {
-      return new TokenizerModel(localFile);
-    } else if (type == ChunkerModel.class) {
-      return new ChunkerModel(localFile);
-    } else if (type == SentenceModel.class) {
-      return new SentenceModel(localFile);
-    } else if (type == POSModel.class) {
-      return new POSModel(localFile);
-    } else {
-      return new TokenNameFinderModel(localFile);
+    try {
+      return type.getConstructor(Path.class).newInstance(localFile);

Review Comment:
   Will check if this would have any benefits here.





> Enhance JavaDoc in opennlp.tools.util package
> ---------------------------------------------
>
>                 Key: OPENNLP-1413
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1413
>             Project: OpenNLP
>          Issue Type: Improvement
>          Components: Documentation
>    Affects Versions: 2.1.0
>            Reporter: Martin Wiesner
>            Assignee: Martin Wiesner
>            Priority: Minor
>             Fix For: 2.1.1
>
>
> The JavaDoc the _opennlp.tools.util_ package suffers from several 
> inconsistencies and missing descriptions. Moreover, several typos are present 
> that need sanitizing.
> It needs enhancements and/or additions to provide more clarity for readers.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to