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


Java JSAPResult.userSpecified方法代码示例

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


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

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

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

示例3: 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

示例4: 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

示例5: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException  {
	String sourceBasename, destBasename;
	Class<?> graphClass;
	
	SimpleJSAP jsap = new SimpleJSAP( ArcListASCIIGraph.class.getName(), "Reads a graph with a given basename and writes it out in ASCII format with another basename",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph" ),
					new FlaggedOption( "shift", JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'S', "shift", "A shift that will be added to each node index." ),
					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 UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph" ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the destination graph" ),
				}		
			);
			
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	graphClass = jsapResult.getClass( "graphClass" );
	sourceBasename = jsapResult.getString( "sourceBasename" );
	destBasename = jsapResult.getString( "destBasename" );

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	final ImmutableGraph graph = graphClass != null 
		? (ImmutableGraph)graphClass.getMethod( "loadOffline", CharSequence.class, ProgressLogger.class ).invoke( null, sourceBasename, pl )
		: ImmutableGraph.loadOffline( sourceBasename, pl );
	if ( jsapResult.userSpecified( "shift" ) ) ArcListASCIIGraph.store( graph, destBasename, jsapResult.getInt( "shift" ) );
	else ArcListASCIIGraph.store( graph, destBasename );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:30,代码来源:ArcListASCIIGraph.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 IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException, InstantiationException  {
	String sourceBasename, destBasename;
	Class<?> graphClass;

	SimpleJSAP jsap = new SimpleJSAP( ASCIIGraph.class.getName(), "Reads a graph with a given basename, or a given spec, and writes it out in ASCII format with another basename",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph" ),
					new FlaggedOption( "shift", JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'S', "shift", "A shift that will be added to each node index." ),
					new Switch( "spec", 's', "spec", "The source is not a basename but rather a spec of the form ImmutableGraphClass(arg,arg,...)." ),
					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 UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph, or a source spec if --spec was given; it is immaterial when --once is specified." ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the destination graph" ),
				}		
			);
			
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	graphClass = jsapResult.getClass( "graphClass" );
	sourceBasename = jsapResult.getString( "sourceBasename" );
	destBasename = jsapResult.getString( "destBasename" );
	final boolean spec = jsapResult.getBoolean( "spec" );

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	if ( graphClass != null && spec ) {
		System.err.println( "Options --graphClass and --spec are incompatible" );
		return;
	}

	ImmutableGraph graph;
	if ( !spec )
		graph = graphClass != null 
		? (ImmutableGraph)graphClass.getMethod( "loadSequential", CharSequence.class, ProgressLogger.class ).invoke( null, sourceBasename, pl )
		: ImmutableGraph.loadSequential( sourceBasename, pl );
	else
		graph = ObjectParser.fromSpec( sourceBasename, ImmutableGraph.class, GraphClassParser.PACKAGE );
	if ( jsapResult.userSpecified( "shift" ) ) ASCIIGraph.store( graph, jsapResult.getInt( "shift" ), destBasename );
	else ASCIIGraph.store( graph, destBasename );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:41,代码来源:ASCIIGraph.java

