2015-12-23 23:03:40 +01:00
|
|
|
"""
|
|
|
|
This file contains various utility functions.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2015-12-23 22:49:14 +01:00
|
|
|
def replaceAll(text, dic):
|
|
|
|
"""Replace all the dic keys by the associated item in text"""
|
|
|
|
for i, j in dic.items():
|
|
|
|
text = text.replace(i, j)
|
|
|
|
return text
|
|
|
|
|
|
|
|
|
|
|
|
def clean_whitespaces(text):
|
|
|
|
"""
|
|
|
|
Remove double whitespaces and trailing . and , from text.
|
|
|
|
"""
|
|
|
|
return ' '.join(text.strip().rstrip(".,").split())
|