class Solution(object):
def entityParser(self, text):
"""
:type text: str
:rtype: str
"""
entity_map = {
'"': '"',
''': "'",
'>': '>',
'<': '<',
'⁄': '/',
'&': '&',
}
n = len(text)
p = 0
ans = []
while p < n:
flag = False
if text[p] == '&':
for t in entity_map:
if text[p: p + len(t)] == t:
ans.append(entity_map[t])
flag = True
p += len(t)
break
if not flag:
ans.append(text[p])
p += 1
return "".join(ans)