arxiv_metadata/reference_fetcher/tools.py

18 lines
392 B
Python
Raw Normal View History

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