Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.Link


  public LinkDatabase getLinkDatabase() {
    return linkdb;
  }

  public LinkKind getLinkKind(String id1, String id2) {
    Link link = linkdb.inferLink(id1, id2);
    if (link == null)
      return LinkKind.DIFFERENT; // we assume missing links are incorrect
    return link.getKind();
  }
View Full Code Here


  public synchronized void matches(Record r1, Record r2, double confidence) {
    String id1 = getid(r1);
    String id2 = getid(r2);

    Link link = golddb.inferLink(id1, id2);
    if (link == null) {
      unknown++; // we don't know if this one is right or not
      if (debug && !showmatches)
        PrintMatchListener.show(r1, r2, confidence, "\nNOT IN TEST FILE",
                                props, pretty);
    } else if (link.getKind() == LinkKind.SAME)
      // no counting now; we do that when we're done
      dukedb.assertLink(new Link(id1, id2, LinkStatus.INFERRED, LinkKind.SAME,
                                 confidence));
    else if (link.getKind() == LinkKind.DIFFERENT) {
      wrongfound++; // we found it, but it's not right

      if (debug && !showmatches)
        PrintMatchListener.show(r1, r2, confidence, "\nINCORRECT",
                                props, pretty);
View Full Code Here

      startRecord_(r1);
    }

    String id1 = getIdentity(r1);
    String id2 = getIdentity(r2);
    curlinks.add(new Link(id1, id2, LinkStatus.INFERRED, LinkKind.SAME,
                          confidence));
  }
View Full Code Here

      startRecord_(r1);
    }

    String id1 = getIdentity(r1);
    String id2 = getIdentity(r2);
    curlinks.add(new Link(id1, id2, LinkStatus.INFERRED, LinkKind.MAYBESAME,
                          confidence));
  }
View Full Code Here

      // removing all the links we found this time around from the set of
      // old links. any links remaining after this will be stale, and need
      // to be retracted
      for (Link newl : new ArrayList<Link>(curlinks)) {
        String key = makeKey(newl);
        Link oldl = oldmap.get(key);
        if (oldl == null)
          continue;

        if (oldl.overrides(newl))
          // previous information overrides this link, so ignore
          curlinks.remove(newl);
        else if (sameAs(oldl, newl)) {
          // there's no new information here, so just ignore this
          curlinks.remove(newl);
          oldmap.remove(key); // we don't want to retract the old one
        } else
          // the link is out of date, but will be overwritten, so remove
          oldmap.remove(key);
      }

      // all the inferred links left in oldmap are now old links we
      // didn't find on this pass. there is no longer any evidence
      // supporting them, and so we can retract them.
      for (Link oldl : oldmap.values())
        if (oldl.getStatus() == LinkStatus.INFERRED) {
          oldl.retract(); // changes to retracted, updates timestamp
          curlinks.add(oldl);
        }
    }

    // okay, now we write it all to the database
View Full Code Here

      PrintMatchListener.prettyCompare(r1, r2, (double) pair.counter,
                                       "Possible match",
                                       config.getProperties());

      LinkKind kind = oracle.getLinkKind(pair.id1, pair.id2);
      Link link = new Link(pair.id1, pair.id2, LinkStatus.ASSERTED, kind, 1.0);
      testdb.assertLink(link);

      count++;
      if (count == questions)
        break;
View Full Code Here

    writer.close();

    load();

    assertEquals(1, db.getAllLinks().size());
    Link link = db.getAllLinks().iterator().next();
    verifySame(new Link("1", "2", LinkStatus.ASSERTED, LinkKind.SAME, 0.95),
               link);
  }
View Full Code Here

    load();

    assertEquals(3, db.getAllLinks().size());
    Collection<Link> links = db.getAllLinks();

    Link link = find(links, "1", "2");
    verifySame(new Link("1", "2", LinkStatus.ASSERTED, LinkKind.SAME, 0.95),
               link);
   
    link = find(links, "1", "3");
    verifySame(new Link("1", "3", LinkStatus.ASSERTED, LinkKind.DIFFERENT, 0.2),
               link);

    link = find(links, "3", "4");
    verifySame(new Link("3", "4", LinkStatus.ASSERTED, LinkKind.SAME, 0.8),
               link);
  }
View Full Code Here

    assertTrue(linkdb.getChangesSince(0).isEmpty());
  }
 
  @Test
  public void testGetSinceForever() {
    Link l1 = new Link("1", "2", LinkStatus.INFERRED, LinkKind.SAME, 1.0);
    linkdb.assertLink(l1);
   
    Link l2 = new Link("1", "3", LinkStatus.INFERRED, LinkKind.SAME, 1.0);
    linkdb.assertLink(l2);

    List<Link> links = linkdb.getChangesSince(0);
    assertEquals(2, links.size());

    // we don't know the order, so must check
    Link ll1;
    Link ll2;
    if (links.get(0).equals(l2)) {
      ll1 = links.get(1);
      ll2 = links.get(0);
    } else {
      ll1 = links.get(0);
View Full Code Here

    assertEquals(l2, ll2);
  }

  @Test
  public void testGetSinceOnlyHalf() {
    Link l1 = new Link("1", "2", LinkStatus.INFERRED, LinkKind.SAME, 1.0);
    linkdb.assertLink(l1);

    pause();
    long thetime = System.currentTimeMillis();
    pause();
   
    Link l2 = new Link("1", "3", LinkStatus.INFERRED, LinkKind.SAME, 1.0);
    linkdb.assertLink(l2);

    List<Link> links = linkdb.getChangesSince(thetime);
    assertEquals(1, links.size());
    assertEquals(l2, links.get(0));
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.Link

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.