Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Fix #307: inconsistent preprocessing #308

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions fuzzywuzzy/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,6 @@ def no_process(x):
if processor is None:
processor = no_process

# Run the processor on the input query.
processed_query = processor(query)

if len(processed_query) == 0:
logging.warning(u"Applied processor reduces input query to empty string, "
"all comparisons will have score 0. "
"[Query: \'{0}\']".format(query))

# Don't run full_process twice
if scorer in [fuzz.WRatio, fuzz.QRatio,
fuzz.token_set_ratio, fuzz.token_sort_ratio,
fuzz.partial_token_set_ratio, fuzz.partial_token_sort_ratio,
fuzz.UWRatio, fuzz.UQRatio] \
and processor == utils.full_process:
processor = no_process

# Only process the query once instead of for every choice
if scorer in [fuzz.UWRatio, fuzz.UQRatio]:
pre_processor = partial(utils.full_process, force_ascii=False)
Expand All @@ -101,7 +85,14 @@ def no_process(x):
scorer = partial(scorer, full_process=False)
else:
pre_processor = no_process
processed_query = pre_processor(processed_query)

# Run the processor-preprocessor on the input query.
processed_query = pre_processor(processor(query))

if len(processed_query) == 0:
logging.warning(u"Applied processor reduces input query to empty string, "
"all comparisons will have score 0. "
"[Query: \'{0}\']".format(query))

try:
# See if choices is a dictionary-like object.
Expand Down