private boolean filterbytype(Record record) { if (types.isEmpty()) // there is no filtering return true; boolean found = false; for (String value : record.getValues(RDF_TYPE)) if (types.contains(value)) return true; return false; }
for (String propname : record.getProperties()) { Property prop = config.getPropertyByName(propname); id = record.getValue(propname); } else { Collection<String> values = record.getValues(propname); if (values != null && !values.isEmpty()) { if (values.size() == 1) {
public static String toString(Record r) { StringBuffer buf = new StringBuffer(); for (String p : r.getProperties()) { Collection<String> vs = r.getValues(p); if (vs == null || vs.isEmpty()) continue; buf.append(p + ": "); for (String v : vs) buf.append("'" + v + "', "); } //buf.append(";;; " + r); return buf.toString(); }
private String getid(Record r) { for (String propname : r.getProperties()) if (config.getPropertyByName(propname).isIdProperty()) return r.getValue(propname); return null; } }
public String makeKey(Record record) { return record.getValue("NAME"); } }
@Test public void testNormal() { Record r = TestUtils.makeRecord("ID", "abc", "NAME", "b"); assertEquals("abc", r.getValue("ID")); Collection<String> values = r.getValues("ID"); assertEquals(1, values.size()); assertEquals("abc", values.iterator().next()); assertEquals("b", r.getValue("NAME")); values = r.getValues("NAME"); assertEquals(1, values.size()); assertEquals("b", values.iterator().next()); assertEquals(null, r.getValue("EMAIL")); assertTrue(r.getValues("EMAIL").isEmpty()); }
private void findNext() { while (it.hasNext()) { next = it.next(); if (!next.getProperties().isEmpty()) return; // we found it! } next = null; } }
@Test public void testTwoRecordsDoubleValue() { setupTripleConfig1("?uri"); source.setRows(new String[][] { {"http://a/1", "http://a/name", "1"}, {"http://a/1", "http://a/name", "one"}, {"http://a/1", "http://a/age", "32"}, {"http://a/2", "http://a/name", "2"}, {"http://a/2", "http://a/age", "23"}}); RecordIterator it = source.getRecords(); assertTrue("data source contains no records", it.hasNext()); Record r = it.next(); assertEquals("wrong ID", "http://a/1", r.getValue("ID")); assertEquals("wrong AGE", "32", r.getValue("AGE")); Collection<String> values = r.getValues("NAME"); assertEquals("wrong number of NAMEs", 2, values.size()); assertTrue("NAMEs doesn't contain '1'", values.contains("1")); assertTrue("NAMEs doesn't contain 'one'", values.contains("one")); assertTrue("data source contains only one record", it.hasNext()); r = it.next(); assertEquals("wrong ID", "http://a/2", r.getValue("ID")); assertEquals("wrong NAME", "2", r.getValue("NAME")); assertEquals("wrong AGE", "23", r.getValue("AGE")); assertFalse("data source contains more than two records", it.hasNext()); assertEquals("wrong number of pages", 2, source.getPages()); }
comparisons++; double prob = 0.5; for (String propname : r1.getProperties()) { Property prop = config.getPropertyByName(propname); if (prop == null) continue; Collection<String> vs1 = r1.getValues(propname); Collection<String> vs2 = r2.getValues(propname); if (vs1 == null || vs1.isEmpty() || vs2 == null || vs2.isEmpty()) continue; // no values to compare, so skip
private String getid(Record r) { for (String propname : r.getProperties()) { Property prop = config.getPropertyByName(propname); if (prop == null) throw new DukeConfigException("Record has property " + propname + " which is not in configuration"); if (prop.isIdProperty()) return r.getValue(propname); } return null; }
private void findNext() { while (it.hasNext()) { next = it.next(); if (!next.getProperties().isEmpty()) return; // we found it! } next = null; } }
private String getId(Record r) { for (Property idprop : config.getIdentityProperties()) { String v = r.getValue(idprop.getName()); if (v != null) return v; } return null; }
private static String value(Record r, String p) { Collection<String> vs = r.getValues(p); if (vs == null) return "<null>"; if (vs.isEmpty()) return "<null>"; StringBuffer buf = new StringBuffer(); for (String v : vs) { buf.append("'"); buf.append(v); buf.append("', "); } return buf.toString(); } }
@Test public void testSplitting() throws IOException { source.addColumn(new Column("F1", null, null, null)); Column c = new Column("F2", null, null, null); c.setSplitOn(";"); source.addColumn(c); source.addColumn(new Column("F3", null, null, null)); RecordIterator it = read("F1,F2,F3\na,b;d;e,c"); Record r = it.next(); assertEquals("a", r.getValue("F1")); assertEquals("c", r.getValue("F3")); Collection<String> values = r.getValues("F2"); assertEquals(3, values.size()); assertTrue(values.contains("b")); assertTrue(values.contains("d")); assertTrue(values.contains("e")); }
for (String propname : record.getProperties()) { Property prop = config.getPropertyByName(propname); if (prop == null) String v = record.getValue(propname); if (v == null || v.equals("")) continue; for (String v : record.getValues(propname)) { if (v.equals("")) continue; // FIXME: not sure if this is necessary
public static String toString(Record r) { StringBuffer buf = new StringBuffer(); for (String p : r.getProperties()) { Collection<String> vs = r.getValues(p); if (vs == null || vs.isEmpty()) continue; buf.append(p + ": "); for (String v : vs) buf.append("'" + v + "', "); } //buf.append(";;; " + r); return buf.toString(); }
@Test public void testRecordImplementation() throws IOException { Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB"); db.index(record); db.commit(); record = db.findRecordById("1"); assertEquals("wrong ID", "1", record.getValue("ID")); assertEquals("wrong NAME", "AND", record.getValue("NAME")); assertEquals("wrong EMAIL", "BBBBB", record.getValue("EMAIL")); Collection<String> props = record.getProperties(); assertEquals("wrong number of properties", 3, props.size()); assertTrue("no ID", props.contains("ID")); assertTrue("no NAME", props.contains("NAME")); assertTrue("no EMAIL", props.contains("EMAIL")); }
/** * . Computes probability that objects are the same * * @return float the computed score */ @Override public double runAsDouble() { HashMap<String, Collection<String>> props = new HashMap<>(); LeafDocLookup doc = doc(); Collection<String> docKeys = comparedRecord.getProperties(); for (String key : docKeys) { if (doc.containsKey(key)) { String value = (doc.get(key) == null ? "" : getFieldValue(doc.get(key))); props.put(key, value == null ? Collections.singleton("") : Collections.singleton(value)); } } Record r2 = new RecordImpl(props); return compare(comparedRecord, r2, entityParams); }
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); } }