X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=match_fingerprints;fp=match_fingerprints;h=8f0d485831f815dd4d312230cafdaa4368283aa4;hp=4c7748033b3ba9e9f2e588c42992168c2fa9e819;hb=2fefcf603c66dc442489e554a4b72733a1f1803f;hpb=5b3e8ef51110574c502303ea6f7070458022c1f2 diff --git a/match_fingerprints b/match_fingerprints index 4c77480..8f0d485 100755 --- a/match_fingerprints +++ b/match_fingerprints @@ -62,7 +62,7 @@ sub populate_fingerprint { $fp{sha1} = sha1_base64($stripped); # make sure file is sorted properly - if ($lastscore and ($fp{compact} > $lastscore)) { + if ($lastscore and ($fp{compact} < $lastscore)) { print "Input file is sorted improperly or unsorted.\n"; die "Sort descending (sort -r) and rerun this script.\n"; } @@ -79,7 +79,7 @@ sub rank_fingerprint { my $id = $fp->{id}; # only process records which haven't already been seen - unless (defined $seen{$id}) { + #unless (defined $seen{$id}) { unless (defined $fps{$sha1}) { # haven't seen this fp before. create a new listref to hold subs # and stow the hash of the fingerprint that we're lead of @@ -90,7 +90,7 @@ sub rank_fingerprint { push @{ $fps{$sha1} }, $id; } $seen{$id} = 1; - } + #} } @@ -107,16 +107,38 @@ sub dump_records { for my $rec (@recs) { for ( @{ $fps{ $rec->{sha1} } } ) { # check for dupes and die if they exist - die "Collision: dupe sub record $_\n" if $subs{$_}; - $subs{$_} = 1; - die "Collision: lead in sub list ", $rec->{id}, "\n" - if $subs{ $rec->{id} }; - - # we don't want subs below threshold - next if ($_ < $conf->{threshold}); - - # still here? output. - print OUT $rec->{id}, "\t$_\n" + #die "Collision: dupe sub record $_\n" if $subs{$_}; + if( not exists ($subs{$_}) ) { + #die "Collision: lead in sub list ", $rec->{id}, "\n" + # if $subs{ $rec->{id} }; + my $lead = $rec->{id}; + + # we don't need to match onto itself + next if ($lead eq $_); + + if ($subs{ $rec->{id} }) + { + print "moving ".$lead." to ".$subs{$rec->{id}}."\n"; + $lead = $subs{$rec->{id}}; + } + + if($_ eq '1459051') + { + print "looking at ".$rec->{sha1}; + } + + # we don't want subs below threshold + next if ($_ < $conf->{threshold}); + + # we don't need to match onto itself + next if ($lead eq $_); + + # record this sub having this leader + $subs{$_} = $lead; + + # still here? output. + print OUT $lead, "\t$_\n" + } } } }