mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-25 17:42:24 +08:00
fix: replace editdistance with rapidfuzz for python 3.13 wheel support (#18132)
### Summary Fixes #18107. `editdistance==0.8.1` (the only recent release on PyPI) has no cp313 wheels for any platform. Since this project requires exactly Python 3.13, `uv`/`pip`/`poetry` fall back to building it from source (Cython), which fails on Windows for anyone without a working C build toolchain — that's the PEP 517 build error in the issue. Swapped `editdistance` for `rapidfuzz`, which ships full cp313 wheels (win32/win_amd64/win_arm64 included) and has no build-from-source step on any of our target platforms. The only call site was `EntityResolution.is_similarity` in `rag/graphrag/entity_resolution.py`, using `editdistance.eval(a, b)` to get the unweighted Levenshtein distance between two entity names. `rapidfuzz.distance.Levenshtein.distance(a, b)` computes the same thing (verified identical output on several string pairs) and is used as a direct replacement.
This commit is contained in:
34
test/unit_test/rag/graphrag/test_entity_resolution.py
Normal file
34
test/unit_test/rag/graphrag/test_entity_resolution.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
from rag.graphrag.entity_resolution import EntityResolution
|
||||
|
||||
|
||||
def _resolver():
|
||||
return EntityResolution(llm_invoker=None)
|
||||
|
||||
|
||||
def test_is_similarity_matches_within_half_edit_distance():
|
||||
resolver = _resolver()
|
||||
|
||||
assert resolver.is_similarity("microsoft", "microsfot") is True
|
||||
assert resolver.is_similarity("apple", "orange") is False
|
||||
|
||||
|
||||
def test_is_similarity_identical_strings():
|
||||
resolver = _resolver()
|
||||
|
||||
assert resolver.is_similarity("openai", "openai") is True
|
||||
Reference in New Issue
Block a user