示例11: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
static public void main( String arg[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, JSAPException, IOException, ClassNotFoundException {
	SimpleJSAP jsap = new SimpleJSAP( Stats.class.getName(), "Computes statistical data of a given graph.",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph." ),
					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( "saveDegrees", 's', "save-degrees", "Save indegrees and outdegrees in text format." ),
					new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
					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 Class<?> graphClass = jsapResult.getClass( "graphClass" );
	final String basename = jsapResult.getString( "basename" );
	final String resultsBasename = jsapResult.userSpecified( "resultsBasename" ) ? jsapResult.getString( "resultsBasename" ) : basename;
	
	final ProgressLogger pl = new ProgressLogger();
	pl.logInterval = jsapResult.getLong( "logInterval" );
	
	final ImmutableGraph graph;

	if ( graphClass != null ) graph = (ImmutableGraph)graphClass.getMethod( "loadOffline", CharSequence.class ).invoke( null, basename );
	else graph = ImmutableGraph.loadOffline( basename, pl );

	final LongArrayBitVector buckets = (LongArrayBitVector)( new File( basename + ".buckets" ).exists() ? BinIO.loadObject( basename + ".buckets" ) : null );
	final int[] sccsize = new File( basename + ".sccsizes" ).exists() ? BinIO.loadInts( basename + ".sccsizes" ) : null;

	run( graph, buckets, sccsize, resultsBasename, jsapResult.getBoolean( "saveDegrees" ), pl );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:32,代码来源:Stats.java

示例12: 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

示例13: main

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

	SimpleJSAP jsap = new SimpleJSAP(WarcCompressor.class.getName(),
		"Given a store uncompressed, write a compressed store.",
		new Parameter[] { new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o', "output", "The output filename  (- for stdout)."),
		new UnflaggedOption("store", JSAP.STRING_PARSER, JSAP.NOT_REQUIRED, "The name of the store (if omitted, stdin)."),
	});

	JSAPResult jsapResult = jsap.parse(arg);
	if (jsap.messagePrinted()) return;

	final InputStream in = jsapResult.userSpecified("store") ? new FastBufferedInputStream(new FileInputStream(jsapResult.getString("store"))) : System.in;

	final WarcReader reader = new UncompressedWarcReader(in);
	final ProgressLogger pl = new ProgressLogger(LOGGER, 1, TimeUnit.MINUTES, "records");
	final String output = jsapResult.getString("output");

	PrintStream out = "-".equals(output) ? System.out : new PrintStream(new FastBufferedOutputStream(new FileOutputStream(output)), false, "UTF-8");
	final WarcWriter writer = new CompressedWarcWriter(out);

	pl.itemsName = "records";
	pl.displayFreeMemory = true;
	pl.displayLocalSpeed = true;
	pl.start("Scanning...");

	for (long storePosition = 0;; storePosition++) {
	    LOGGER.trace("STOREPOSITION " + storePosition);
	    WarcRecord record = null;
	    try {
		record = reader.read();
	    } catch (Exception e) {
		LOGGER.error("Exception while reading record " + storePosition + " ");
		LOGGER.error(e.getMessage());
		e.printStackTrace();
		continue;
	    }
	    if (record == null)
		break;
	    writer.write(record);
	    pl.lightUpdate();
	}
	pl.done();
	writer.close();
    }
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:45,代码来源:WarcCompressor.java

示例14: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws Exception {
	final SimpleJSAP jsap = new SimpleJSAP(ParallelFilteredProcessorRunner.class.getName(), "Processes a store.",
			new Parameter[] {
			new FlaggedOption("filter", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "filter", "A WarcRecord filter that recods must pass in order to be processed."),
	 		new FlaggedOption("processor", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'p', "processor", "A processor to be applied to data.").setAllowMultipleDeclarations(true),
		 	new FlaggedOption("writer", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'w', "writer", "A writer to be applied to the results.").setAllowMultipleDeclarations(true),
			new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "output", "The output filename  (- for stdout).").setAllowMultipleDeclarations(true),
			new FlaggedOption("threads", JSAP.INTSIZE_PARSER, Integer.toString(Runtime.getRuntime().availableProcessors()), JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used."),
			new Switch("sequential", 'S', "sequential"),
			new UnflaggedOption("store", JSAP.STRING_PARSER, JSAP.NOT_REQUIRED, "The name of the store (if omitted, stdin)."),
	});

	final JSAPResult jsapResult = jsap.parse(arg);
	if (jsap.messagePrinted()) return;

	final String filterSpec = jsapResult.getString("filter");
	final Filter<WarcRecord> filter;
	if (filterSpec != null) {
		final FilterParser<WarcRecord> parser = new FilterParser<>(WarcRecord.class);
		filter = parser.parse(filterSpec);
	} else
		filter = null;
	final InputStream in = jsapResult.userSpecified("store") ? new FastBufferedInputStream(new FileInputStream(jsapResult.getString("store"))) : System.in;
	final ParallelFilteredProcessorRunner parallelFilteredProcessorRunner = new ParallelFilteredProcessorRunner(in, filter);

	final String[] processor =  jsapResult.getStringArray("processor");
	final String[] writer =  jsapResult.getStringArray("writer");
	final String[] output =  jsapResult.getStringArray("output");
	if (processor.length != writer.length) throw new IllegalArgumentException("You must specify the same number or processors and writers");
	if (output.length != writer.length) throw new IllegalArgumentException("You must specify the same number or output specifications and writers");

	final String[] packages = new String[] { ParallelFilteredProcessorRunner.class.getPackage().getName() };
	final PrintStream[] ops = new PrintStream[processor.length];
	for (int i = 0; i < processor.length; i++) {
		ops[i] = "-".equals(output[i]) ? System.out : new PrintStream(new FastBufferedOutputStream(new FileOutputStream(output[i])), false, "UTF-8");
		// TODO: these casts to SOMETHING<Object> are necessary for compilation under Eclipse. Check in the future.
		parallelFilteredProcessorRunner.add((Processor<Object>)ObjectParser.fromSpec(processor[i], Processor.class, packages, new String[] { "getInstance" }),
				(Writer<Object>)ObjectParser.fromSpec(writer[i], Writer.class,  packages, new String[] { "getInstance" }),
				ops[i]);
	}

	if (jsapResult.userSpecified("sequential")) parallelFilteredProcessorRunner.runSequentially();
	else parallelFilteredProcessorRunner.run(jsapResult.getInt("threads"));

	for (int i = 0; i < processor.length; i++) ops[i].close();

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

示例15: 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 scattered list of arcs into a BVGraph. The list of" +
			"identifiers in order of appearance will be saved with extension \"" + IDS_EXTENSION + "\", unless a translation function has been specified.",
			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 FlaggedOption( "batchSize", JSAP.INTSIZE_PARSER, Integer.toString( DEFAULT_BATCH_SIZE ), JSAP.NOT_REQUIRED, 's', "batch-size", "The maximum size of a batch, in arcs." ),
					new FlaggedOption( "tempDir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'T', "temp-dir", "A directory for all temporary batch files." ),
					new Switch( "symmetrize", 'S', "symmetrize", "Force the output graph to be symmetric." ),
					new Switch( "noLoops", 'L', "no-loops", "Remove loops from the output graph." ),
					new FlaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "function", "A serialised function from strings to longs that will be used to translate identifiers to node numbers." ),
					new FlaggedOption( "charset", JSAP.STRING_PARSER, "ISO-8859-1", JSAP.NOT_REQUIRED, 'C', "charset", "The charset used to read the list of arcs." ),
					new FlaggedOption( "n", JSAP.INTSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'n', "n", "The number of nodes of the graph (only if you specified a function)." ),
					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" );

	Object2LongFunction<String> function = null;
	Charset charset = null;
	int n = -1;
	if ( jsapResult.userSpecified( "function" ) ) {
		function = (Object2LongFunction<String>)BinIO.loadObject( jsapResult.getString( "function" ) );
		charset = Charset.forName( jsapResult.getString( "charset" ) );
		if ( ! jsapResult.userSpecified( "n" ) ) throw new IllegalArgumentException( "You must specify a graph size if you specify a translation function." );
		n = jsapResult.getInt( "n" );
	}
	
	File tempDir = null;
	if ( jsapResult.userSpecified( "tempDir" ) ) tempDir = new File( jsapResult.getString( "tempDir" ) );

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
	ScatteredArcsASCIIGraph graph = new ScatteredArcsASCIIGraph( System.in, function, charset, n, jsapResult.userSpecified( "symmetrize" ), jsapResult.userSpecified( "noLoops" ), jsapResult.getInt( "batchSize" ), tempDir, pl );
	BVGraph.store( graph, basename, windowSize, maxRefCount, minIntervalLength, zetaK, flags, pl );
	if ( function == null ) BinIO.storeLongs( graph.ids, basename + IDS_EXTENSION );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:63,代码来源:ScatteredArcsASCIIGraph.java


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