Skip to content

Commit d11facc

Browse files
committed
Increase hamming_distance_threshold
Signed-off-by: Jono Yang <[email protected]>
1 parent c3c0c22 commit d11facc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

matchcode/models.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def match(cls, fingerprint, resource=None, exact_match=False):
269269

270270
# Step 2: calculate Hamming distance of all matches
271271

272+
hamming_distance_threshold = 10
272273
# Store all close matches in a dictionary of querysets
273274
matches_by_hamming_distance = defaultdict(cls.objects.none)
274275
for match in matches:
@@ -281,7 +282,8 @@ def match(cls, fingerprint, resource=None, exact_match=False):
281282
hd = byte_hamming_distance(bah128, match_bah128)
282283

283284
# TODO: try other thresholds if this is too restrictive
284-
if hd < 8:
285+
# TODO: rank matches instead of having threshold
286+
if hd < hamming_distance_threshold:
285287
# Save match to `matches_by_hamming_distance` by adding the matched object
286288
# to the queryset
287289
matches_by_hamming_distance[hd] |= cls.objects.filter(pk=match.pk)

0 commit comments

Comments
 (0)