当前位置: 首页>>代码示例>>Java>>正文


Java JSAPResult.getInt方法代码示例

本文整理汇总了Java中com.martiansoftware.jsap.JSAPResult.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java JSAPResult.getInt方法的具体用法?Java JSAPResult.getInt怎么用?Java JSAPResult.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.martiansoftware.jsap.JSAPResult的用法示例。


在下文中一共展示了JSAPResult.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:26,代码来源:SequentialHyperBall.java

示例2: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String arg[]) throws Exception {
	final SimpleJSAP jsap = new SimpleJSAP(Agent.class.getName(), "Starts a BUbiNG agent (note that you must enable JMX by means of the standard Java system properties).",
			new Parameter[] {
				new FlaggedOption("weight", JSAP.INTEGER_PARSER, "1", JSAP.NOT_REQUIRED, 'w', "weight", "The agent weight."),
				new FlaggedOption("group", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g', "group", "The JGroups group identifier (must be the same for all cooperating agents)."),
				new FlaggedOption("jmxHost", JSAP.STRING_PARSER, InetAddress.getLocalHost().getHostAddress(), JSAP.REQUIRED, 'h', "jmx-host", "The IP address (possibly specified by a host name) that will be used to expose the JMX RMI connector to other agents."),
				new FlaggedOption("rootDir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'r', "root-dir", "The root directory."),
				new Switch("new", 'n', "new", "Start a new crawl"),
				new FlaggedOption("properties", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'P', "properties", "The properties used to configure the agent."),
				new UnflaggedOption("name", JSAP.STRING_PARSER, JSAP.REQUIRED, "The agent name (an identifier that must be unique across the group).")
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) System.exit(1);

		// JMX *must* be set up.
		final String portProperty = System.getProperty(JMX_REMOTE_PORT_SYSTEM_PROPERTY);
		if (portProperty == null) throw new IllegalArgumentException("You must specify a JMX service port using the property " + JMX_REMOTE_PORT_SYSTEM_PROPERTY);

		final String name = jsapResult.getString("name");
		final int weight = jsapResult.getInt("weight");
		final String group = jsapResult.getString("group");
		final String host = jsapResult.getString("jmxHost");
		final int port = Integer.parseInt(portProperty);

		final BaseConfiguration additional = new BaseConfiguration();
		additional.addProperty("name", name);
		additional.addProperty("group", group);
		additional.addProperty("weight", Integer.toString(weight));
		additional.addProperty("crawlIsNew", Boolean.valueOf(jsapResult.getBoolean("new")));
		if (jsapResult.userSpecified("rootDir")) additional.addProperty("rootDir", jsapResult.getString("rootDir"));

		new Agent(host, port, new RuntimeConfiguration(new StartupConfiguration(jsapResult.getString("properties"), additional)));
		System.exit(0); // Kills remaining FetchingThread instances, if any.
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:36,代码来源:Agent.java

示例3: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws JSAPException, IOException, InterruptedException {
	final SimpleJSAP jsap = new SimpleJSAP(RandomReadWritesTest.class.getName(), "Writes some random records on disk.",
		new Parameter[] {
			new FlaggedOption("random", JSAP.INTEGER_PARSER, "100", JSAP.NOT_REQUIRED, 'r', "random", "The number of random record to sample from."),
			new FlaggedOption("body", JSAP.INTSIZE_PARSER, "4K", JSAP.NOT_REQUIRED, 'b', "body", "The maximum size of the random generated body (in bytes)."),
			new Switch("fully", 'f', "fully", "Whether to read fully the record (and do a minimal sequential cosnsistency check)."),
			new Switch("writeonly", 'w', "writeonly", "Whether to skip the read part (if present, 'fully' will be ignored."),
			new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The path to write to."),
			new UnflaggedOption("records", JSAP.INTSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The numer of records to write."),
	});

	final JSAPResult jsapResult = jsap.parse(args);
	if (jsap.messagePrinted()) System.exit(1);

	final String path = jsapResult.getString("path");
	final boolean compress = path.endsWith(".gz");
	final boolean fully = jsapResult.getBoolean("fully");
	final int parallel = compress ? 1 : 0;

	final int body = jsapResult.getInt("body");

	final WarcRecord[] rnd = prepareRndRecords(jsapResult.getInt("random"), RESPONSE_PROBABILITY, MAX_NUMBER_OF_HEADERS, MAX_LENGTH_OF_HEADER, body);
	final int[] sequence = writeRecords(path, jsapResult.getInt("records"), rnd, parallel);
	if (! jsapResult.getBoolean("writeonly"))
		readRecords(path, sequence, body, fully, compress);

}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:28,代码来源:RandomReadWritesTest.java

示例4: Parameters

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public Parameters(String[] args) throws JSAPException {
	JSAP jsap = createJSAP();
	JSAPResult config = jsap.parse(args);
	if(!config.success()){
		exit(jsap);
	}
	
	input = config.getString(INPUT_OPT);
	output = config.getString(OUTPUT_OPT);
	model = config.getString(MODEL_OPT);
	train = config.getString(TRAIN_OPT);
	external = config.getString(EXTERNAL_OPT);
	trainSize = config.getInt(TRAINSIZE_OPT);
	iters = config.getInt(ITER_OPT);
	modelSize = config.getInt(MODEL_SIZE_OPT);
	repeats = config.getInt(REPEAT_OPT);
	rightMerge = config.getBoolean(RIGHT_MERGE_STRATEGY);
	implicitComplete = config.getBoolean(IMPLICIT_COMPLETE_STRATEGY);
	constrainedMerge = config.getBoolean(CONSTRAINED_MERGE_STRATEGY);
	fixedMweOnly = config.getBoolean(FIXED_MWE_ONLY);
	noSyntax = config.getBoolean(NO_SYNTACTIC_ANALYSIS);
	baseline = config.getBoolean(BASELINE);
	projective = config.getBoolean(PROJECTIVE_OPT);
	xconll = config.getBoolean(XCONLL_INPUT);
	
	if(!rightMerge && constrainedMerge){
		throw new IllegalStateException("The constrained merge strategy can only be applied with a right merge strategy!!");
	}
	if(iters <= 0){
		throw new IllegalStateException("number of training iterations should be positive");
	}
	if(modelSize <= 0){
		throw new IllegalStateException("number of feature identifiers should be positive");
	}
	
	if(repeats <= 0){
		throw new IllegalStateException("number of repeats should be positive");
	}
	
}
 
开发者ID:MathieuConstant,项目名称:lgtools,代码行数:41,代码来源:Parameters.java

示例5: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {		
	SimpleJSAP jsap = new SimpleJSAP( ErdosRenyiGraph.class.getName(), "Generates an Erd\u0151s-R\u00E9nyi random graph and stores it as a BVGraph.",
			new Parameter[] {
		new Switch( "loops", 'l', "loops", "Whether the graph should include self-loops." ), 
		new FlaggedOption( "p", JSAP.DOUBLE_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'p', "The probability of generating an arc." ),
		new FlaggedOption( "m", JSAP.LONGSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'm', "The expected number of arcs." ),
		new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.REQUIRED, "The basename of the output graph file." ),
		new UnflaggedOption( "n", JSAP.INTEGER_PARSER, JSAP.REQUIRED, "The number of nodes." ),
	});
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );

	final String baseName = jsapResult.getString( "basename" );
	final int n = jsapResult.getInt( "n" );
	final boolean loops = jsapResult.getBoolean( "loops" );
	
	if ( jsapResult.userSpecified( "p" ) && jsapResult.userSpecified( "m" ) ) {
		System.err.println( "Options p and m cannot be specified together" );
		System.exit( 1 );
	}
	if ( ! jsapResult.userSpecified( "p" ) && ! jsapResult.userSpecified( "m" ) ) {
		System.err.println( "Exactly one of the options p and m must be specified" );
		System.exit( 1 );
	}
	
	BVGraph.store( ( jsapResult.userSpecified( "p" ) ? new ErdosRenyiGraph( n, jsapResult.getDouble( "p" ), loops ) : new ErdosRenyiGraph( n, jsapResult.getLong( "m" ), loops ) ), baseName, new ProgressLogger() );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:28,代码来源:ErdosRenyiGraph.java

示例6: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {
	SimpleJSAP jsap = new SimpleJSAP( NeighbourhoodFunction.class.getName(), 
			"Prints the neighbourhood function of a graph, computing it via breadth-first visits.",
			new Parameter[] {
		new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
		new Switch( "expand", 'e', "expand", "Expand the graph to increase speed (no compression)." ),
		new FlaggedOption( "threads", JSAP.INTSIZE_PARSER, "0", JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used. If 0, the number will be estimated automatically." ),
		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 String basename = jsapResult.getString( "basename" );
	final int threads = jsapResult.getInt( "threads" );
	ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
	ImmutableGraph g =ImmutableGraph.load( basename );
	if ( jsapResult.userSpecified( "expand" ) ) g = new ArrayListMutableGraph( g ).immutableView();
	TextIO.storeLongs( computeExact( g, threads, pl ), System.out );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:22,代码来源:NeighbourhoodFunction.java

示例7: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {
	SimpleJSAP jsap = new SimpleJSAP( ConnectedComponents.class.getName(),
			"Computes the connected components of a symmetric graph of given basename. The resulting data is saved " +
			"in files stemmed from the given basename with extension .wcc (a list of binary integers specifying the " +
			"component of each node) and .wccsizes (a list of binary integer specifying the size of each component). " +
			"The symmetric graph can also be specified using a generic (non-symmetric) graph and its transpose.",
			new Parameter[] {
				new Switch( "sizes", 's', "sizes", "Compute component sizes." ),
				new Switch( "renumber", 'r', "renumber", "Renumber components in decreasing-size order." ),
				new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ), 
				new Switch( "mapped", 'm', "mapped", "Do not load the graph in main memory, but rather memory-map it." ),
				new FlaggedOption( "threads", JSAP.INTSIZE_PARSER, "0", JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used. If 0, the number will be estimated automatically." ),
				new FlaggedOption( "basenamet", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 't', "transpose", "The basename of the transpose, in case the graph is not symmetric." ),
				new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of a symmetric graph (or of a generic graph, if the transpose is provided, too)." ),
				new UnflaggedOption( "resultsBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the resulting files." ),
			}
	);

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );

	final String basename = jsapResult.getString( "basename" );
	final String basenamet = jsapResult.getString( "basenamet" );
	final String resultsBasename = jsapResult.getString( "resultsBasename", basename );
	final int threads = jsapResult.getInt( "threads" );
	ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	ImmutableGraph graph = jsapResult.userSpecified( "mapped" ) ? ImmutableGraph.loadMapped( basename ) : ImmutableGraph.load( basename, pl );
	ImmutableGraph grapht = basenamet == null ? null : jsapResult.userSpecified( "mapped" ) ? ImmutableGraph.loadMapped( basenamet ) : ImmutableGraph.load( basenamet, pl );
	final ConnectedComponents components = ConnectedComponents.compute( basenamet != null ? new UnionImmutableGraph( graph, grapht ) : graph, threads, pl );

	if ( jsapResult.getBoolean( "sizes" ) || jsapResult.getBoolean( "renumber" ) ) {
		final int size[] = components.computeSizes();
		if ( jsapResult.getBoolean( "renumber" ) ) components.sortBySize( size );
		if ( jsapResult.getBoolean( "sizes" ) ) BinIO.storeInts( size, resultsBasename + ".wccsizes" );
	}
	BinIO.storeInts( components.component, resultsBasename + ".wcc" );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:39,代码来源:ConnectedComponents.java

示例8: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( final String[] arg ) throws IOException, InterruptedException, JSAPException {
	
	SimpleJSAP jsap = new SimpleJSAP( BetweennessCentrality.class.getName(), "Computes the betweenness centrality a graph using an implementation of Brandes's algorithm based on multiple parallel breadth-first visits.",
		new Parameter[] {
		new Switch( "expand", 'e', "expand", "Expand the graph to increase speed (no compression)." ),
		new Switch( "mapped", 'm', "mapped", "Use loadMapped() to load the graph." ),
		new FlaggedOption( "threads", JSAP.INTSIZE_PARSER, "0", JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used. If 0, the number will be estimated automatically." ),
		new UnflaggedOption( "graphBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
		new UnflaggedOption( "rankFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where the resulting rank (doubles in binary form) are stored." )
	}
	);
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	final boolean mapped = jsapResult.getBoolean( "mapped", false );
	final String graphBasename = jsapResult.getString( "graphBasename" );
	final String rankFilename = jsapResult.getString( "rankFilename" );
	final int threads = jsapResult.getInt( "threads" );
	final ProgressLogger progressLogger = new ProgressLogger( LOGGER, "nodes" );
	progressLogger.displayFreeMemory = true;
	progressLogger.displayLocalSpeed = true;

	ImmutableGraph graph = mapped? ImmutableGraph.loadMapped( graphBasename, progressLogger ) : ImmutableGraph.load( graphBasename, progressLogger );
	if ( jsapResult.userSpecified( "expand" ) ) graph = new ArrayListMutableGraph( graph ).immutableView();
	
	BetweennessCentrality betweennessCentralityMultipleVisits = new BetweennessCentrality( graph, threads, progressLogger );
	betweennessCentralityMultipleVisits.compute();
	
	BinIO.storeDoubles( betweennessCentralityMultipleVisits.betweenness, rankFilename );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:32,代码来源:BetweennessCentrality.java

示例9: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( final String[] arg ) throws IOException, JSAPException, InterruptedException {
	
	SimpleJSAP jsap = new SimpleJSAP( GeometricCentralities.class.getName(), "Computes centralities of a graph using multiple parallel breadth-first visits.",
		new Parameter[] {
		new Switch( "expand", 'e', "expand", "Expand the graph to increase speed (no compression)." ),
		new Switch( "mapped", 'm', "mapped", "Use loadMapped() to load the graph." ),
		new FlaggedOption( "threads", JSAP.INTSIZE_PARSER, "0", JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used. If 0, the number will be estimated automatically." ),
		new UnflaggedOption( "graphBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
		new UnflaggedOption( "closenessFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where closeness-centrality scores (doubles in binary form) will be stored." ),
		new UnflaggedOption( "linFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where Lin's-centrality scores (doubles in binary form) will be stored." ),
		new UnflaggedOption( "harmonicFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where harmonic-centrality scores (doubles in binary form) will be stored." ),
		new UnflaggedOption( "reachableFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where the number of reachable nodes (longs in binary form) will be stored." )
	}
	);
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	final boolean mapped = jsapResult.getBoolean( "mapped", false );
	final String graphBasename = jsapResult.getString( "graphBasename" );
	final int threads = jsapResult.getInt( "threads" );
	final ProgressLogger progressLogger = new ProgressLogger( LOGGER, "nodes" );
	progressLogger.displayFreeMemory = true;
	progressLogger.displayLocalSpeed = true;

	ImmutableGraph graph = mapped? ImmutableGraph.loadMapped( graphBasename, progressLogger ) : ImmutableGraph.load( graphBasename, progressLogger );
	if ( jsapResult.userSpecified( "expand" ) ) graph = new ArrayListMutableGraph( graph ).immutableView();
	
	GeometricCentralities centralities = new GeometricCentralities( graph, threads, progressLogger );
	centralities.compute();
	
	BinIO.storeDoubles( centralities.closeness, jsapResult.getString( "closenessFilename" ) );
	BinIO.storeDoubles( centralities.lin, jsapResult.getString( "linFilename" ) );
	BinIO.storeDoubles( centralities.harmonic, jsapResult.getString( "harmonicFilename" ) );
	BinIO.storeLongs( centralities.reachable, jsapResult.getString( "reachableFilename" ) );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:37,代码来源:GeometricCentralities.java

示例10: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    JSAP jsap = new JSAP();
    FlaggedOption targetIp = new FlaggedOption("targetIp")
            .setStringParser(JSAP.INETADDRESS_PARSER)
            .setRequired(true)
            .setShortFlag('d')
            .setLongFlag("destination");
    FlaggedOption relayIp = new FlaggedOption("relayIp")
            .setStringParser(JSAP.INETADDRESS_PARSER)
            .setRequired(true)
            .setShortFlag('r')
            .setLongFlag("relay");
    FlaggedOption relayPort = new FlaggedOption("relayPort")
            .setStringParser(JSAP.INTEGER_PARSER)
            .setRequired(false)
            .setDefault(String.valueOf(DEFAULT_PORT))
            .setShortFlag('p')
            .setLongFlag("port");
    FlaggedOption token = new FlaggedOption("token")
            .setRequired(true)
            .setShortFlag('t')
            .setLongFlag("token");
    FlaggedOption rules = new FlaggedOption("rules")
            .setRequired(false)
            .setLongFlag("rules");
    jsap.registerParameter(targetIp);
    jsap.registerParameter(relayIp);
    jsap.registerParameter(relayPort);
    jsap.registerParameter(token);
    jsap.registerParameter(rules);
    JSAPResult config = jsap.parse(args);
    if (!config.success()) {
        System.err.println();
        System.err.println("Usage: " + jsap.getUsage());
        System.err.println();
        System.exit(0);
    }
    InetSocketAddress natBypassServer = new InetSocketAddress(config.getInetAddress("relayIp"), config.getInt("relayPort"));
    NATHole hole = UDPHoleCreator.createHole(config.getString("token"), config.getInetAddress("targetIp"), natBypassServer);
    channelHandler = new ChannelHandler(hole.getSocket(), hole.getTarget());
    if (config.contains("rules")) {
        for (String rule : config.getString("rules").split(",")) {
            if (!rule.equals("")) {
                parseRule(rule);
            }
        }
    }
    channelHandler.start();
    BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
    while (true) {
        try {
            String line = userInput.readLine();
            if (line.equalsIgnoreCase("exit")) {
                System.exit(0);
            } else if (line.equalsIgnoreCase("show")) {
                channelHandler.showChannels();
            } else {
                parseRule(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:JoBa97,项目名称:UDPRelayClient,代码行数:65,代码来源:UDPClient.java

示例11: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String arg[]) throws IllegalArgumentException, IOException, URISyntaxException, JSAPException, NoSuchAlgorithmException {

		final SimpleJSAP jsap = new SimpleJSAP(HTMLParser.class.getName(), "Produce the digest of a page: the page is downloaded or passed as argument by specifying a file",
				new Parameter[] {
					new UnflaggedOption("url", JSAP.STRING_PARSER, JSAP.REQUIRED, "The url of the page."),
					new Switch("crossAuthorityDuplicates", 'c', "cross-authority-duplicates"),
					new FlaggedOption("charBufferSize", JSAP.INTSIZE_PARSER, Integer.toString(CHAR_BUFFER_SIZE), JSAP.NOT_REQUIRED, 'b', "buffer", "The size of the parser character buffer (0 for dynamic sizing)."),
					new FlaggedOption("file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "file", "The page to be processed."),
					new FlaggedOption("digester", JSAP.STRING_PARSER, "MD5", JSAP.NOT_REQUIRED, 'd', "digester", "The digester to be used.")
			});

			final JSAPResult jsapResult = jsap.parse(arg);
			if (jsap.messagePrinted()) System.exit(1);

		final String url = jsapResult.getString("url");
		final String digester = jsapResult.getString("digester");
		final boolean crossAuthorityDuplicates = jsapResult.userSpecified("crossAuthorityDuplicates");
		final int charBufferSize = jsapResult.getInt("charBufferSize");

		final HTMLParser<Void> htmlParser =  new HTMLParser<>(BinaryParser.forName(digester), (TextProcessor<Void>)null, crossAuthorityDuplicates, charBufferSize);
		final SetLinkReceiver linkReceiver = new SetLinkReceiver();
		final byte[] digest;

		if (!jsapResult.userSpecified("file")) {
			final URI uri = new URI(url);
			final HttpGet request = new HttpGet(uri);
			request.setConfig(RequestConfig.custom().setRedirectsEnabled(false).build());
			digest = htmlParser.parse(uri, HttpClients.createDefault().execute(request), linkReceiver);
		}
		else {
			final String file = jsapResult.getString("file");
			final String content = IOUtils.toString(new InputStreamReader(new FileInputStream(file)));
			digest = htmlParser.parse(BURL.parse(url) , new StringHttpMessages.HttpResponse(content), linkReceiver);
		}

		System.out.println("DigestHexString: " + Hex.encodeHexString(digest));
		System.out.println("Links: " + linkReceiver.urls);

		final Set<String> urlStrings = new ObjectOpenHashSet<>();
		for (final URI link: linkReceiver.urls) urlStrings.add(link.toString());
		if (urlStrings.size() != linkReceiver.urls.size()) System.out.println("There are " + linkReceiver.urls.size() + " URIs but " + urlStrings.size() + " strings");

	}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:44,代码来源:HTMLParser.java

示例12: standalonemain

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
/**
 * Use this method to compute entity embeddings on a single machine. See --help
 * @param args command line arguments
 * @throws JSAPException
 * @throws ClassNotFoundException
 * @throws IOException
 */
public static void standalonemain( String args[] ) throws JSAPException, ClassNotFoundException, IOException {
    SimpleJSAP jsap = new SimpleJSAP( EntityEmbeddings.class.getName(), "Learns entity embeddings", new Parameter[]{
            new FlaggedOption( "input", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'i', "input", "Entity description files" ),
            new FlaggedOption( "vectors", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'v', "vectors", "Word2Vec file" ),
            new FlaggedOption( "rho", JSAP.INTEGER_PARSER, "-1", JSAP.NOT_REQUIRED, 'r', "rho", "rho negative sampling parameters (if it's <0 we use even sampling)" ),
            new FlaggedOption( "max", JSAP.INTEGER_PARSER, "-1", JSAP.NOT_REQUIRED, 'm', "max", "Max words per entity (<0 we use all the words)" ),
            new FlaggedOption( "output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o', "output", "Compressed version" ), }
    );
    JSAPResult jsapResult = jsap.parse( args );
    if( jsap.messagePrinted() ) return;
    CompressedW2V vectors = new CompressedW2V( jsapResult.getString( "vectors" ) );
    ProgressLogger pl = new ProgressLogger();
    final int rho = jsapResult.getInt( "rho" );
    final int nwords = vectors.getSize();
    final int d = vectors.N;
    final int maxWords = jsapResult.getInt( "max" ) > 0? jsapResult.getInt( "max" ):Integer.MAX_VALUE;
    final BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream( new File( jsapResult.getString( "input" ) ) ) ) );
    int count = 0;
    pl.count = count;
    pl.itemsName = "entities";
    while( br.readLine() != null ) count++;
    br.close();
    final PrintWriter pw = new PrintWriter( new BufferedWriter( new FileWriter( jsapResult.getString( "output" ), false ) ) );
    pw.println( count + " " + d );

    float alpha = 10;
    EntityEmbeddings eb = new EntityEmbeddings();
    final BufferedReader br2 = new BufferedReader( new InputStreamReader( new FileInputStream( new File( jsapResult.getString( "input" ) ) ) , "UTF-8") );
    pl.start();
    String line;
    while( ( line = br2.readLine() ) != null ) {
        String[] parts = line.split( "\t" );
        if( parts.length > 1 ) {
            TrainingExamples ex = eb.getVectors( parts[ 1 ], vectors, rho, nwords, maxWords );
            float[] w = eb.trainLR2( ex.x, d, ex.y, alpha );
            pw.print( parts[ 0 ] + " " );
            for( int i = 0; i < d; i++ ) {
                pw.print( w[ i ] + " " );
            }
            pw.println();
            pl.lightUpdate();
            pw.flush();

            for( int i = 0; i < ex.y.length; i++ ) {
                if( ex.y[ i ] > 0 ) {
                    double v = eb.scoreLR( ex.x[ i ], w );
                }
            }
        }
    }
    br2.close();
    pw.close();
    pl.stop();
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:62,代码来源:EntityEmbeddings.java

示例13: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, IOException, JSAPException, ClassNotFoundException  {
	String basename;
	SimpleJSAP jsap = new SimpleJSAP( ScatteredArcsASCIIGraph.class.getName(), "Converts a int2intset fastutil map into a BVGraph.",
			new Parameter[] {
					new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The serialized Int2ObjectMap<IntSet>" ),	
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
					new FlaggedOption( "comp", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 'c', "comp", "A compression flag (may be specified several times)." ).setAllowMultipleDeclarations( true ),
					new FlaggedOption( "windowSize", JSAP.INTEGER_PARSER, String.valueOf( BVGraph.DEFAULT_WINDOW_SIZE ), JSAP.NOT_REQUIRED, 'w', "window-size", "Reference window size (0 to disable)." ),
					new FlaggedOption( "maxRefCount", JSAP.INTEGER_PARSER, String.valueOf( BVGraph.DEFAULT_MAX_REF_COUNT ), JSAP.NOT_REQUIRED, 'm', "max-ref-count", "Maximum number of backward references (-1 for ∞)." ),
					new FlaggedOption( "minIntervalLength", JSAP.INTEGER_PARSER, String.valueOf( BVGraph.DEFAULT_MIN_INTERVAL_LENGTH ), JSAP.NOT_REQUIRED, 'i', "min-interval-length", "Minimum length of an interval (0 to disable)." ),
					new FlaggedOption( "zetaK", JSAP.INTEGER_PARSER, String.valueOf( BVGraph.DEFAULT_ZETA_K ), JSAP.NOT_REQUIRED, 'k', "zeta-k", "The k parameter for zeta-k codes." ),
					new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the output graph" ),
				}
			);
			
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	basename = jsapResult.getString( "basename" );

	int flags = 0;
	for( String compressionFlag: jsapResult.getStringArray( "comp" ) ) {
		try {
			flags |= BVGraph.class.getField( compressionFlag ).getInt( BVGraph.class );
		}
		catch ( Exception notFound ) {
			throw new JSAPException( "Compression method " + compressionFlag + " unknown." );
		}
	}
	
	final int windowSize = jsapResult.getInt( "windowSize" );
	final int zetaK = jsapResult.getInt( "zetaK" );
	int maxRefCount = jsapResult.getInt( "maxRefCount" );
	if ( maxRefCount == -1 ) maxRefCount = Integer.MAX_VALUE;
	final int minIntervalLength = jsapResult.getInt( "minIntervalLength" );
	
	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
	ImmutableGraph graph = new IntMapGraph((Int2ObjectMap<IntSet>) SerializationUtils.read(jsapResult.getString("map")));
	BVGraph.store( graph, basename, windowSize, maxRefCount, minIntervalLength, zetaK, flags, pl );
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:42,代码来源:IntMapGraph.java

示例14: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] rawArguments) throws JSAPException, IOException, ReflectiveOperationException {
	SimpleJSAP jsap = new SimpleJSAP(
			LatentMatrixEstimator.class.getName(),
			"Estimate the latent category matrix. ",
			new Parameter[] {
		new UnflaggedOption( "node2cat", JSAP.STRING_PARSER, JSAP.REQUIRED,
					"The serialized java file with node id -> category ids." ),
		new UnflaggedOption( "graph", JSAP.STRING_PARSER, JSAP.REQUIRED,
					"The input .graph file." ),
		new UnflaggedOption( "output", JSAP.STRING_PARSER, JSAP.REQUIRED,
			"The output serialied matrix basename, a different file will be saved"
			+ " with the estimated w at the end of each pass." ),
		new FlaggedOption( "seed", JSAP.LONG_PARSER, "1234567890", JSAP.NOT_REQUIRED, 's', "seed",
				"Seed for random generation."),
		new FlaggedOption( "passes", JSAP.INTEGER_PARSER, "1", JSAP.NOT_REQUIRED,
				'k', "passes",
				"Learning will happen k times and each time nodes will be shuffled."),
		
		new FlaggedOption( "matrixsize", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED,
				'm', "matrixsize",
				"If you provide an int k, a **dense matrix** of size k x k will be used to represent W."
				+ " If you don't, it will be used a sparse matrix of unknown size."),

		new FlaggedOption( "savestats", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED,
				JSAP.NO_SHORTFLAG, "savestats",
				"If a filepath is provided here, it will save a tsv file with"
				+ " accuracy and recall recorded every " + SAVE_STATS_EVERY + 
				" arcs learned.")

		
	});
	
	// parse arguments
	JSAPResult args = jsap.parse( rawArguments );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	if (args.contains("seed"))
		RandomSingleton.seedWith(args.getLong("seed"));
	
	Matrix matrix = args.contains("matrixsize") ?
						new ArrayMatrix(args.getInt("matrixsize"))
					:	new LongBasedMatrix();
	
	// reading input data
	LOGGER.info("Reading input files...");
	Int2ObjectMap<IntSet> node2cat = (Int2ObjectMap<IntSet>) SerializationUtils.read(args.getString("node2cat"));
	ImmutableGraph graph = ImmutableGraph.load(SerializationUtils.noExtension(args.getString("graph")));
	
	// actually doing stuff
	LatentMatrixEstimator estimator = new LatentMatrixEstimator(graph, node2cat, args.getString("output"), matrix);
	if (args.contains("savestats")) estimator.saveStatsTo(new File(args.getString("savestats")));
	estimator.learnNPassShuffled(args.getInt("passes"));
	estimator.close();
	LOGGER.info("Done.");
	
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:57,代码来源:LatentMatrixEstimator.java

示例15: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws IllegalArgumentException, JSAPException, IOException, ReflectiveOperationException {
	JsapResultsWithObject<TestMatrix> jsapResultsWithObject = 
			JsapUtils.constructObject(TestMatrix.class, args, 
			"Test a matrix, measuring its confusion matrix.",
			new Parameter[] {
				new UnflaggedOption( "n", 
						JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
						"Number of experiments." ),
				new UnflaggedOption( "numsample", 
						JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
						"Number of nodes in a sample." ),	
				new FlaggedOption("trunc", JSAP.INTEGER_PARSER,
						JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 't', "trunc",
						"If an int k is provided, it tests the matrix truncated to its "
						+ " k highest-absolute-valued elements. "),
				new FlaggedOption("lessrecallthan", JSAP.DOUBLE_PARSER,
						JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NO_SHORTFLAG, "lessrecallthan",
						"Show how many experiments showed a recall lower "
						+ "then then the provided value.")
			});
	
	TestMatrix t = jsapResultsWithObject.getObject();
	JSAPResult jsap = jsapResultsWithObject.getJsapResult();
	if (jsap.contains("trunc")) {
		int trunc = jsap.getInt("trunc");
		t.matrix.truncateTo(trunc);
	}
	ClassifierResults[] testResults = t.computeNExperiments(jsap.getInt("n"), jsap.getInt("numsample"));
	System.out.println("========= MEAN OF TEST RESULTS ========");
	System.out.println(ClassifierResults.avg(Arrays.asList(testResults)));
	
	if (jsap.contains("lessrecallthan")) {
		double threshold = jsap.getDouble("lessrecallthan");
		int nLower = 0;
		for (ClassifierResults test : testResults)
			if (test.getDouble(Stats.RECALL) < threshold)
				nLower++;
		System.out.println("Number of experiments with lower recall "
				+ "than " + threshold + ": "
				+ nLower + "/" + testResults.length 
				+ " (" + ((double) nLower / testResults.length * 100.0) + "%)"  );
	}
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:44,代码来源:TestMatrix.java


注:本文中的com.martiansoftware.jsap.JSAPResult.getInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。