当前位置: 首页>>代码示例>>Java>>正文


Java BasicCmdLineTool类代码示例

本文整理汇总了Java中opennlp.tools.cmdline.BasicCmdLineTool的典型用法代码示例。如果您正苦于以下问题:Java BasicCmdLineTool类的具体用法?Java BasicCmdLineTool怎么用?Java BasicCmdLineTool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BasicCmdLineTool类属于opennlp.tools.cmdline包,在下文中一共展示了BasicCmdLineTool类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import opennlp.tools.cmdline.BasicCmdLineTool; //导入依赖的package包/类
public static void main(String[] args) {

    if (args.length == 0) {
      usage();
      System.exit(0);
    }

    String toolArguments[] = new String[args.length -1];
    System.arraycopy(args, 1, toolArguments, 0, toolArguments.length);

    String toolName = args[0];

    //check for format
    String formatName = StreamFactoryRegistry.DEFAULT_FORMAT;
    int idx = toolName.indexOf(".");
    if (-1 < idx) {
      formatName = toolName.substring(idx + 1);
      toolName = toolName.substring(0, idx);
    }
    CmdLineTool tool = toolLookupMap.get(toolName);

    try {
      if (null == tool) {
        throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
      }

      if ((0 == toolArguments.length && tool.hasParams()) ||
          0 < toolArguments.length && "help".equals(toolArguments[0])) {
          if (tool instanceof TypedCmdLineTool) {
            System.out.println(((TypedCmdLineTool) tool).getHelp(formatName));
          } else if (tool instanceof BasicCmdLineTool) {
            System.out.println(tool.getHelp());
          }

          System.exit(0);
      }

      if (tool instanceof TypedCmdLineTool) {
        ((TypedCmdLineTool) tool).run(formatName, toolArguments);
      } else if (tool instanceof BasicCmdLineTool) {
        if (-1 == idx) {
          ((BasicCmdLineTool) tool).run(toolArguments);
        } else {
          throw new TerminateToolException(1, "Tool " + toolName + " does not support formats.");
        }
      } else {
        throw new TerminateToolException(1, "Tool " + toolName + " is not supported.");
      }
    }
    catch (TerminateToolException e) {

      if (e.getMessage() != null) {
        System.err.println(e.getMessage());
      }

      if (e.getCause() != null) {
        System.err.println(e.getCause().getMessage());
        e.getCause().printStackTrace(System.err);
      }

      System.exit(e.getCode());
    }
    
    System.out.println("Completed!");
    System.exit(1);
  }
 
开发者ID:datancoffee,项目名称:sirocco,代码行数:67,代码来源:CLI.java

示例2: main

import opennlp.tools.cmdline.BasicCmdLineTool; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
 public static void main(String[] args) {

  if (args.length == 0) {
    usage();
    System.exit(0);
  }

  String toolArguments[] = new String[args.length -1];
  System.arraycopy(args, 1, toolArguments, 0, toolArguments.length);

  String toolName = args[0];

  //check for format
  String formatName = StreamFactoryRegistry.DEFAULT_FORMAT;
  int idx = toolName.indexOf(".");
  if (-1 < idx) {
    formatName = toolName.substring(idx + 1);
    toolName = toolName.substring(0, idx);
  }
  CmdLineTool tool = toolLookupMap.get(toolName);

  try {
    if (null == tool) {
      throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
    }

    if ((0 == toolArguments.length && tool.hasParams()) ||
        0 < toolArguments.length && "help".equals(toolArguments[0])) {
        if (tool instanceof TypedCmdLineTool) {
          System.out.println(((TypedCmdLineTool) tool).getHelp(formatName));
        } else if (tool instanceof BasicCmdLineTool) {
          System.out.println(tool.getHelp());
        }

        System.exit(0);
    }

    if (tool instanceof TypedCmdLineTool) {
      ((TypedCmdLineTool) tool).run(formatName, toolArguments);
    } else if (tool instanceof BasicCmdLineTool) {
      if (-1 == idx) {
        ((BasicCmdLineTool) tool).run(toolArguments);
      } else {
        throw new TerminateToolException(1, "Tool " + toolName + " does not support formats.");
      }
    } else {
      throw new TerminateToolException(1, "Tool " + toolName + " is not supported.");
    }
  }
  catch (TerminateToolException e) {

    if (e.getMessage() != null) {
      System.err.println(e.getMessage());
    }

    if (e.getCause() != null) {
      System.err.println(e.getCause().getMessage());
      e.getCause().printStackTrace(System.err);
    }

    System.exit(e.getCode());
  }
}
 
开发者ID:apache,项目名称:opennlp-addons,代码行数:65,代码来源:CLI.java

示例3: main

import opennlp.tools.cmdline.BasicCmdLineTool; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length == 0) {
    usage();
    System.exit(0);
}

String toolArguments[] = new String[args.length -1];
System.arraycopy(args, 1, toolArguments, 0, toolArguments.length);

String toolName = args[0];

String formatName = DEFAULT_FORMAT;
int idx = toolName.indexOf(".");
if (-1 < idx) {
    formatName = toolName.substring(idx + 1);
    toolName = toolName.substring(0, idx);
}
CmdLineTool tool = toolLookupMap.get(toolName);

try {
    if (null == tool) {
	throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
    }

    if ((0 == toolArguments.length && tool.hasParams()) ||
	0 < toolArguments.length && "help".equals(toolArguments[0])) {
	if (tool instanceof TypedCmdLineTool) {
	    System.out.println(((TypedCmdLineTool) tool).getHelp(formatName));
	} else if (tool instanceof BasicCmdLineTool) {
	    System.out.println(tool.getHelp());
	}

	System.exit(0);
    }

    if (tool instanceof TypedCmdLineTool) {
	((TypedCmdLineTool) tool).run(formatName, toolArguments);
    } else if (tool instanceof BasicCmdLineTool) {
	if (-1 == idx) {
	    ((BasicCmdLineTool) tool).run(toolArguments);
	} else {
	    throw new TerminateToolException(1, "Tool " + toolName + " does not support formats.");
	}
    } else {
	throw new TerminateToolException(1, "Tool " + toolName + " is not supported.");
    }
}
catch (TerminateToolException e) {

    if (e.getMessage() != null) {
	System.err.println(e.getMessage());
    }

    if (e.getCause() != null) {
	System.err.println(e.getCause().getMessage());
	e.getCause().printStackTrace(System.err);
    }

    System.exit(e.getCode());
}
   }
 
开发者ID:USCDataScience,项目名称:AgePredictor,代码行数:62,代码来源:CLI.java


注:本文中的opennlp.tools.cmdline.BasicCmdLineTool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。