| 498 | } |
| 499 | |
| 500 | int main(int argc, char *argv[]) |
| 501 | { |
| 502 | extern int optind; |
| 503 | int option; |
| 504 | char const *opt_str = "cdhi:j:m:M:o:stvw"; |
| 505 | char usage_str[80]; |
| 506 | |
| 507 | char *outfile = 0; |
| 508 | unsigned num_files = 0; // number of files read |
| 509 | |
| 510 | sprintf(usage_str, "usage: %%s [ -%s ] [ FILE ]\n", opt_str); |
| 511 | |
| 512 | /* Process arguments: */ |
| 513 | while ((option = getopt(argc, argv, opt_str)) != EOF) { |
| 514 | switch (option) { |
| 515 | |
| 516 | case 'c': |
| 517 | csv_summary = 1; |
| 518 | break; |
| 519 | |
| 520 | case 'd': |
| 521 | debug = verbose = 1; |
| 522 | break; |
| 523 | |
| 524 | case 'h': |
| 525 | fputs( |
| 526 | "This program finds clusters of near-duplicate files of source code.\n" |
| 527 | "The input is a file (or files) with one sample per line. A sample consists\n" |
| 528 | "of a unique (within the input) identifier for the source code, e.g.\n" |
| 529 | "its file name or its file name path, and a list of space-separated tokens.\n\n" |
| 530 | "Two samples are reported as near-duplicates depending on the thresholds set\n" |
| 531 | "for the various similarity metrics (thresholds must be in [0..1]):\n" |
| 532 | "1. in Jaccard mode, the set similarity score must meet the 1st threshold and\n" |
| 533 | " the multiset score meet the 2nd threshold;\n" |
| 534 | "2. in LCS mode, the ratio of common subsequence length and input length must\n" |
| 535 | " be at least the 1st threshold value;\n" |
| 536 | "3. in Cosine mode, the cosine similarity must be at least the 1st threshold.\n\n" |
| 537 | , stdout); |
| 538 | fprintf(stderr, usage_str, basename(argv[0])); |
| 539 | fputs( |
| 540 | "\nCommand line options are:\n" |
| 541 | "-c : output summary in CSV instead of plain text (default) to stderr.\n" |
| 542 | "-d : print debug info to stderr; implies -v.\n" |
| 543 | "-h : print just this text to stderr and stop.\n" |
| 544 | "-i<num> : 1st Jaccard (or LCS, or Cosine) threshold value (default 0.9).\n" |
| 545 | "-j<num> : 2nd Jaccard threshold value (default 0.8).\n" |
| 546 | "-m<mode> : operation mode either jaccard (default), lcs, or cosine.\n" |
| 547 | "-M<int> : samples smaller than this number are discarded (default 20).\n" |
| 548 | "-o<file> : name for output file (instead of stdout).\n" |
| 549 | "-s : also output singleton clusters (default don't).\n" |
| 550 | "-t : insist tokens are TAB-separated (default autodetect).\n" |
| 551 | "-v : print action summary to stderr.\n" |
| 552 | "-w : suppress all warning messages.\n", |
| 553 | stderr); |
| 554 | return 0; |
| 555 | |
| 556 | case 'i': |
| 557 | threshold_0 = atof(optarg); |
nothing calls this directly
no test coverage detected