-
Notifications
You must be signed in to change notification settings - Fork 5
Description
These 2 functions could be significantly improved.
-
instead of returning a list with one dict entry each, just return a single dictionary with all the entries
i used the following to quickly convert them into a proper dict
d = {}
for r in parsedAddress:
key = list(r.keys())[0]
value = list(r.values())[0]
d[key] = value -
use text = re.sub('[àáâãăäāå]', '', text) it will be much faster
And where are the other functions from the library ?
def stringToJSON(string):
if not string in ['{}']:
string = string.replace('{ ', '')
string = string.replace('}', '')
string = string.replace('"', '')
string = string.split(", ")
stringList = [i.split(': ') for i in string]
outDictList = []
for i in stringList:
outDictList.append({i[0]: i[1].rstrip().lstrip()})
return outDictList
else:
return {}
def removeSpeacialChars(address):
b = {'≈': '', '≠': '', '>': '', '<': '', '+': '', '≥': '', '≤': '', '±': '', '*': '', '÷': '', '√': '',
'°': '', '⊥': '', '~': '', 'Δ': '', 'π': '', '≡': '', '≜': '', '∝': '', '∞': '', '≪': '', '≫': '',
'⌈': '', '⌉': '', '⌋': '', '⌊': '', '∑': '', '∏': '', 'γ': '', 'φ': '', '⊃': '', '⋂': '', '⋃': '',
'μ': '', 'σ': '', 'ρ': '', 'λ': '', 'χ': '', '⊄': '', '⊆': '', '⊂': '', '⊇': '', '⊅': '', '⊖': '',
'∈': '', '∉': '', '⊕': '', '⇒': '', '⇔': '', '↔': '', '∀': '', '∃': '', '∄': '', '∴': '', '∵': '',
'ε': '', '∫': '', '∮': '', '∯': '', '∰': '', 'δ': '', 'ψ': '', 'Θ': '', 'θ': '', 'α': '', 'β': '',
'ζ': '', 'η': '', 'ι': '', 'κ': '', 'ξ': '', 'τ': '', 'ω': '', '∇': ''}
for x, y in b.items():
address = address.replace(x, y)
return address