public void setRandomly(GeneticConfiguration cfg) { Configuration config = cfg.getConfiguration(); double new_value = drift(config.getThreshold(), 1.0, 0.0); config.setThreshold(new_value); }
public void setFromOther(GeneticConfiguration cfg1, GeneticConfiguration cfg2) { Configuration config = cfg1.getConfiguration(); Configuration other = cfg2.getConfiguration(); config.setThreshold(other.getThreshold()); }
private boolean[] whoThinksThisIsTrue(String id1, String id2) { Record r1 = database.findRecordById(id1); if (r1 == null) r1 = secondary.get(id1); Record r2 = database.findRecordById(id2); if (r2 == null) r2 = secondary.get(id2); List<GeneticConfiguration> configs = population.getConfigs(); boolean[] believers = new boolean[configs.size()]; for (int ix = 0; ix < configs.size(); ix++) { Configuration config = configs.get(ix).getConfiguration(); Processor proc = new Processor(config, database); believers[ix] = proc.compare(r1, r2) > config.getThreshold(); } return believers; } }
/** * Returns the brief summary used in the command-line output. */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append("[GeneticConfiguration " + shortnum(config.getThreshold())); for (Property p : config.getProperties()) if (p.isIdProperty()) buf.append(" [" + p.getName() + "]"); else buf.append(" [" + p.getName() + " " + shortname(p.getComparator()) + " " + shortnum(p.getHighProbability()) + " " + shortnum(p.getLowProbability()) + "]"); buf.append(" mr=" + mutation_rate + " rr=" + shortnum(recombination_rate)); buf.append("]"); return buf.toString(); }
public void setRandomly(GeneticConfiguration cfg) { Configuration config = cfg.getConfiguration(); Property p = config.getPropertyByName(prop.getName()); double new_value = drift(config.getThreshold(), 1.0, 0.5); p.setHighProbability(new_value); }
public void setRandomly(GeneticConfiguration cfg) { Configuration config = cfg.getConfiguration(); Property p = config.getPropertyByName(prop.getName()); double new_value = drift(config.getThreshold(), 0.5, 0.0); p.setLowProbability(new_value); }
@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()); }
@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()); }
private int countDifferences(Configuration config, Configuration rand) { int differences = 0; if (rand.getThreshold() != config.getThreshold()) differences += 1; Property prop = rand.getPropertyByName("ID"); assertTrue("ID property lost", prop.isIdProperty()); differences += checkProperty("NAME", config, rand); differences += checkProperty("EMAIL", config, rand); return differences; }
@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()); }
/** * Passes on all matches found. */ protected void compareCandidatesSimple(Record record, Collection<Record> candidates) { boolean found = false; for (Record candidate : candidates) { if (isSameAs(record, candidate)) continue; double prob = compare(record, candidate); if (prob > config.getThreshold()) { found = true; registerMatch(record, candidate, prob); } else if (config.getMaybeThreshold() != 0.0 && prob > config.getMaybeThreshold()) { found = true; // I guess? registerMatchPerhaps(record, candidate, prob); } } if (!found) registerNoMatchFor(record); }
assertTrue(config.getDataSources(1).isEmpty()); assertTrue(config.getDataSources(2).isEmpty()); assertEquals(config.getThreshold(), 0.85); assertEquals(config.getMaybeThreshold(), 0.7); assertEquals(3, config.getProperties().size());
assertEquals(config.getThreshold(), 0.85); assertEquals(config.getMaybeThreshold(), 0.7); assertEquals(3, config.getProperties().size());
assertEquals(config.getThreshold(), 0.85); assertEquals(config.getMaybeThreshold(), 0.7); assertEquals(3, config.getProperties().size());
/** * Passes on only the best match for each record. */ protected void compareCandidatesBest(Record record, Collection<Record> candidates) { double max = 0.0; Record best = null; // go through all candidates, and find the best for (Record candidate : candidates) { if (isSameAs(record, candidate)) continue; double prob = compare(record, candidate); if (prob > max) { max = prob; best = candidate; } } // pass on the best match, if any if (logger.isDebugEnabled()) { logger.debug("Best candidate at " + max + " is " + best); } if (max > config.getThreshold()) registerMatch(record, best, max); else if (config.getMaybeThreshold() != 0.0 && max > config.getMaybeThreshold()) registerMatchPerhaps(record, best, max); else registerNoMatchFor(record); }
assertEquals(config.getThreshold(), 0.85); assertEquals(config.getMaybeThreshold(), 0.7); assertEquals(3, config.getProperties().size());
public void setFromOther(Configuration config, Configuration other) { config.setThreshold(other.getThreshold()); }
writeElement("threshold", "" + config.getThreshold()); if (config.getMaybeThreshold() != 0.0) writeElement("maybe-threshold", "" + config.getMaybeThreshold());
/** * Returns the brief summary used in the command-line output. */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append("[GeneticConfiguration " + shortnum(config.getThreshold())); for (Property p : config.getProperties()) if (p.isIdProperty()) buf.append(" [" + p.getName() + "]"); else buf.append(" [" + p.getName() + " " + shortname(p.getComparator()) + " " + shortnum(p.getHighProbability()) + " " + shortnum(p.getLowProbability()) + "]"); buf.append("]"); return buf.toString(); }
/** * Passes on all matches found. */ protected void compareCandidatesSimple(Record record, Collection<Record> candidates) { boolean found = false; for (Record candidate : candidates) { if (isSameAs(record, candidate)) continue; double prob = compare(record, candidate); if (prob > config.getThreshold()) { found = true; registerMatch(record, candidate, prob); } else if (config.getMaybeThreshold() != 0.0 && prob > config.getMaybeThreshold()) { found = true; // I guess? registerMatchPerhaps(record, candidate, prob); } } if (!found) registerNoMatchFor(record); }