Package org.apache.commons.cli2

Examples of org.apache.commons.cli2.OptionException


        if ("tf".equalsIgnoreCase(wString)) {
          processIdf = false;
        } else if ("tfidf".equalsIgnoreCase(wString)) {
          processIdf = true;
        } else {
          throw new OptionException(weightOpt);
        }
      } else {
        processIdf = true;
      }
     
View Full Code Here


          if ("text".equals(dictionaryType)) {
            dictionary = VectorHelper.loadTermDictionary(new File(cmdLine.getValue(dictOpt).toString()));
          } else if ("sequencefile".equals(dictionaryType)) {
            dictionary = VectorHelper.loadTermDictionary(conf, cmdLine.getValue(dictOpt).toString());
          } else {
            throw new OptionException(dictTypeOpt);
          }
        }

        Set<String> filters;
        if (cmdLine.hasOption(filtersOpt)) {
View Full Code Here

          if ("tf".equalsIgnoreCase(wString)) {
            weight = new TF();
          } else if ("tfidf".equalsIgnoreCase(wString)) {
            weight = new TFIDF();
          } else {
            throw new OptionException(weightOpt);
          }
        } else {
          weight = new TFIDF();
        }
View Full Code Here

          if ("text".equals(dictionaryType)) {
            dictionary = VectorHelper.loadTermDictionary(new File(cmdLine.getValue(dictOpt).toString()));
          } else if ("sequencefile".equals(dictionaryType)) {
            dictionary = VectorHelper.loadTermDictionary(conf, fs, cmdLine.getValue(dictOpt).toString());
          } else {
            throw new OptionException(dictTypeOpt);
          }
        }
        boolean useJSON = cmdLine.hasOption(centroidJSonOpt);
        boolean sizeOnly = cmdLine.hasOption(sizeOpt);
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

        if ("tf".equalsIgnoreCase(wString)) {
          processIdf = false;
        } else if ("tfidf".equalsIgnoreCase(wString)) {
          processIdf = true;
        } else {
          throw new OptionException(weightOpt);
        }
      } else {
        processIdf = true;
      }
     
View Full Code Here

    public void process(final WriteableCommandLine commandLine, final ListIterator arguments)
        throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, arg);
      }

      ArrayList properties = new ArrayList();
      String next = "";
      while (arguments.hasNext()) {
        next = (String) arguments.next();
        if (!next.startsWith("-")) {

          if (next.indexOf("=") == -1) {
            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, "argument: '"
                + next + "' is not of the form x=y");
          }
          properties.add(next);
        } else {
          arguments.previous();
View Full Code Here

    public void process(final WriteableCommandLine commandLine,
                        final ListIterator arguments) throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this,
                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
      }
     
      ArrayList properties = new ArrayList();
      String next = "";
View Full Code Here

        if ("tf".equalsIgnoreCase(wString)) {
          processIdf = false;
        } else if ("tfidf".equalsIgnoreCase(wString)) {
          processIdf = true;
        } else {
          throw new OptionException(weightOpt);
        }
      } else {
        processIdf = true;
      }
View Full Code Here

      useMapRed = getOption(DefaultOptionCreator.METHOD_OPTION).equalsIgnoreCase(DefaultOptionCreator.MAPREDUCE_METHOD);

      if (useMapRed) {
        if (!hasOption("randomSelectionPct")) {
          throw new OptionException(getCLIOption("randomSelectionPct"),
                  "must set randomSelectionPct when mapRed option is used");
        }
        if (!hasOption("mapRedOutputDir")) {
          throw new OptionException(getCLIOption("mapRedOutputDir"),
                                    "mapRedOutputDir must be set when mapRed option is used");
        }
        mapRedOutputDirectory = new Path(getOption("mapRedOutputDir"));
        if (hasOption("keepPct")) {
          keepPct = Integer.parseInt(getOption("keepPct"));
        }
        if (hasOption(DefaultOptionCreator.OVERWRITE_OPTION)) {
          HadoopUtil.delete(getConf(), mapRedOutputDirectory);
        }
      } else {
        if (!hasOption("trainingOutput")
                || !hasOption("testOutput")) {
          throw new OptionException(getCLIOption("trainingOutput"),
                  "trainingOutput and testOutput must be set if mapRed option is not used");
        }
        if (!hasOption("testSplitSize")
                && !hasOption("testSplitPct")
                && !hasOption("randomSelectionPct")
                && !hasOption("randomSelectionSize")) {
          throw new OptionException(getCLIOption("testSplitSize"),
                  "must set one of test split size/percentage or randomSelectionSize/percentage");
        }

        trainingOutputDirectory = new Path(getOption("trainingOutput"));
        testOutputDirectory = new Path(getOption("testOutput"));
        FileSystem fs = trainingOutputDirectory.getFileSystem(getConf());
        if (hasOption(DefaultOptionCreator.OVERWRITE_OPTION)) {
          HadoopUtil.delete(fs.getConf(), trainingOutputDirectory);
          HadoopUtil.delete(fs.getConf(), testOutputDirectory);
        }
        fs.mkdirs(trainingOutputDirectory);
        fs.mkdirs(testOutputDirectory);
      }

      if (hasOption("charset")) {
        charset = Charset.forName(getOption("charset"));
      }

      if (hasOption("testSplitSize") && hasOption("testSplitPct")) {
        throw new OptionException(getCLIOption("testSplitPct"), "must have either split size or split percentage "
            + "option, not BOTH");
      }

      if (hasOption("testSplitSize")) {
        setTestSplitSize(Integer.parseInt(getOption("testSplitSize")));
View Full Code Here

    public void process(final WriteableCommandLine commandLine,
                        final ListIterator arguments) throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this,
                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
      }
     
      ArrayList properties = new ArrayList();
      String next = "";
View Full Code Here

TOP

Related Classes of org.apache.commons.cli2.OptionException

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.