-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbfb7ce
commit 90811df
Showing
50 changed files
with
1,780 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
|
||
def filterUnneededImports(name): | ||
return False | ||
if "__pyinstaller" in name: | ||
return False | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,92 @@ | ||
# SPDX-License-Identifier: MIT | ||
# Copyright (C) 2022 Max Bachmann | ||
# Copyright (C) 2025 Max Bachmann | ||
from __future__ import annotations | ||
|
||
from rapidfuzz._utils import fallback_import as _fallback_import | ||
import contextlib | ||
import os | ||
|
||
_mod = "rapidfuzz.distance.metrics" | ||
distance = _fallback_import(_mod, "damerau_levenshtein_distance") | ||
similarity = _fallback_import(_mod, "damerau_levenshtein_similarity") | ||
normalized_distance = _fallback_import(_mod, "damerau_levenshtein_normalized_distance") | ||
normalized_similarity = _fallback_import(_mod, "damerau_levenshtein_normalized_similarity") | ||
from rapidfuzz._feature_detector import AVX2, SSE2, supports | ||
|
||
__all__ = ["distance", "normalized_distance", "normalized_similarity", "similarity"] | ||
|
||
_impl = os.environ.get("RAPIDFUZZ_IMPLEMENTATION") | ||
if _impl == "cpp": | ||
imported = False | ||
if supports(AVX2): | ||
with contextlib.suppress(ImportError): | ||
from rapidfuzz.distance.metrics_cpp_avx2 import ( # pyright: ignore[reportMissingImports] | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
|
||
imported = True | ||
|
||
if not imported and supports(SSE2): | ||
with contextlib.suppress(ImportError): | ||
from rapidfuzz.distance.metrics_cpp_sse2 import ( # pyright: ignore[reportMissingImports] | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
|
||
imported = True | ||
|
||
if not imported: | ||
from rapidfuzz.distance.metrics_cpp import ( # pyright: ignore[reportMissingImports] | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
elif _impl == "python": | ||
from rapidfuzz.distance.metrics_py import ( | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
else: | ||
imported = False | ||
if supports(AVX2): | ||
with contextlib.suppress(ImportError): | ||
from rapidfuzz.distance.metrics_cpp_avx2 import ( # pyright: ignore[reportMissingImports] | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
|
||
imported = True | ||
|
||
if not imported and supports(SSE2): | ||
with contextlib.suppress(ImportError): | ||
from rapidfuzz.distance.metrics_cpp_sse2 import ( # pyright: ignore[reportMissingImports] | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
|
||
imported = True | ||
|
||
if not imported: | ||
with contextlib.suppress(ImportError): | ||
from rapidfuzz.distance.metrics_cpp import ( # pyright: ignore[reportMissingImports] | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) | ||
|
||
imported = True | ||
|
||
if not imported: | ||
from rapidfuzz.distance.metrics_py import ( | ||
damerau_levenshtein_distance as distance, | ||
damerau_levenshtein_normalized_distance as normalized_distance, | ||
damerau_levenshtein_normalized_similarity as normalized_similarity, | ||
damerau_levenshtein_similarity as similarity, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.