本文整理汇总了Java中no.priv.garshol.duke.ConfigLoader类的典型用法代码示例。如果您正苦于以下问题:Java ConfigLoader类的具体用法?Java ConfigLoader怎么用?Java ConfigLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigLoader类属于no.priv.garshol.duke包,在下文中一共展示了ConfigLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testString
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testString() throws IOException, SAXException {
String cfg = "<duke>" +
"<schema>" +
"<threshold>0.4</threshold>" +
"</schema>" +
"</duke>";
Configuration config = ConfigLoader.loadFromString(cfg);
assertTrue(config.getDataSources().isEmpty());
assertTrue(config.getDataSources(1).isEmpty());
assertTrue(config.getDataSources(2).isEmpty());
assertEquals(config.getThreshold(), 0.4);
assertEquals(config.getMaybeThreshold(), 0.0);
assertTrue(config.getProperties().isEmpty());
}
示例2: testEmpty
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testEmpty() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-empty.xml");
assertTrue(config.getDataSources().isEmpty());
assertTrue(config.getDataSources(1).isEmpty());
assertTrue(config.getDataSources(2).isEmpty());
assertEquals(config.getThreshold(), 0.4);
assertEquals(config.getMaybeThreshold(), 0.0);
assertTrue(config.getProperties().isEmpty());
File outfile = tmpdir.newFile("config.xml");
ConfigWriter writer = new ConfigWriter(new FileOutputStream(outfile.getAbsolutePath()));
writer.write(config);
config = ConfigLoader.load(outfile.getAbsolutePath());
assertTrue(config.getDataSources().isEmpty());
assertTrue(config.getDataSources(1).isEmpty());
assertTrue(config.getDataSources(2).isEmpty());
assertEquals(config.getThreshold(), 0.4);
assertEquals(config.getMaybeThreshold(), 0.0);
assertTrue(config.getProperties().isEmpty());
}
示例3: testDatabase
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testDatabase() throws IOException, SAXException {
Configuration config = ConfigLoader
.load("classpath:config-database.xml");
Database db = config.getDatabase(false);
ElasticSearchDatabase es = (ElasticSearchDatabase) db;
assertEquals("duke-es", es.getCluster());
}
示例4: testDatabase
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testDatabase() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-database.xml");
Database db = config.getDatabase(false);
LuceneDatabase lucene = (LuceneDatabase) db;
assertEquals("/tmp/ct-visma-1", lucene.getPath());
}
示例5: testEmpty
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testEmpty() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-empty.xml");
assertTrue(config.getDataSources().isEmpty());
assertTrue(config.getDataSources(1).isEmpty());
assertTrue(config.getDataSources(2).isEmpty());
assertEquals(config.getThreshold(), 0.4);
assertEquals(config.getMaybeThreshold(), 0.0);
assertTrue(config.getProperties().isEmpty());
}
示例6: testSingleGroup
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testSingleGroup() throws IOException, SAXException {
try {
ConfigLoader.load("classpath:config-single-group.xml");
fail("Config file with a single group was accepted");
} catch (DukeConfigException e) {
// this configuration is bad, so this is what we wanted to test
}
}
示例7: testDefaultProbs
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testDefaultProbs() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-default-probs.xml");
Property prop = config.getPropertyByName("FIRSTNAME");
assertEquals(0.5, prop.getHighProbability());
assertEquals(0.5, prop.getLowProbability());
assertEquals(Property.Lookup.DEFAULT, prop.getLookupBehaviour());
}
示例8: testDefaultComparator
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testDefaultComparator() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-no-comparator.xml");
Property prop = config.getPropertyByName("LASTNAME");
assertEquals(null, prop.getComparator());
assertEquals(Property.Lookup.DEFAULT, prop.getLookupBehaviour());
}
示例9: testLookup
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testLookup() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-lookup.xml");
Property prop = config.getPropertyByName("FIRSTNAME");
assertEquals(Property.Lookup.REQUIRED, prop.getLookupBehaviour());
prop = config.getPropertyByName("LASTNAME");
assertEquals(Property.Lookup.DEFAULT, prop.getLookupBehaviour());
}
示例10: testParameterOfNothing
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testParameterOfNothing() throws IOException, SAXException {
try {
ConfigLoader.load("classpath:config-no-object.xml");
fail("Config file setting parameters of nothing was accepted");
} catch (DukeConfigException e) {
// this configuration is bad, so this is what we wanted to test
}
}
示例11: testCustomComparator
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testCustomComparator() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-custom-comparator.xml");
List<Comparator> comparators = config.getCustomComparators();
assertEquals(1, comparators.size());
}
示例12: testCustomEstimator
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testCustomEstimator() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-custom-estimator.xml");
List<Comparator> comparators = config.getCustomComparators();
assertEquals(1, comparators.size());
WeightedLevenshtein wl = (WeightedLevenshtein) comparators.get(0);
DefaultWeightEstimator est = (DefaultWeightEstimator) wl.getEstimator();
assertEquals(3.8, est.getDigitWeight());
}
示例13: DukeController
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
public DukeController(Properties props) {
this.status = "Initialized, inactive";
String configfile = get(props, "duke.configfile");
try {
// setting up logger
String loggerclass = get(props, "duke.logger-class", null);
if (loggerclass != null) {
logger = (Logger) ObjectUtils.instantiate(loggerclass);
logger.debug("DukeController starting up");
}
// loading configuration
Configuration config = ConfigLoader.load(configfile);
this.processor = new Processor(config, false);
this.linkdb = makeLinkDatabase(props);
processor.addMatchListener(new LinkDatabaseMatchListener(config, linkdb));
processor.addMatchListener(this);
batch_size = get(props, "duke.batch-size", 40000);
error_factor = get(props, "duke.error-wait-skips", 6);
// add loggers
if (logger != null) {
processor.setLogger(logger);
if (linkdb instanceof RDBMSLinkDatabase)
((RDBMSLinkDatabase) linkdb).setLogger(logger);
}
} catch (Throwable e) {
// this means init failed, and we need to clean up so that we can try
// again later. unfortunately, we don't know what failed, so we need
// to be careful
if (processor != null)
try {
processor.close();
} catch (Exception e2) {
if (logger != null)
logger.error("Couldn't close processor", e2);
}
if (linkdb != null)
linkdb.close();
throw new DukeException(e); // we failed, so signal that
}
}
示例14: main
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
public static void main(String[] argv) throws IOException, SAXException {
// parse command-line
CommandLineParser parser = new CommandLineParser();
parser.setMinimumArguments(1);
parser.setMaximumArguments(1);
parser.addStringOption("testfile", 'T');
parser.addBooleanOption("scientific", 's');
parser.addStringOption("generations", 'G');
parser.addStringOption("population", 'P');
parser.addStringOption("questions", 'Q');
parser.addStringOption("output", 'O');
parser.addStringOption("threads", 't');
parser.addBooleanOption("active", 'A');
parser.addStringOption("linkfile", 'l');
parser.addBooleanOption("sparse", 'S');
parser.addStringOption("mutation-rate", 'm');
parser.addStringOption("recombination-rate", 'r');
parser.addBooleanOption("no-comparators", 'C');
parser.addStringOption("original", 'o');
parser.addBooleanOption("incomplete-data", 'I');
try {
argv = parser.parse(argv);
} catch (CommandLineParser.CommandLineParserException e) {
System.err.println("ERROR: " + e.getMessage());
usage();
System.exit(1);
}
String testfile = parser.getOptionValue("testfile");
if (parser.getOptionState("scientific") && testfile == null) {
System.err.println("ERROR: scientific mode requires a test file");
System.exit(1);
}
// get started
Configuration config = ConfigLoader.load(argv[0]);
GeneticAlgorithm genetic =
new GeneticAlgorithm(config, testfile,
parser.getOptionState("scientific"));
genetic.setPopulation(parser.getOptionInteger("population", 100));
genetic.setGenerations(parser.getOptionInteger("generations", 100));
genetic.setQuestions(parser.getOptionInteger("questions", 10));
genetic.setConfigOutput(parser.getOptionValue("output"));
genetic.setThreads(parser.getOptionInteger("threads", 1));
genetic.setSparse(parser.getOptionState("sparse"));
genetic.setMutationRate(parser.getOptionInteger("mutation-rate", -1));
genetic.setRecombinationRate(parser.getOptionDouble("recombination-rate", -1.0));
genetic.setEvolveComparators(!parser.getOptionState("no-comparators"));
genetic.setCopiesOfOriginal(parser.getOptionInteger("original", 0));
genetic.setIncompleteTest(parser.getOptionState("incomplete-data"));
if (parser.getOptionState("active"))
genetic.setActive(true);
if (parser.getOptionValue("linkfile") != null)
genetic.setLinkFile(parser.getOptionValue("linkfile"));
genetic.run();
}
示例15: testDatabaseDefault
import no.priv.garshol.duke.ConfigLoader; //导入依赖的package包/类
@Test
public void testDatabaseDefault() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-database.xml");
Database db = config.getDatabase(false);
assertTrue(db instanceof InMemoryDatabase);
}