mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
9 lines
307 B
Python
9 lines
307 B
Python
class RegexMerger(object):
|
|
def __init__(self, regexes):
|
|
self.regexes = regexes
|
|
|
|
def __call__(self, tokens):
|
|
for tag, entity_type, regex in self.regexes:
|
|
for m in regex.finditer(tokens.string):
|
|
tokens.merge(m.start(), m.end(), tag, m.group(), entity_type)
|