forked from uniborg/uniborg
clean up parser
This commit is contained in:
parent
969da5bcc9
commit
edd042190d
|
@ -63,25 +63,24 @@ def parse(message):
|
||||||
match = pattern.match(message, pos=i)
|
match = pattern.match(message, pos=i)
|
||||||
if match:
|
if match:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
if match:
|
i += 1
|
||||||
text, entity = parser(match)
|
|
||||||
# replace whole match with text from parser
|
|
||||||
message = ''.join((
|
|
||||||
message[:match.start()],
|
|
||||||
text,
|
|
||||||
message[match.end():]
|
|
||||||
))
|
|
||||||
|
|
||||||
# append entity if we got one
|
|
||||||
if entity:
|
|
||||||
entities.append(entity)
|
|
||||||
|
|
||||||
# skip past the match
|
|
||||||
i += len(text)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
i += 1
|
text, entity = parser(match)
|
||||||
|
# replace whole match with text from parser
|
||||||
|
message = ''.join((
|
||||||
|
message[:match.start()],
|
||||||
|
text,
|
||||||
|
message[match.end():]
|
||||||
|
))
|
||||||
|
|
||||||
|
# append entity if we got one
|
||||||
|
if entity:
|
||||||
|
entities.append(entity)
|
||||||
|
|
||||||
|
# skip past the match
|
||||||
|
i += len(text)
|
||||||
|
|
||||||
return _del_surrogate(message), entities
|
return _del_surrogate(message), entities
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue