Class TypedCmdLineTool<T,P>

java.lang.Object
opennlp.tools.cmdline.CmdLineTool
opennlp.tools.cmdline.TypedCmdLineTool<T,P>
Direct Known Subclasses:
AbstractConverterTool, AbstractTypedParamTool

public abstract class TypedCmdLineTool<T,P> extends CmdLineTool
Base class for tools which support processing of samples of some type T coming from a stream of a certain format.
  • Field Details

    • type

      protected final Class<T> type
      variable to access the type of the generic parameter.
  • Constructor Details

    • TypedCmdLineTool

      protected TypedCmdLineTool(Class<T> sampleType)
      Constructor with type parameters.
      Parameters:
      sampleType - class of the template parameter
  • Method Details

    • getStreamFactory

      protected ObjectStreamFactory<T,P> getStreamFactory(String format)
      Returns stream factory for the type of this tool for the format.
      Parameters:
      format - data format name
      Returns:
      The factory for the type of this tool for the format.
    • validateAllArgs

      protected <A> void validateAllArgs(String[] args, Class<A> argProxyInterface, String format)
      Validates arguments using parameters from argProxyInterface and the parameters of the format.
      Type Parameters:
      A - The generic type.
      Parameters:
      args - arguments
      argProxyInterface - interface with parameter descriptions
      format - data format name
    • validateFactoryArgs

      protected void validateFactoryArgs(ObjectStreamFactory<T,P> factory, String[] args)
      Validates arguments for a format processed by the factory.
      Parameters:
      factory - The factory to use.
      args - arguments
    • getBasicHelp

      protected String getBasicHelp(Class<?>... argProxyInterfaces)
      Overrides:
      getBasicHelp in class CmdLineTool
    • getHelp

      public String getHelp()
      Specified by:
      getHelp in class CmdLineTool
      Returns:
      Retrieves a description on how to use the tool
    • run

      public abstract void run(String format, String[] args)
      Executes the tool with the given parameters.
      Parameters:
      format - format to work with
      args - command line arguments
    • getHelp

      public abstract String getHelp(String format)
      Parameters:
      format - data format
      Returns:
      Retrieves a description on how to use the tool.