You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by au...@apache.org on 2012/07/15 17:17:28 UTC

svn commit: r1361713 - in /opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline: AbstractCmdLineTool.java CLI.java CmdLineTool.java tokenizer/SimpleTokenizerTool.java

Author: autayeu
Date: Sun Jul 15 15:17:27 2012
New Revision: 1361713

URL: http://svn.apache.org/viewvc?rev=1361713&view=rev
Log:
OPENNLP-470: CLI for SimpleTokenizer is broken

Modified:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/AbstractCmdLineTool.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CLI.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/AbstractCmdLineTool.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/AbstractCmdLineTool.java?rev=1361713&r1=1361712&r2=1361713&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/AbstractCmdLineTool.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/AbstractCmdLineTool.java Sun Jul 15 15:17:27 2012
@@ -33,6 +33,10 @@ public abstract class AbstractCmdLineToo
     }
   }
 
+  public boolean hasParams() {
+    return true;
+  }
+
   @SuppressWarnings({"unchecked"})
   protected <T> String getBasicHelp(Class<T> argProxyInterface) {
     return getBasicHelp(new Class[]{argProxyInterface});

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CLI.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CLI.java?rev=1361713&r1=1361712&r2=1361713&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CLI.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CLI.java Sun Jul 15 15:17:27 2012
@@ -207,7 +207,7 @@ public final class CLI {
         throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
       }
 
-      if (0 == toolArguments.length ||
+      if ((0 == toolArguments.length && tool.hasParams()) ||
           0 < toolArguments.length && "help".equals(toolArguments[0])) {
           if (tool instanceof TypedCmdLineTool) {
             System.out.println(((TypedCmdLineTool) tool).getHelp(formatName));

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java?rev=1361713&r1=1361712&r2=1361713&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java Sun Jul 15 15:17:27 2012
@@ -1,46 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package opennlp.tools.cmdline;
-
-/**
- * Base interface for all command line tools.
- */
-public interface CmdLineTool {
-
-  /**
-   * Retrieves the name of the training data tool. The name (used as command)
-   * must not contain white spaces.
-   *
-   * @return the name of the command line tool
-   */
-  String getName();
-
-  /**
-   * Retrieves a short description of what the tool does.
-   *
-   * @return a short description of what the tool does
-   */
-  String getShortDescription();
-
-  /**
-   * Retrieves a description on how to use the tool.
-   *
-   * @return a description on how to use the tool
-   */
-  String getHelp();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.cmdline;
+
+/**
+ * Base interface for all command line tools.
+ */
+public interface CmdLineTool {
+
+  /**
+   * Retrieves the name of the training data tool. The name (used as command)
+   * must not contain white spaces.
+   *
+   * @return the name of the command line tool
+   */
+  String getName();
+
+  /**
+   * Retrieves a short description of what the tool does.
+   *
+   * @return a short description of what the tool does
+   */
+  String getShortDescription();
+
+  /**
+   * Retrieves a description on how to use the tool.
+   *
+   * @return a description on how to use the tool
+   */
+  String getHelp();
+
+  /**
+   * Returns whether the tool has any command line params.
+   * @return whether the tool has any command line params
+   */
+  boolean hasParams();
+}

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java?rev=1361713&r1=1361712&r2=1361713&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java Sun Jul 15 15:17:27 2012
@@ -30,6 +30,11 @@ public final class SimpleTokenizerTool e
     return "Usage: " + CLI.CMD + " " + getName() + " < sentences";
   }
 
+  @Override
+  public boolean hasParams() {
+    return false;
+  }
+
   public void run(String[] args) {
     if (args.length != 0) {
       System.out.println(getHelp());