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

svn commit: r1145566 - /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java

Author: colen
Date: Tue Jul 12 12:31:45 2011
New Revision: 1145566

URL: http://svn.apache.org/viewvc?rev=1145566&view=rev
Log:
OPENNLP-221 Updated the Parameters interface to use File and Charset now supported by ArgumentParser

Modified:
    incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java

Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java?rev=1145566&r1=1145565&r2=1145566&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java Tue Jul 12 12:31:45 2011
@@ -42,10 +42,10 @@ public final class SentenceDetectorEvalu
     
     @ParameterDescription(valueName = "charsetName", description = "specifies the encoding which should be used for reading and writing text")
     @OptionalParameter(defaultValue="UTF-8")
-    String getEncoding();
+    Charset getEncoding();
     
     @ParameterDescription(valueName = "model")
-    String getModel();
+    File getModel();
     
     @ParameterDescription(valueName = "data")
     String getData();
@@ -72,14 +72,14 @@ public final class SentenceDetectorEvalu
     
     Parameters params = ArgumentParser.parse(args, Parameters.class);
     
-    Charset encoding = Charset.forName(params.getEncoding());
+    Charset encoding = params.getEncoding();
     
     if (encoding == null) {
       System.out.println(getHelp());
       throw new TerminateToolException(1);
     }
     
-    SentenceModel model = new SentenceModelLoader().load(new File(params.getModel()));
+    SentenceModel model = new SentenceModelLoader().load(params.getModel());
     
     File trainingDataInFile = new File(params.getData());
     CmdLineUtil.checkInputFile("Training Data", trainingDataInFile);



Re: svn commit: r1145566 - /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java

Posted by Jörn Kottmann <ko...@gmail.com>.
On 7/12/11 2:31 PM, colen@apache.org wrote:
> +    Charset encoding = params.getEncoding();
>
>       if (encoding == null) {
>         System.out.println(getHelp());
>         throw new TerminateToolException(1);
>       }

The case encoding == null will never happen, since
encoding is a mandatory parameter. So these three lines
should be removed.

The call to validateArguments will return false if the encoding
is not specified, and the call to ArgumentParser.parse will fail if
the Charset cannot be created, e.g invalid name, not support on platform.

Jörn