Bug fix (didn't keep any beginning or ending space)

This commit is contained in:
Valentin Lorentz 2010-11-01 11:47:19 +01:00
parent 4dcd7f7fb4
commit a2c8c613db

View File

@ -61,7 +61,14 @@ def rsplit(s, sep=None, maxsplit=-1):
def normalizeWhitespace(s): def normalizeWhitespace(s):
"""Normalizes the whitespace in a string; \s+ becomes one space.""" """Normalizes the whitespace in a string; \s+ becomes one space."""
return ' '.join(s.split()) beginning = s.startswith(' ')
ending = s.endswith(' ')
s = ' '.join(s.split())
if beginning:
s = ' ' + s
if ending:
s = s + ' '
return s
def distance(s, t): def distance(s, t):
"""Returns the levenshtein edit distance between two strings.""" """Returns the levenshtein edit distance between two strings."""