Package org.apache.commons.cli2.option

Examples of org.apache.commons.cli2.option.Command


    try {
      Parser parser = new Parser();
     
      parser.setGroup(group);
      parser.setHelpOption(helpOpt);
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String classifierType = (String) cmdLine.getValue(typeOpt);
     
      if (cmdLine.hasOption(gramSizeOpt)) {
       
      }
     
      int gramSize = 1;
      if (cmdLine.hasOption(gramSizeOpt)) {
        gramSize = Integer.parseInt((String) cmdLine.getValue(gramSizeOpt));
      }

      int maxResults = 10;
      if (cmdLine.hasOption(maxResultsOpt)) {
        maxResults = Integer.parseInt((String) cmdLine.getValue(maxResultsOpt));
      }
     
      String inputPath  = (String) cmdLine.getValue(inputDirOpt);
      String modelPath = (String) cmdLine.getValue(modelOpt);
      String categoryField = (String) cmdLine.getValue(categoryFieldOpt);
      String contentField = (String) cmdLine.getValue(contentFieldOpt);
     
      MatchMode mode;
     
      if ("knn".equalsIgnoreCase(classifierType)) {
        mode = MatchMode.KNN;
View Full Code Here


   
    try {
     
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return false;
      }
     
      inputDirectory = new Path((String) cmdLine.getValue(inputDirOpt));
      trainingOutputDirectory = new Path((String) cmdLine.getValue(trainingOutputDirOpt));
      testOutputDirectory = new Path((String) cmdLine.getValue(testOutputDirOpt));
    
      charset = Charset.forName((String) cmdLine.getValue(charsetOpt));

      if (cmdLine.hasOption(testSplitSizeOpt) && cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option, not BOTH");
      } else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option");
      }

      if (cmdLine.hasOption(testSplitSizeOpt)) {
        setTestSplitSize(Integer.parseInt((String) cmdLine.getValue(testSplitSizeOpt)));
      }
     
      if (cmdLine.hasOption(testSplitPctOpt)) {
        setTestSplitPct(Integer.parseInt((String) cmdLine.getValue(testSplitPctOpt)));
      }
     
      if (cmdLine.hasOption(splitLocationOpt)) {
        setSplitLocation(Integer.parseInt((String) cmdLine.getValue(splitLocationOpt)));
      }
     
      if (cmdLine.hasOption(randomSelectionSizeOpt)) {
        setTestRandomSelectionSize(Integer.parseInt((String) cmdLine.getValue(randomSelectionSizeOpt)));
      }
     
      if (cmdLine.hasOption(randomSelectionPctOpt)) {
        setTestRandomSelectionPct(Integer.parseInt((String) cmdLine.getValue(randomSelectionPctOpt)));
      }

      fs.mkdirs(trainingOutputDirectory);
      fs.mkdirs(testOutputDirectory);
    
View Full Code Here

      .create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }

      File file = new File(cmdLine.getValue(inputOpt).toString());
     
      if (!file.isDirectory()) {
        throw new IllegalArgumentException(file + " does not exist or is not a directory");
      }
     
     
     
      long maxDocs = Long.MAX_VALUE;
      if (cmdLine.hasOption(maxOpt)) {
        maxDocs = Long.parseLong(cmdLine.getValue(maxOpt).toString());
      }
     
      if (maxDocs < 0) {
        throw new IllegalArgumentException("maxDocs must be >= 0");
      }

      String field = cmdLine.getValue(fieldOpt).toString();

      PrintWriter out = null;
      if (cmdLine.hasOption(outputOpt)) {
        out = new PrintWriter(new FileWriter(cmdLine.getValue(outputOpt).toString()));
      }
      else {
        out = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
      }
     
