mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
* Add multi-word expression RegexMatcher
This commit is contained in:
parent
2fee67cfa3
commit
0ea5af88b6
8
spacy/multi_words.py
Normal file
8
spacy/multi_words.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
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(unicode(tokens)):
|
||||
tokens.merge(m.start(), m.end(), tag, m.group(), entity_type)
|
Loading…
Reference in New Issue
Block a user