/** * Returns the name of the property. */ public String getName() { return prop.getName(); }
public static String toString(Record r, List<Property> props) { StringBuffer buf = new StringBuffer(); for (Property p : props) { Collection<String> vs = r.getValues(p.getName()); if (vs == null || vs.isEmpty()) continue; buf.append(p.getName() + ": "); for (String v : vs) buf.append("'" + v + "', "); } //buf.append(";;; " + r); return buf.toString(); }
private boolean isSameAs(Record r1, Record r2) { for (Property idp : config.getIdentityProperties()) { Collection<String> vs2 = r2.getValues(idp.getName()); Collection<String> vs1 = r1.getValues(idp.getName()); if (vs1 == null) continue; for (String v1 : vs1) if (vs2.contains(v1)) return true; } return false; }
protected void indexById(Record record) { for (Property idprop : config.getIdentityProperties()) for (String id : record.getValues(idprop.getName())) idmap.put(id, record); }
public void setRandomly(GeneticConfiguration cfg) { Configuration config = cfg.getConfiguration(); Property p = config.getPropertyByName(prop.getName()); p.setComparator(comparators.get((int) (comparators.size() * Math.random()))); }
public static void prettyPrint(Record r, List<Property> props) { for (Property p : props) { String prop = p.getName(); if (r.getValues(prop) == null || r.getValues(prop).isEmpty()) continue; System.out.println(prop + ": " + value(r, prop)); } }
public GeoProperty(Property prop) { this.prop = prop; this.spatialctx = SpatialContext.GEO; int maxlevels = 11; // FIXME: how to compute? GeohashPrefixTree grid = new GeohashPrefixTree(spatialctx, maxlevels); this.strategy = new RecursivePrefixTreeStrategy(grid, prop.getName()); }
private String getId(Record r) { for (Property idprop : config.getIdentityProperties()) { String v = r.getValue(idprop.getName()); if (v != null) return v; } return null; }
private String getid(Record r) { for (Property p : idprops) { String v = r.getValue(p.getName()); if (v == null) continue; return v; } throw new DukeException("No identity for record " + r); } }
private String getid(Record r) { for (Property p : idprops) { String v = r.getValue(p.getName()); if (v == null) continue; return v; } throw new DukeException("No identity for record " + r); } }
private void delete(Record record) { // removes previous copy of this record from the index, if it's there Property idprop = config.getIdentityProperties().iterator().next(); Query q = parseTokens(idprop.getName(), record.getValue(idprop.getName())); try { iwriter.deleteDocuments(q); } catch (IOException e) { throw new DukeException(e); } }
/** * Look up record by identity. */ public Record findRecordById(String id) { if (directory == null) init(); Property idprop = config.getIdentityProperties().iterator().next(); for (Record r : lookup(idprop, id)) if (r.getValue(idprop.getName()).equals(id)) return r; return null; // not found }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) for (String v : r.getValues(p.getName())) return v; throw new RuntimeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }
public void setFromOther(GeneticConfiguration cfg1, GeneticConfiguration cfg2) { Configuration config = cfg1.getConfiguration(); Configuration other = cfg2.getConfiguration(); Property p1 = config.getPropertyByName(prop.getName()); Property p2 = other.getPropertyByName(prop.getName()); p1.setComparator(p2.getComparator()); } }
public void setFromOther(GeneticConfiguration cfg1, GeneticConfiguration cfg2) { Configuration config = cfg1.getConfiguration(); Configuration other = cfg2.getConfiguration(); Property p1 = config.getPropertyByName(prop.getName()); Property p2 = other.getPropertyByName(prop.getName()); p1.setLowProbability(p2.getLowProbability()); }
public void setFromOther(GeneticConfiguration cfg1, GeneticConfiguration cfg2) { Configuration config = cfg1.getConfiguration(); Configuration other = cfg2.getConfiguration(); Property p1 = config.getPropertyByName(prop.getName()); Property p2 = other.getPropertyByName(prop.getName()); p1.setHighProbability(p2.getHighProbability()); } }
private String getIdentity(Record r) { for (Property p : config.getIdentityProperties()) { Collection<String> vs = r.getValues(p.getName()); if (vs == null) continue; for (String v : vs) return v; } throw new DukeException("No identity found in record [" + PrintMatchListener.toString(r) + "]"); }
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); }