Package com.google.gxp.compiler.cli

Examples of com.google.gxp.compiler.cli.GxpcFlags$CommandLine


   
    Parser parser = new Parser();
    parser.setGroup(group);
   
    try {
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String dataset = cmdLine.getValue(inputOpt).toString();
      int target = Integer.parseInt(cmdLine.getValue(labelOpt).toString());
      double threshold = !cmdLine.hasOption(thresholdOpt) ? 0.5 : Double.parseDouble(cmdLine.getValue(
        thresholdOpt).toString());
      int crosspnts = !cmdLine.hasOption(crosspntsOpt) ? 1 : Integer.parseInt(cmdLine.getValue(crosspntsOpt)
          .toString());
      double mutrate = Double.parseDouble(cmdLine.getValue(mutrateOpt).toString());
      double mutrange = !cmdLine.hasOption(mutrangeOpt) ? 0.1 : Double.parseDouble(cmdLine.getValue(
        mutrangeOpt).toString());
      int mutprec = !cmdLine.hasOption(mutprecOpt) ? 2 : Integer.parseInt(cmdLine.getValue(mutprecOpt)
          .toString());
      int popSize = Integer.parseInt(cmdLine.getValue(popsizeOpt).toString());
      int genCount = Integer.parseInt(cmdLine.getValue(gencntOpt).toString());
     
      long start = System.currentTimeMillis();
     
      runJob(dataset, target, threshold, crosspnts, mutrate, mutrange, mutprec, popSize, genCount);
     
View Full Code Here


        .withOption(maxLabelsOpt).withOption(minClusterSizeOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String seqFileDir = cmdLine.getValue(seqOpt).toString();
      String pointsDir = cmdLine.getValue(pointsOpt).toString();
      String indexDir = cmdLine.getValue(indexOpt).toString();
      String contentField = cmdLine.getValue(fieldOpt).toString();
     
      String idField = null;
     
      if (cmdLine.hasOption(idFieldOpt)) {
        idField = cmdLine.getValue(idFieldOpt).toString();
      }
      String output = null;
      if (cmdLine.hasOption(outputOpt)) {
        output = cmdLine.getValue(outputOpt).toString();
      }
      int maxLabels = DEFAULT_MAX_LABELS;
      if (cmdLine.hasOption(maxLabelsOpt)) {
        maxLabels = Integer.parseInt(cmdLine.getValue(maxLabelsOpt).toString());
      }
      int minSize = DEFAULT_MIN_IDS;
      if (cmdLine.hasOption(minClusterSizeOpt)) {
        minSize = Integer.parseInt(cmdLine.getValue(minClusterSizeOpt).toString());
      }
      ClusterLabels clusterLabel = new ClusterLabels(seqFileDir, pointsDir, indexDir, contentField, minSize,
          maxLabels);
     
      if (idField != null) {
View Full Code Here

        .create();
   
    Parser parser = new Parser();
    parser.setGroup(group);
    try {
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String inputPath = (String) cmdLine.getValue(dirInputPathOpt);
      String outputPath = (String) cmdLine.getValue(dirOutputPathOpt);
      String catFile = (String) cmdLine.getValue(categoriesOpt);
      Class<? extends Analyzer> analyzerClass = WikipediaAnalyzer.class;
      if (cmdLine.hasOption(analyzerOpt)) {
        String className = cmdLine.getValue(analyzerOpt).toString();
        analyzerClass = (Class<? extends Analyzer>) Class.forName(className);
        // try instantiating it, b/c there isn't any point in setting it if
        // you can't instantiate it
        analyzerClass.newInstance();
      }
      runJob(inputPath, outputPath, catFile, cmdLine.hasOption(exactMatchOpt),
        analyzerClass);
    } catch (OptionException e) {
      log.error("Exception", e);
      CommandLineUtil.printHelp(group);
    } catch (ClassNotFoundException e) {
View Full Code Here

        .withOption(helpOpt).withOption(dictOutOpt).withOption(outWriterOpt).withOption(delimiterOpt)
        .create();
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
       
        CommandLineUtil.printHelp(group);
        return;
      }
      if (cmdLine.hasOption(inputOpt)) { // Lucene case
        File input = new File(cmdLine.getValue(inputOpt).toString());
        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 outDir = cmdLine.getValue(outputOpt).toString();
        log.info("Output Dir: {}", outDir);
        String outWriter = null;
        if (cmdLine.hasOption(outWriterOpt)) {
          outWriter = cmdLine.getValue(outWriterOpt).toString();
        }
        String delimiter = cmdLine.hasOption(delimiterOpt) ? cmdLine.getValue(delimiterOpt).toString() : "\t";
        File dictOut = new File(cmdLine.getValue(dictOutOpt).toString());
        ARFFModel model = new MapBackedARFFModel();
        if (input.exists() && input.isDirectory()) {
          File[] files = input.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File file, String name) {
View Full Code Here

        .create();
   
    Parser parser = new Parser();
    parser.setGroup(group);
    try {
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String inputPath = (String) cmdLine.getValue(dirInputPathOpt);
      String outputPath = (String) cmdLine.getValue(dirOutputPathOpt);
     
      String catFile = "";
      if (cmdLine.hasOption(categoriesOpt)) {
        catFile = (String) cmdLine.getValue(categoriesOpt);
      }
     
      boolean all = false;
      if (cmdLine.hasOption(allOpt)) {
        all = true;
      }
      runJob(inputPath, outputPath, catFile, cmdLine.hasOption(exactMatchOpt), all);
    } catch (OptionException e) {
      log.error("Exception", e);
      CommandLineUtil.printHelp(group);
    }
  }
View Full Code Here

        .withOption(dictTypeOpt).withOption(numWordsOpt).create();

    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
      if (!cmdLine.hasOption(seqOpt)) {
        return;
      }
      String seqFileDir = cmdLine.getValue(seqOpt).toString();
      String termDictionary = null;
      if (cmdLine.hasOption(dictOpt)) {
        termDictionary = cmdLine.getValue(dictOpt).toString();
      }

      String pointsDir = null;
      if (cmdLine.hasOption(pointsOpt)) {
        pointsDir = cmdLine.getValue(pointsOpt).toString();
      }
      String outputFile = null;
      if (cmdLine.hasOption(outputOpt)) {
        outputFile = cmdLine.getValue(outputOpt).toString();
      }

      int sub = -1;
      if (cmdLine.hasOption(substringOpt)) {
        sub = Integer.parseInt(cmdLine.getValue(substringOpt).toString());
      }

      ClusterDumper clusterDumper = new ClusterDumper(seqFileDir, pointsDir);
      if (cmdLine.hasOption(centroidJSonOpt)) {
        clusterDumper.setUseJSON(true);
      }

      if (outputFile != null) {
        clusterDumper.setOutputFile(outputFile);
      }

      String dictionaryType = "text";
      if (cmdLine.hasOption(dictTypeOpt)) {
        dictionaryType = cmdLine.getValue(dictTypeOpt).toString();
      }

      if (termDictionary != null) {
        clusterDumper.setTermDictionary(termDictionary, dictionaryType);
      }

      if (cmdLine.hasOption(numWordsOpt)) {
        int numWords = Integer.parseInt(cmdLine.getValue(numWordsOpt).toString());
        clusterDumper.setNumTopFeatures(numWords);
      }

      if (sub >= 0) {
        clusterDumper.setSubString(sub);
View Full Code Here

    Group group = gbuilder.withName("Options").withOption(dictOpt).withOption(outOpt).withOption(wordOpt)
        .withOption(inputOpt).withOption(dictTypeOpt).create();
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String input = cmdLine.getValue(inputOpt).toString();
      String dictFile = cmdLine.getValue(dictOpt).toString();
      int numWords = 20;
      if (cmdLine.hasOption(wordOpt)) {
        numWords = Integer.parseInt(cmdLine.getValue(wordOpt).toString());
      }
      Configuration config = new Configuration();
     
      String dictionaryType = "text";
      if (cmdLine.hasOption(dictTypeOpt)) {
        dictionaryType = cmdLine.getValue(dictTypeOpt).toString();
      }
     
      List<String> wordList;
      if (dictionaryType.equals("text")) {
        wordList = Arrays.asList(VectorHelper.loadTermDictionary(new File(dictFile)));
      } else if (dictionaryType.equals("sequencefile")) {
        FileSystem fs = FileSystem.get(new Path(dictFile).toUri(), config);
        wordList = Arrays.asList(VectorHelper.loadTermDictionary(config, fs, dictFile));
      } else {
        throw new IllegalArgumentException("Invalid dictionary format");
      }
     
      List<List<String>> topWords = topWordsForTopics(input, config, wordList, numWords);
     
      if (cmdLine.hasOption(outOpt)) {
        File output = new File(cmdLine.getValue(outOpt).toString());
        if (!output.exists()) {
          if (!output.mkdirs()) {
            throw new IOException("Could not create directory: " + output);
          }
        }
View Full Code Here

          mOpt).withOption(topicsOpt).withOption(helpOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      String input = cmdLine.getValue(inputOpt).toString();
      String output = cmdLine.getValue(outputOpt).toString();
      String modelFactory = "org.apache.mahout.clustering.dirichlet.models.NormalModelDistribution";
      if (cmdLine.hasOption(modelOpt)) modelFactory = cmdLine.getValue(modelOpt).toString();
      String modelPrototype = "org.apache.mahout.math.RandomAccessSparseVector";
      if (cmdLine.hasOption(prototypeOpt)) modelPrototype = cmdLine.getValue(prototypeOpt).toString();
      int prototypeSize = Integer.parseInt(cmdLine.getValue(sizeOpt).toString());
      int numModels = Integer.parseInt(cmdLine.getValue(topicsOpt).toString());
      int maxIterations = Integer.parseInt(cmdLine.getValue(maxIterOpt).toString());
      double alpha_0 = Double.parseDouble(cmdLine.getValue(mOpt).toString());
      runJob(input, output, modelFactory, modelPrototype, prototypeSize, numModels, maxIterations, alpha_0);
    } catch (OptionException e) {
      log.error("Exception parsing command line: ", e);
      CommandLineUtil.printHelp(group);
    }
View Full Code Here

          helpOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
      String input = cmdLine.getValue(inputOpt).toString();
      String clusters = cmdLine.getValue(clustersOpt).toString();
      String output = cmdLine.getValue(outputOpt).toString();
      String measureClass = SquaredEuclideanDistanceMeasure.class.getName();
      if (cmdLine.hasOption(measureClassOpt)) {
        measureClass = cmdLine.getValue(measureClassOpt).toString();
      }
      double convergenceDelta = 0.5;
      if (cmdLine.hasOption(convergenceDeltaOpt)) {
        convergenceDelta = Double.parseDouble(cmdLine.getValue(convergenceDeltaOpt).toString());
      }
      float m = Float.parseFloat(cmdLine.getValue(mOpt).toString());
     
      // Class<? extends Vector> vectorClass = cmdLine.hasOption(vectorClassOpt) == false ?
      // RandomAccessSparseVector.class
      // : (Class<? extends Vector>) Class.forName(cmdLine.getValue(vectorClassOpt).toString());
     
      int numReduceTasks = 10;
      if (cmdLine.hasOption(numReduceTasksOpt)) {
        numReduceTasks = Integer.parseInt(cmdLine.getValue(numReduceTasksOpt).toString());
      }
     
      int numMapTasks = 50;
      if (cmdLine.hasOption(numMapTasksOpt)) {
        numMapTasks = Integer.parseInt(cmdLine.getValue(numMapTasksOpt).toString());
      }
     
      int maxIterations = 20;
      if (cmdLine.hasOption(maxIterationsOpt)) {
        maxIterations = Integer.parseInt(cmdLine.getValue(maxIterationsOpt).toString());
      }
     
      if (cmdLine.hasOption(overwriteOutput)) {
        HadoopUtil.overwriteOutput(output);
      }
     
      if (cmdLine.hasOption(kOpt)) {
        clusters = RandomSeedGenerator.buildRandom(input, clusters,
          Integer.parseInt(cmdLine.getValue(kOpt).toString())).toString();
      }
     
      if (cmdLine.hasOption(clusteringOpt)) {
        runClustering(input, clusters, output, measureClass, convergenceDelta, numMapTasks,
          m);
      } else {
        runJob(input, clusters, output, measureClass, convergenceDelta, maxIterations,
          numMapTasks, numReduceTasks, m);
View Full Code Here

          vectorClassOpt).withOption(helpOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
      String input = cmdLine.getValue(inputOpt).toString();
      String clusters = cmdLine.getValue(clustersOpt).toString();
      String output = cmdLine.getValue(outputOpt).toString();
      String measureClass = cmdLine.getValue(measureClassOpt).toString();
      double convergenceDelta = Double.parseDouble(cmdLine.getValue(convergenceDeltaOpt).toString());
      int maxIterations = Integer.parseInt(cmdLine.getValue(maxIterOpt).toString());
      int numMapTasks = Integer.parseInt(cmdLine.getValue(numMapOpt).toString());
      int numReduceTasks = Integer.parseInt(cmdLine.getValue(numRedOpt).toString());
      boolean doCanopy = Boolean.parseBoolean(cmdLine.getValue(doCanopyOpt).toString());
      float m = Float.parseFloat(cmdLine.getValue(mOpt).toString());
      // String vectorClassName = cmdLine.getValue(vectorClassOpt).toString();
      // Class<? extends Vector> vectorClass = (Class<? extends Vector>) Class.forName(vectorClassName);
      runJob(input, clusters, output, measureClass, convergenceDelta, maxIterations,
        numMapTasks, numReduceTasks, doCanopy, m);
    } catch (OptionException e) {
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.cli.GxpcFlags$CommandLine

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.