public boolean equals(Object other) { if (!(other instanceof Link)) return false; Link olink = (Link) other; return (olink.getID1().equals(id1) && olink.getID2().equals(id2)); }
private void retract(Link link) { // it's indexed under both IDs, so we need to remove it from both // places links.get(link.getID1()).remove(link); links.get(link.getID2()).remove(link); }
public List<Link> getAllLinks() { // contains the links we've already covered, form: ID1,ID2 Set<String> seen = new HashSet(); List<Link> all = new ArrayList(); for (Collection<Link> linkcoll : links.values()) for (Link link : linkcoll) { String id = link.getID1() + ',' + link.getID2(); if (seen.contains(id)) continue; all.add(link); seen.add(id); } return all; }
private String makeKey(Link l) { return l.getID1() + "\t" + l.getID2(); }
public Link inferLink(String id1, String id2) { // FIXME: it's possible that we find inconsistencies here. for now we // ignore that. if we've seen a link between these two IDs then that // means we're not going to ask the user about it. Collection<Link> ourlinks = links.get(id1); if (ourlinks != null) { for (Link link : ourlinks) if (link.getID1().equals(id2) || link.getID2().equals(id2)) return link; // if we get here it means we couldn't find a direct link. move on // to see if we can find an indirect one. } // can we prove that these belong to the same equivalence class? // basically, need to traverse graph outwards from ID1 to see if // we ever get to ID2. // if (traverseFrom(id1, id2, new HashSet())) // return new Link(id1, id2, LinkStatus.ASSERTED, LinkKind.SAME, 0.0); // else return null; }
private boolean traverseFrom(String id, String goalid, Set<String> seen) { seen.add(id); if (links.get(id) == null) return false; for (Link link : links.get(id)) { // check that this is a SAME link if (link.getKind() != LinkKind.SAME) continue; // find the ID that is not 'id' (find the ID at the other end) String otherid = link.getID1(); if (otherid.equals(id)) otherid = link.getID2(); // if we haven't seen it, and it's not goalid, keep traversing if (otherid.equals(goalid)) return true; else if (!seen.contains(otherid)) { if (traverseFrom(otherid, goalid, seen)) return true; // found it! // else: keep trying } } return false; }
private void addLink(Link link) { indexLink(link.getID1(), link); indexLink(link.getID2(), link); }
private Link find(Collection<Link> links, String id1, String id2) { for (Link link : links) if (link.getID1().equals(id1) && link.getID2().equals(id2)) return link; fail("Couldn't find link " + id1 + " " + id2); return null; }
public synchronized void noMatchFor(Record r) { // we missed all of the correct links for this record (if any). // count, and tell the user. for (Link link : golddb.getAllLinksFor(getid(r))) { if (link.getKind() != LinkKind.SAME) continue; // it's a bad link, so never mind missed++; Record r1 = database.findRecordById(link.getID1()); Record r2 = database.findRecordById(link.getID2()); if (r1 != null && r2 != null) { if (debug && !showmatches) PrintMatchListener.show(r1, r2, processor.compare(r1, r2), "\nNOT FOUND", props, pretty); } else if (debug && !showmatches) { System.out.println("\nIDENTITIES IN TEST FILE NOT FOUND IN DATA"); System.out.println("ID1: " + link.getID1() + " -> " + r1); System.out.println("ID2: " + link.getID2() + " -> " + r2); } } }
"links where " + "id1 = '" + escape(link.getID1()) + "' and " + "id2 = '" + escape(link.getID2()) + "'"); if (rs.next()) { existing = makeLink(rs); if (existing != null) { logger.trace("Updating link for " + link.getID1() + " and " + link.getID2()); query = "update " + tblprefix + "links set status = " + link.getStatus().getId() + " , confidence = " + link.getConfidence() + " " + "where id1 = '" + escape(link.getID1()) + "' " + " and id2 = '" + escape(link.getID2()) + "' "; } else { logger.trace("Inserting link for " + link.getID1() + " and " + link.getID2()); query = "insert into " + tblprefix + "links values ('" + escape(link.getID1()) + "', " + " '" + escape(link.getID2()) + "', " + link.getKind().getId() + " , " + link.getStatus().getId() + ", " + dbtype.getNow() + ", " + link.getConfidence() + ") ";
public static void verifySame(Link l1, Link l2) { assertEquals("wrong ID1", l1.getID1(), l2.getID1()); assertEquals("wrong ID2", l1.getID2(), l2.getID2()); assertEquals("wrong status", l1.getStatus(), l2.getStatus()); assertEquals("wrong kind", l1.getKind(), l2.getKind()); assertEquals(l1.getConfidence(), l2.getConfidence(), 0.0001); }
public boolean equals(Object other) { if (!(other instanceof Link)) return false; Link olink = (Link) other; return (olink.getID1().equals(id1) && olink.getID2().equals(id2)); }
private void retract(Link link) { // it's indexed under both IDs, so we need to remove it from both // places links.get(link.getID1()).remove(link); links.get(link.getID2()).remove(link); }
public List<Link> getAllLinks() { // contains the links we've already covered, form: ID1,ID2 Set<String> seen = new HashSet(); List<Link> all = new ArrayList(); for (Collection<Link> linkcoll : links.values()) for (Link link : linkcoll) { String id = link.getID1() + ',' + link.getID2(); if (seen.contains(id)) continue; all.add(link); seen.add(id); } return all; }
private String makeKey(Link l) { return l.getID1() + "\t" + l.getID2(); }
private boolean traverseFrom(String id, String goalid, Set<String> seen) { seen.add(id); if (links.get(id) == null) return false; for (Link link : links.get(id)) { // check that this is a SAME link if (link.getKind() != LinkKind.SAME) continue; // find the ID that is not 'id' (find the ID at the other end) String otherid = link.getID1(); if (otherid.equals(id)) otherid = link.getID2(); // if we haven't seen it, and it's not goalid, keep traversing if (otherid.equals(goalid)) return true; else if (!seen.contains(otherid)) { if (traverseFrom(otherid, goalid, seen)) return true; // found it! // else: keep trying } } return false; }
public Link inferLink(String id1, String id2) { // FIXME: it's possible that we find inconsistencies here. for now we // ignore that. if we've seen a link between these two IDs then that // means we're not going to ask the user about it. Collection<Link> ourlinks = links.get(id1); if (ourlinks != null) { for (Link link : ourlinks) if (link.getID1().equals(id2) || link.getID2().equals(id2)) return link; // if we get here it means we couldn't find a direct link. move on // to see if we can find an indirect one. } // can we prove that these belong to the same equivalence class? // basically, need to traverse graph outwards from ID1 to see if // we ever get to ID2. if (traverseFrom(id1, id2, new HashSet())) return new Link(id1, id2, LinkStatus.ASSERTED, LinkKind.SAME, 0.0); else return null; }
private void addLink(Link link) { indexLink(link.getID1(), link); indexLink(link.getID2(), link); }
public synchronized void noMatchFor(Record r) { // we missed all of the correct links for this record (if any). // count, and tell the user. for (Link link : golddb.getAllLinksFor(getid(r))) { if (link.getKind() != LinkKind.SAME) continue; // it's a bad link, so never mind missed++; Record r1 = database.findRecordById(link.getID1()); Record r2 = database.findRecordById(link.getID2()); if (r1 != null && r2 != null) { if (debug && !showmatches) PrintMatchListener.show(r1, r2, processor.compare(r1, r2), "\nNOT FOUND", props, pretty); } else if (debug && !showmatches) { System.out.println("\nIDENTITIES IN TEST FILE NOT FOUND IN DATA"); System.out.println("ID1: " + link.getID1() + " -> " + r1); System.out.println("ID2: " + link.getID2() + " -> " + r2); } } }