Search in sources :

Example 36 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project asterixdb by apache.

the class AbstractCommand method execute.

public void execute(String[] args) throws Exception {
    String[] cmdArgs = new String[args.length - 1];
    System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
    config = getCommandConfig();
    CmdLineParser parser = new CmdLineParser(config);
    parser.parseArgument(cmdArgs);
    execCommand();
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser)

Example 37 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project Anserini by castorini.

the class LookupObjectTriples method main.

public static void main(String[] args) throws Exception {
    Args searchArgs = new Args();
    // Parse args
    CmdLineParser parser = new CmdLineParser(searchArgs, ParserProperties.defaults().withUsageWidth(90));
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.err.println("Example command: " + LookupObjectTriples.class.getSimpleName() + parser.printExample(OptionHandlerFilter.REQUIRED));
        return;
    }
    new LookupObjectTriples(searchArgs.index).search(searchArgs.subject, searchArgs.predicate);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 38 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project Anserini by castorini.

the class TrainingDataGenerator method main.

public static void main(String[] args) throws Exception {
    Args trainingDataGeneratorArgs = new Args();
    CmdLineParser parser = new CmdLineParser(trainingDataGeneratorArgs, ParserProperties.defaults().withUsageWidth(90));
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.err.println("Example command: " + TrainingDataGenerator.class.getSimpleName() + parser.printExample(OptionHandlerFilter.REQUIRED));
        return;
    }
    LOG.info("Generating training data started...");
    new TrainingDataGenerator(trainingDataGeneratorArgs).generateTrainingData();
    LOG.info("Generating training data completed.");
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 39 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project Anserini by castorini.

the class JsonStatusCorpusReader method main.

public static void main(String[] argv) throws IOException {
    Args args = new Args();
    CmdLineParser parser = new CmdLineParser(args, ParserProperties.defaults().withUsageWidth(100));
    try {
        parser.parseArgument(argv);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.exit(-1);
    }
    long minId = Long.MAX_VALUE, maxId = Long.MIN_VALUE, cnt = 0;
    JsonStatusCorpusReader tweets = new JsonStatusCorpusReader(new File(args.input));
    Status tweet = null;
    while ((tweet = tweets.next()) != null) {
        cnt++;
        long id = tweet.getId();
        System.out.println("id: " + id);
        if (id < minId)
            minId = id;
        if (id > maxId)
            maxId = id;
        if (cnt % 100000 == 0) {
            System.out.println("Read " + cnt + " tweets");
        }
    }
    tweets.close();
    System.out.println("Read " + cnt + " in total.");
    System.out.println("MaxId = " + maxId);
    System.out.println("MinId = " + minId);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 40 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project Anserini by castorini.

the class JsonTweetsCollection method main.

public static void main(String[] argv) throws IOException {
    Args args = new Args();
    CmdLineParser parser = new CmdLineParser(args, ParserProperties.defaults().withUsageWidth(100));
    try {
        parser.parseArgument(argv);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
        System.exit(-1);
    }
    long minId = Long.MAX_VALUE, maxId = Long.MIN_VALUE, cnt = 0;
    JsonTweetsCollection tweets = new JsonTweetsCollection(new File(args.input));
    for (Status tweet : tweets) {
        cnt++;
        long id = tweet.getId();
        System.out.println("id: " + id);
        if (id < minId)
            minId = id;
        if (id > maxId)
            maxId = id;
        if (cnt % 100000 == 0) {
            System.out.println("Read " + cnt + " tweets");
        }
    }
    tweets.close();
    System.out.println("Read " + cnt + " in total.");
    System.out.println("MaxId = " + maxId);
    System.out.println("MinId = " + minId);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)208 CmdLineException (org.kohsuke.args4j.CmdLineException)165 IOException (java.io.IOException)45 File (java.io.File)27 Test (org.junit.Test)14 KeeperException (org.apache.zookeeper.KeeperException)12 ArrayList (java.util.ArrayList)11 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)10 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)10 Directory (org.apache.lucene.store.Directory)10 FSDirectory (org.apache.lucene.store.FSDirectory)10 JobId (org.apache.hyracks.api.job.JobId)9 JobSpecification (org.apache.hyracks.api.job.JobSpecification)9 ClientException (com.ms.silverking.cloud.dht.client.ClientException)8 PutException (com.ms.silverking.cloud.dht.client.PutException)8 SKGridConfiguration (com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration)8 PrintStream (java.io.PrintStream)8 List (java.util.List)8 RetrievalException (com.ms.silverking.cloud.dht.client.RetrievalException)7 IndexArgs (io.anserini.index.IndexArgs)7