arxiv_metadata/tools.py

13 lines
336 B
Python
Raw Normal View History

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())