Skip to content

Commit

Permalink
Added a threshold option, -t <minScore>.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbox63 committed Nov 21, 2017
1 parent 0e75393 commit 241ed45
Showing 1 changed file with 54 additions and 22 deletions.
76 changes: 54 additions & 22 deletions src/fpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <unistd.h>

#ifndef TRUE
# define TRUE (0 == 0)
#endif /* TRUE */

#ifndef FALSE
# define FALSE (! TRUE)
#endif /* FALSE */

#define ONE ((size_t) 1)

float minValue = -2.0;

typedef struct _FingerprintSet {
int fingerprints;
int length;
Expand Down Expand Up @@ -145,7 +156,9 @@ selfCompare(FingerprintSet *queryp)
}
r /= (qVar*tVar);
++ target;
printf("%d\t%d\t%7f\n", query, target, r);
if (minValue <= r) {
printf("%d\t%d\t%7f\n", query, target, r);
}
}
}
}
Expand Down Expand Up @@ -232,10 +245,12 @@ compare1(FingerprintSet *queryp,
r /= qVar*tVar;
++ target;

if (flipped) {
printf("%d\t%d\t%7f\n", target, query, r);
} else {
printf("%d\t%d\t%7f\n", query, target, r);
if (minValue <= r) {
if (flipped) {
printf("%d\t%d\t%7f\n", target, query, r);
} else {
printf("%d\t%d\t%7f\n", query, target, r);
}
}
}

Expand Down Expand Up @@ -307,32 +322,49 @@ compare(FingerprintSet *queryp,
/*--------------------------------------------------------------------------------
//
*/
static char *USAGE = "Usage: %s <queryFile> [ <dbFile1> ... ]\n";
static char *USAGE = "Usage: %s [ -t <threshold> ] <queryFile> [ <dbFile1> ... ]\n";

int
main(int argc,
char *argv[])
{
FingerprintSet query;

if (argc < 2) {
fprintf(stderr, USAGE, argv[0]);
fflush(stderr);
exit(0);
extern int optind;
extern char *optarg;
int opt;
int usage = FALSE;

while (-1 != (opt = getopt(argc,argv,"t:"))) {
switch (opt) {
case 't':
if (1 != sscanf(optarg,"%f",&minValue)) {
usage = TRUE;
}
break;
default:
usage = TRUE;
break;
}
}
readFingerprintSet(argv[1],&query);
if (2 == argc) {
selfCompare(&query);
} else {
FingerprintSet db;
int i;
for (i = 2; i < argc; ++ i) {
readFingerprintSet(argv[i],&db);
compare(&query, &db);
free((void *) db.valuep);
if (argc == optind) { usage = TRUE; }
if (! usage) {
readFingerprintSet(argv[optind++],&query);
if (optind == argc) {
selfCompare(&query);
} else {
FingerprintSet db;
while (optind < argc) {
readFingerprintSet(argv[optind++],&db);
compare(&query, &db);
free((void *) db.valuep);
}
}
free((void *) query.valuep);
}
if (usage) {
fprintf(stderr, USAGE, argv[0]);
fflush(stderr);
}
free((void *) query.valuep);
}

/* end of fpcompare.c */

0 comments on commit 241ed45

Please sign in to comment.