You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is a problem in your fuzzy search logic. In case you execute the line match = re.search(re.escape(best_match[0]), edited_content), you are not updating the pattern variable, which compiles for the exact match string, instead of the fuzzy match result. So when you do pattern.sub, I think this would fail. Did I miss something?
# Use regex to find the content, ignoring leading/trailing whitespace
pattern = re.compile(re.escape(search_content), re.DOTALL)
match = pattern.search(edited_content)
if match or (USE_FUZZY_SEARCH and similarity >= 0.8):
if not match:
# If using fuzzy search and no exact match, find the best match
best_match = difflib.get_close_matches(search_content, [edited_content], n=1, cutoff=0.6)
if best_match:
match = re.search(re.escape(best_match[0]), edited_content)
if match:
# Replace the content using re.sub for more robust replacement
replace_content_cleaned = re.sub(r'</?SEARCH>|</?REPLACE>', '', replace_content)
edited_content = pattern.sub(replace_content_cleaned, edited_content, count=1)
changes_made = True
The text was updated successfully, but these errors were encountered:
Hi,
I think there is a problem in your fuzzy search logic. In case you execute the line
match = re.search(re.escape(best_match[0]), edited_content)
, you are not updating the pattern variable, which compiles for the exact match string, instead of the fuzzy match result. So when you dopattern.sub
, I think this would fail. Did I miss something?The text was updated successfully, but these errors were encountered: