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


Java XMLConfiguration.addProperty方法代码示例

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


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

示例1: saveIntermediateGMLFile

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public void saveIntermediateGMLFile() throws IOException{ 
	XMLConfiguration configuration = getConfiguration();
	configuration.setRootElementName("gml");
	List<Path> instancePathCollection;
	for(int partitionId : _partitionedTemplates.keySet()){
		configuration.addProperty("partition(-1)[@id]", partitionId);
		configuration.addProperty("partition.template", _partitionedTemplates.get(partitionId).toFile().getAbsolutePath());

		instancePathCollection = _partitionedInstances.get(partitionId);
		for(Path instancePath : instancePathCollection){
			configuration.addProperty("partition.instances.instance(-1)", instancePath.toFile().getAbsolutePath());
		}
	}

	try {
		File partitionedGMLFileDir = _workingDirPath.resolve(_intermediateGMLInputFile).toFile();
		configuration.save(partitionedGMLFileDir);
		System.out.println("saving the partitioned gml information to " + partitionedGMLFileDir.getAbsolutePath());
	} catch (ConfigurationException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:dream-lab,项目名称:goffish_v2,代码行数:23,代码来源:GMLPartitionBuilder.java

示例2: configureJob

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
 * <p>
 * Configure the execution of the algorithm.
 * 
 * @param jobFilename Name of the KEEL file with properties of the execution
 *  </p>                  
 */

private static void configureJob(String jobFilename) {

	Properties props = new Properties();

	try {
		InputStream paramsFile = new FileInputStream(jobFilename);
		props.load(paramsFile);
		paramsFile.close();			
	}
	catch (IOException ioe) {
		ioe.printStackTrace();
		System.exit(0);
	}
	
	// Files training and test
	String trainFile;
	String testFile;
	StringTokenizer tokenizer = new StringTokenizer(props.getProperty("inputData"));
	tokenizer.nextToken();
	trainFile = tokenizer.nextToken();
	trainFile = trainFile.substring(1, trainFile.length()-1);
	testFile = tokenizer.nextToken();
	testFile = testFile.substring(1, testFile.length()-1);
	
	tokenizer = new StringTokenizer(props.getProperty("outputData"));
	String reportTrainFile = tokenizer.nextToken();
	reportTrainFile = reportTrainFile.substring(1, reportTrainFile.length()-1);
	String reportTestFile = tokenizer.nextToken();
	reportTestFile = reportTestFile.substring(1, reportTestFile.length()-1);	
	String reportRulesFile = tokenizer.nextToken();
	reportRulesFile = reportRulesFile.substring(1, reportRulesFile.length()-1);				
	
	// Algorithm auxiliar configuration
	XMLConfiguration algConf = new XMLConfiguration();
	algConf.setRootElementName("experiment");
	algConf.addProperty("process[@algorithm-type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasAlgorithm");
	algConf.addProperty("process.rand-gen-factory[@type]", "net.sourceforge.jclec.util.random.RanecuFactory");
	algConf.addProperty("process.rand-gen-factory[@seed]", Integer.parseInt(props.getProperty("seed")));
	algConf.addProperty("process.population-size", Integer.parseInt(props.getProperty("population-size")));
	algConf.addProperty("process.max-of-generations", Integer.parseInt(props.getProperty("max-generations")));
	algConf.addProperty("process.max-deriv-size", Integer.parseInt(props.getProperty("max-deriv-size")));
	algConf.addProperty("process.dataset[@type]", "net.sourceforge.jclec.util.dataset.KeelDataSet");
	algConf.addProperty("process.dataset.train-data.file-name", trainFile);
	algConf.addProperty("process.dataset.test-data.file-name", testFile);
	algConf.addProperty("process.species[@type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasSyntaxTreeSpecies");
	algConf.addProperty("process.evaluator[@type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasEvaluator");
	algConf.addProperty("process.provider[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeCreator");
	algConf.addProperty("process.parents-selector[@type]", "net.sourceforge.jclec.selector.RouletteSelector");
	algConf.addProperty("process.recombinator[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeRecombinator");
	algConf.addProperty("process.recombinator[@rec-prob]", Double.parseDouble(props.getProperty("rec-prob")));
	algConf.addProperty("process.recombinator.base-op[@type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasCrossover");
	algConf.addProperty("process.copy-prob", Double.parseDouble(props.getProperty("copy-prob")));
	algConf.addProperty("process.listener[@type]", "net.sourceforge.jclec.problem.classification.freitas.KeelFreitasPopulationReport");
	algConf.addProperty("process.listener.report-dir-name", "./");
	algConf.addProperty("process.listener.train-report-file", reportTrainFile);
	algConf.addProperty("process.listener.test-report-file", reportTestFile);
	algConf.addProperty("process.listener.rules-report-file", reportRulesFile);
	algConf.addProperty("process.listener.global-report-name", "resumen");
	algConf.addProperty("process.listener.report-frequency", 50);

	try {
		algConf.save(new File("configure.txt"));
	} catch (ConfigurationException e) {
		e.printStackTrace();
	}

	net.sourceforge.jclec.RunExperiment.main(new String [] {"configure.txt"});
}
 
开发者ID:triguero,项目名称:Keel3.0,代码行数:77,代码来源:Main.java


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