View Full Code Here

   
    Parser parser = new Parser();
    parser.setGroup(group);
   
    try {
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      File file;
      file = new File(cmdLine.getValue(wikipediaFileOpt).toString());
      File[] dumpFiles;
      if (file.isDirectory()) {
        dumpFiles = file.listFiles(new FilenameFilter() {
          public boolean accept(File file, String s) {
            return s.startsWith("freebase-segment-");
          }
        });
      } else {
        dumpFiles = new File[] {file};
      }
     
      int numDocs = Integer.MAX_VALUE;
      if (cmdLine.hasOption(numDocsOpt)) {
        numDocs = Integer.parseInt(cmdLine.getValue(numDocsOpt).toString());
      }
      String url = DEFAULT_SOLR_URL;
      if (cmdLine.hasOption(solrURLOpt)) {
        url = cmdLine.getValue(solrURLOpt).toString();
      }
      int batch = 100;
      if (cmdLine.hasOption(solrBatchOpt)) {
        batch = Integer.parseInt(cmdLine.getValue(solrBatchOpt).toString());
      }
      WikipediaWexIndexer indexer = new WikipediaWexIndexer(
          new CommonsHttpSolrServer(url));
      int total = 0;
      for (int i = 0; i < dumpFiles.length && total < numDocs; i++) {
View Full Code Here

    Option outputOpt = obuilder.withLongName("output").withRequired(true).withArgument(
      abuilder.withName("output").withMinimum(1).withMaximum(1).create()).withDescription(
      "The output directory").withShortName("o").create();
   
   
    Group group = gbuilder.withName("Options").withOption(helpOpt).withOption(
        inputDirOpt).withOption(outputOpt).create();
   
    //.withOption(gramSizeOpt).withOption(typeOpt)
   
    try {
View Full Code Here

   
    Option modelOpt = obuilder.withLongName("model").withRequired(true).withArgument(
      abuilder.withName("index").withMinimum(1).withMaximum(1).create()).withDescription(
      "The directory containing the index model").withShortName("m").create();

    Group group = gbuilder.withName("Options").withOption(helpOpt)
        .withOption(inputDirOpt).withOption(modelOpt).create();
   
    try {
      Parser parser = new Parser();
     
View Full Code Here

   
    Option typeOpt = obuilder.withLongName("classifierType").withRequired(false).withArgument(
      abuilder.withName("classifierType").withMinimum(1).withMaximum(1).create()).withDescription(
      "Type of classifier: knn|tfidf. Default: bayes").withShortName("type").create();
   
    Group group = gbuilder.withName("Options").withOption(gramSizeOpt).withOption(helpOpt).withOption(
        inputDirOpt).withOption(modelOpt).withOption(typeOpt).withOption(contentFieldOpt)
        .withOption(categoryFieldOpt).withOption(maxResultsOpt)
        .create();
   
    try {
View Full Code Here

   
    Option helpOpt = obuilder.withLongName("help")
      .withDescription("Print out help")
      .withShortName("h").create();
   
    Group group = gbuilder.withName("Options")
      .withOption(inputOpt)
      .withOption(categoryOpt)
      .withOption(outputOpt)
      .withOption(categoryFieldsOpt)
      .withOption(textFieldsOpt)
View Full Code Here

   
    Option testDataSizeOpt = obuilder.withLongName("testDataSize").withRequired(false).withArgument(
        abuilder.withName("testDataSize").withMinimum(1).withMaximum(1).create()).withDescription(
        "The number of questions to extract for training data").withShortName("tes").create();

    Group group = gbuilder.withName("Options").withOption(inputFileOpt).withOption(trainingOutputOpt)
         .withOption(testOutputOpt).withOption(trainingDataSizeOpt).withOption(testDataSizeOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
View Full Code Here

   
    Option solrUrlOpt = obuilder.withLongName("solrUrl").withRequired(true).withArgument(
        abuilder.withName("solrUrl").withMinimum(1).withMaximum(1).create()).withDescription(
        "URL of the solr server").withShortName("s").create();
   
    Group group = gbuilder.withName("Options")
      .withOption(inputFileOpt)
      .withOption(countFileOpt)
      .withOption(outputFileOpt)
      .withOption(solrUrlOpt).create();
   
View Full Code Here

TOP

Related Classes of org.apache.commons.cli2.option.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.