Skip to content
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
8 changes: 7 additions & 1 deletion word_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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("'", " ")
Expand Down