From 02cf1d257cac31bda0d0b56136f054875deccb51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BClent=20=C3=96zden?= Date: Sat, 17 Jun 2023 02:42:13 +0300 Subject: [PATCH] Fix apostrophe replace order --- word_usage.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/word_usage.py b/word_usage.py index 14c43be..a4a5c65 100755 --- a/word_usage.py +++ b/word_usage.py @@ -15,13 +15,16 @@ strip_apostrophes = False non_dictionary_only = False -def clean(line): + +def replace_apostrophes(line): # Convert curly apostrophes to straight line = line.replace(u"\u2018", "'") line = line.replace(u"\u2019", "'") line = line.replace(u"\u0060", "'") line = line.replace(u"\u00b4", "'") + +def clean(line): # Filter out symbols line = re.sub("[^a-zA-Z\u00c0-\u024f\u0370-\u1fff\u3040-\ufeff']", " ", line) @@ -34,6 +37,9 @@ def clean(line): def clean_and_split(line, strip_apostrophes=False): + + replace_apostrophes(line) + if strip_apostrophes: # Remove apostrophes to split words line = line.replace("'", " ")