本文整理汇总了Java中com.martiansoftware.jsap.JSAPResult类的典型用法代码示例。如果您正苦于以下问题:Java JSAPResult类的具体用法?Java JSAPResult怎么用?Java JSAPResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSAPResult类属于com.martiansoftware.jsap包,在下文中一共展示了JSAPResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadConfigFiles
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
/**
* Load in the configuration files
* @throws SimulatorException
*
*/
public SpaceSettlersConfig loadConfigFiles(JSAPResult parserConfig) throws SimulatorException {
String configFile = parserConfig.getString("configPath") + parserConfig.getString("simulatorConfigFile");
XStream xstream = new XStream();
xstream.alias("SpaceSettlersConfig", SpaceSettlersConfig.class);
xstream.alias("HighLevelTeamConfig", HighLevelTeamConfig.class);
xstream.alias("BaseConfig", BaseConfig.class);
xstream.alias("AsteroidConfig", RandomAsteroidConfig.class);
xstream.alias("FixedAsteroidConfig", FixedAsteroidConfig.class);
xstream.alias("FlagConfig", FlagConfig.class);
try {
simConfig = (SpaceSettlersConfig) xstream.fromXML(new File(configFile));
} catch (Exception e) {
throw new SimulatorException("Error parsing config file at string " + e.getMessage());
}
return simConfig;
}
示例2: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main(final String[] arguments)
{
try
{
final SimpleJSAP jsap = new SimpleJSAP(
"Main Application",
"Demonstrate JSAP",
new Parameter[]
{new FlaggedOption("file", STRING_PARSER, NO_DEFAULT, REQUIRED, 'f', "file", "File path/name."),
new Switch("verbose", 'v', "verbose", "Requests verbose output." )});
final JSAPResult parsedResult = jsap.parse(arguments);
if (jsap.messagePrinted())
{
out.println(jsap.getHelp());
System.exit( -1 );
}
out.println("File path/name is '" + parsedResult.getString("file") + "'.");
out.println("Verbosity level is " + parsedResult.getBoolean("verbose"));
}
catch (JSAPException jsapException)
{
out.println("Exception encountered during parsing command line arguments - " + jsapException);
}
}
示例3: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main(String[] arg) throws IOException, JSAPException {
final SimpleJSAP jsap = new SimpleJSAP(GZIPIndexer.class.getName(), "Computes and stores a quasi-succinct index for a compressed archive.",
new Parameter[] {
new UnflaggedOption("archive", JSAP.STRING_PARSER, JSAP.REQUIRED, "The name a GZIP's archive."),
new UnflaggedOption("index", JSAP.STRING_PARSER, JSAP.REQUIRED, "The output (a serialized LongBigList of pointers to the records in the archive) filename."),
}
);
final JSAPResult jsapResult = jsap.parse(arg);
if (jsap.messagePrinted()) return;
final FastBufferedInputStream input = new FastBufferedInputStream(new FileInputStream(jsapResult.getString("archive")));
ProgressLogger pl = new ProgressLogger(LOGGER, 1, TimeUnit.MINUTES, "records");
pl.start("Scanning...");
final EliasFanoMonotoneLongBigList list = new EliasFanoMonotoneLongBigList(index(input, pl));
pl.done();
BinIO.storeObject(list, jsapResult.getString("index"));
}
示例4: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main(String[] args) throws IOException, JSAPException {
SimpleJSAP jsap = new SimpleJSAP(GZIPArchiveReader.class.getName(), "Writes some random records on disk.",
new Parameter[] {
new Switch("fully", 'f', "fully",
"Whether to read fully the record (and do a minimal cosnsistency check)."),
new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
"The path to read from."), });
JSAPResult jsapResult = jsap.parse(args);
if (jsap.messagePrinted())
System.exit(1);
final boolean fully = jsapResult.getBoolean("fully");
GZIPArchiveReader gzar = new GZIPArchiveReader(new FileInputStream(jsapResult.getString("path")));
for (;;) {
ReadEntry e = gzar.getEntry();
if (e == null)
break;
InputStream inflater = e.lazyInflater.get();
if (fully)
ByteStreams.toByteArray(inflater);
e.lazyInflater.consume();
System.out.println(e);
}
}
示例5: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main( String[] args ) throws Exception {
SimpleJSAP jsap = new SimpleJSAP( FormatReader.class.getName(), "Tests the reading format", new Parameter[]{ new FlaggedOption( "input", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'i', "input", "Input file" ), } );
JSAPResult jsapResult = jsap.parse( args );
if( jsap.messagePrinted() ) return;
final Iterable<StringAndCandidate> stringAndCandidates = FormatReader.stringAndCandidates( jsapResult.getString( "input" ), 0, 0 );
int bogus = 0;
int numberOfCandidates = 0;
for( StringAndCandidate sc : stringAndCandidates ) {
CandidatesInfo ci = sc.candidatesInfo;
if( ci.QAF == 0 && ci.LAF == 0 && ci.LAT == 0 && ci.QAC == 0 && ci.QAT == 0 ) bogus++;
numberOfCandidates++;
if( sc.surfaceForm.contains( "brad pitt" ) ) System.out.println( sc.surfaceForm + "\n" + ci );
}
LOGGER.info( "Candidates with all zeros : " + bogus );
LOGGER.info( "Number of candidates:" + numberOfCandidates );
}
示例6: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main(String[] rawArguments) throws JSAPException, IOException, ReflectiveOperationException {
SimpleJSAP jsap = new SimpleJSAP(
ScorerStatisticsSummarizer.class.getName(),
"Compute summary statistics for a scorer ",
new Parameter[] {
new UnflaggedOption( "scorer", JSAP.STRING_PARSER, JSAP.REQUIRED,
"Specification for the scorer" ),
new UnflaggedOption( "output", JSAP.STRING_PARSER, JSAP.REQUIRED,
"Filepath of the saved statistics summary, saved as a Property file." ),
});
// parse arguments
JSAPResult args = jsap.parse( rawArguments );
if ( jsap.messagePrinted() ) System.exit( 1 );
String scorerSpec = args.getString("scorer");
UnexpectednessScorer scorer = (UnexpectednessScorer) PoolSpecification.SCORER_PARSER.parse(scorerSpec);
SummaryStatistics stat = computeStatistics(scorer);
save(stat, new File(args.getString("output")), scorerSpec);
System.out.println(scorer + " " + stat);
}
示例7: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main( final String[] arg ) throws IOException, JSAPException {
final SimpleJSAP simpleJSAP = new SimpleJSAP( JungAdapter.class.getName(), "Reads a graph with a given basename, optionally its transpose, and writes it on standard output in Pajek format.",
new Parameter[] {
new Switch( "offline", 'o', "offline", "Use the offline load method to reduce memory consumption. It usually works, but your mileage may vary." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph." ),
new UnflaggedOption( "transpose", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the transpose. If unspecified, the JungAdapter constructor will be provided with null as a parameter. This usually works, but your mileage may vary." )
});
final JSAPResult jsapResult = simpleJSAP.parse( arg );
if ( simpleJSAP.messagePrinted() ) System.exit( 1 );
final boolean offline = jsapResult.userSpecified( "offline" );
final ImmutableGraph graph = offline ? ImmutableGraph.loadOffline( jsapResult.getString( "basename" ) ) : ImmutableGraph.load( jsapResult.getString( "basename" ) );
final ImmutableGraph transpose = jsapResult.userSpecified( "transpose" ) ? ( offline ? ImmutableGraph.loadOffline( jsapResult.getString( "transpose" ) ) : ImmutableGraph.load( jsapResult.getString( "transpose" ) ) ) : null;
final PrintWriter printWriter = new PrintWriter( System.out );
new PajekNetWriter<Integer, Long>().save( new JungAdapter( graph, transpose ), printWriter );
printWriter.flush();
}
示例8: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, JSAPException, UnsupportedEncodingException, FileNotFoundException {
final SimpleJSAP jsap = new SimpleJSAP( ImmutableSubgraph.class.getName(), "Writes the property file of an immutable subgraph.",
new Parameter[] {
new UnflaggedOption( "supergraphBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the supergraph." ),
new FlaggedOption( "subgraphNodes", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 's', "subgraph-nodes", "Sets a subgraph node file (a list integers in DataInput format). If not specified, the name will be stemmed from the basename." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of resulting immutable subgraph." ),
}
);
final JSAPResult jsapResult = jsap.parse( args );
if ( jsap.messagePrinted() ) System.exit( 1 );
final PrintWriter pw = new PrintWriter( new OutputStreamWriter( new FileOutputStream( jsapResult.getString( "basename" ) + ImmutableGraph.PROPERTIES_EXTENSION ), "UTF-8" ) );
pw.println( ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + ImmutableSubgraph.class.getName() );
pw.println( "supergraphbasename = " + jsapResult.getString( "supergraphBasename" ) );
if ( jsapResult.userSpecified( "subgraphNodes" ) ) pw.println( "subgraphnodes = " + jsapResult.getString( "subgraphNodes" ) );
pw.close();
}
示例9: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
SimpleJSAP jsap = new SimpleJSAP( SequentialHyperBall.class.getName(), "Prints an approximation of the neighbourhood function.",
new Parameter[] {
new FlaggedOption( "log2m", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'l', "log2m", "The logarithm of the number of registers." ),
new FlaggedOption( "upperBound", JSAP.LONGSIZE_PARSER, Long.toString( Long.MAX_VALUE ), JSAP.NOT_REQUIRED, 'u', "upper-bound", "An upper bound to the number of iteration (default: the graph size)." ),
new FlaggedOption( "threshold", JSAP.DOUBLE_PARSER, Double.toString( 1E-3 ), JSAP.NOT_REQUIRED, 't', "threshould", "A threshould that will be used to stop the computation by absolute or relative increment." ),
new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
}
);
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final boolean spec = jsapResult.getBoolean( "spec" );
final String basename = jsapResult.getString( "basename" );
final ProgressLogger pl = new ProgressLogger( LOGGER );
final int log2m = jsapResult.getInt( "log2m" );
final ImmutableGraph graph = spec ? ObjectParser.fromSpec( basename, ImmutableGraph.class, GraphClassParser.PACKAGE ) : ImmutableGraph.loadOffline( basename );
SequentialHyperBall shb = new SequentialHyperBall( graph, log2m, pl, Util.randomSeed() );
TextIO.storeDoubles( shb.approximateNeighbourhoodFunction( jsapResult.getLong( "upperBound" ), jsapResult.getDouble( "threshold" ) ), System.out );
shb.close();
}
示例10: main
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
SimpleJSAP jsap = new SimpleJSAP( ExactNeighbourhoodFunction.class.getName(), "Prints the neighbourhood function.",
new Parameter[] {
new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
}
);
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final boolean spec = jsapResult.getBoolean( "spec" );
final String basename = jsapResult.getString( "basename" );
final ProgressLogger pl = new ProgressLogger( LOGGER );
final ImmutableGraph graph = spec ? ObjectParser.fromSpec( basename, ImmutableGraph.class, GraphClassParser.PACKAGE ) : ImmutableGraph.loadOffline( basename );
final ExactNeighbourhoodFunction neighbourhoodFunction = new ExactNeighbourhoodFunction( graph, pl );
pl.start( "Computing..." );
TextIO.storeDoubles( neighbourhoodFunction.neighbourhoodFunction(), System.out );
pl.done();
}
示例11: CLIBuilder
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
protected CLIBuilder(String[] args, String name) throws PEException {
this.name = buildToolBannerName(name);
logger.debug("Create CLIBuilder " + this.name);
currentCommandMap = createCommandMap(DEFAULT_MAP);
changeMode(currentCommandMap);
if ((args != null) && (args.length > 0)) {
try {
final SimpleJSAP jsap = new SimpleJSAP(this.name, null, ARGS);
final JSAPResult options = jsap.parse(args);
if (jsap.messagePrinted()) {
System.exit(0);
}
processArgs(options);
} catch (final JSAPException e) {
throw new PEException("Error: Failed to parse " + this.name + " command line parameters", e);
}
}
}
示例12: processArgs
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
private void processArgs(JSAPResult options) throws PEException {
displayVersion = options.getBoolean("version");
suppressWelcome = options.getBoolean("suppressWelcome");
emulateReader = options.getBoolean("emulateReader");
final String filename = options.getString("file");
final String cmd = options.getString("cmd");
if (filename != null) {
try {
fileInputStream = new FileInputStream(filename);
} catch (final Exception e) {
throw new PEException("Failed to open file '" + filename + "'", e);
}
} else if (cmd != null) {
singleCommand = cmd;
}
}
示例13: Indexer
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
public Indexer(JSAPResult config) throws IOException {
String outputPath = config.getString(OUTPUT_PATH, "<NONE>");
if (!outputPath.equals("<NONE>")) {
SimpleFSDirectory idx_dir = new SimpleFSDirectory(new File(
outputPath));
IndexWriterConfig indexConfig = new IndexWriterConfig(
Version.LUCENE_4_10_2, analyzer);
this.writer = new IndexWriter(idx_dir, indexConfig);
} else {
this.writer = null;
}
this.joiner = Joiner.on(" ").skipNulls();
this.config = config;
Options options = new Options();
options.createIfMissing(true);
leveldb = factory.open(new File(outputPath, "leveldb"), options);
}
示例14: getNextCommand
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
@Override
protected Command getNextCommand() throws Exception {
String nextCommandAsString = reader.readLine();
if (EXIT_COMMAND.equals(nextCommandAsString)) {
hasMoreCommands = false;
return null;
}
JSAPResult result = jsap.parse(nextCommandAsString);
if (result.success()) {
String databaseFolder = result.getString(DATABASE_FOLDER_OPTION);
String commandName = result.getString(COMMAND_NAME_OPTION);
Map<String, String> parameters = parseParameters(result.getString(PARAMETERS_OPTION, ""));
return CommandBuilder
.command(commandName)
.usingDatabaseManager(databaseManager)
.forDatabase(databaseFolder)
.withParameters(parameters)
.build();
} else {
throw new Exception("Wrong command syntax: " + nextCommandAsString);
}
}
示例15: parseArgs
import com.martiansoftware.jsap.JSAPResult; //导入依赖的package包/类
/**
* Actually parse the command line arguments
* @param args
* @param parser
* @return
*/
private JSAPResult parseArgs(String[] args, SimpleJSAP parser) {
// parse the arguments
JSAPResult parserConfig = parser.parse(args);
// exit if it failed to parse
if (parser.messagePrinted()) {
System.exit(-1);
}
return parserConfig;
}