Package org.rabinfingerprint.handprint.Handprints

Examples of org.rabinfingerprint.handprint.Handprints.HandPrintFactory


  private static Collection<Handprint> getHandsFromPath(final Polynomial p, final String path)
      throws FileNotFoundException {
    File dir = new File(path);
    List<File> files = FileListing.getFileListing(dir);
    List<Handprint> hands = new ArrayList<Handprint>();
    HandPrintFactory factory = Handprints.newFactory(p);
    for (File file : files) {
      if (!file.isFile())
        continue;
      hands.add(factory.newHandprint(new FileInputStream(file)));
    }

    return hands;
  }
View Full Code Here


    rabin.pushBytes(ByteStreams.toByteArray(System.in));
    System.out.println(String.format("%X", rabin.getFingerprintLong()));
  }

  public void handprintStdin(Polynomial p) throws IOException {
    HandPrintFactory factory = Handprints.newFactory(p);
    Handprint hand = factory.newHandprint(System.in);
    for (Long finger : hand.getHandFingers().keySet()) {
      System.out.println(String.format("%X", finger));
    }
  }
View Full Code Here

      System.out.println(String.format("%X", finger));
    }
  }

  public void handprintFiles(List<String> paths, Polynomial p) throws IOException {
    HandPrintFactory factory = Handprints.newFactory(p);
    for (String path : paths) {
      File file = new File(path);
      if (file.exists()) {
        Handprint hand = factory.newHandprint(new FileInputStream(file));
        for (Long finger : hand.getHandFingers().keySet()) {
          System.out.println(String.format("%X", finger));
        }
        System.out.flush();
      } else {
View Full Code Here

public class HandprintTest extends TestCase {
  public void testChunkingFiles() throws IOException {
    Polynomial p = Polynomial.createIrreducible(53);
   
    List<InputStream> sims = TestDataGenerator.getSimilarRandomBytes(4);
    HandPrintFactory factory = Handprints.newFactory(p);
    Handprint hand1 = factory.newHandprint(sims.get(0));
    Handprint hand2 = factory.newHandprint(sims.get(1));
    Handprint hand3 = factory.newHandprint(sims.get(2));
    Handprint hand4 = factory.newHandprint(sims.get(3));

    assertTrue(Math.abs(0.70 - hand1.getSimilarity(hand2)) < 0.05);
    assertTrue(Math.abs(0.70 - hand1.getSimilarity(hand3)) < 0.05);
    assertTrue(Math.abs(0.70 - hand1.getSimilarity(hand4)) < 0.05);
   
    List<InputStream> diffs = TestDataGenerator.getDifferentRandomBytes(3);
    Handprint hand5 = factory.newHandprint(diffs.get(0));
    Handprint hand6 = factory.newHandprint(diffs.get(1));
    Handprint hand7 = factory.newHandprint(diffs.get(2));

    assertTrue(Math.abs(0.00 - hand1.getSimilarity(hand5)) < 0.05);
    assertTrue(Math.abs(0.00 - hand1.getSimilarity(hand6)) < 0.05);
    assertTrue(Math.abs(0.00 - hand1.getSimilarity(hand7)) < 0.05);
  }
View Full Code Here

TOP

Related Classes of org.rabinfingerprint.handprint.Handprints.HandPrintFactory

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.