mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 05:37:03 +03:00
Fix matcher callback example (closes #3862)
This commit is contained in:
parent
6ccdf37574
commit
d361e380b8
|
@ -305,11 +305,11 @@ match on the uppercase versions, in case someone has written it as "Google i/o".
|
||||||
|
|
||||||
```python
|
```python
|
||||||
### {executable="true"}
|
### {executable="true"}
|
||||||
import spacy
|
from spacy.lang.en import English
|
||||||
from spacy.matcher import Matcher
|
from spacy.matcher import Matcher
|
||||||
from spacy.tokens import Span
|
from spacy.tokens import Span
|
||||||
|
|
||||||
nlp = spacy.load("en_core_web_sm")
|
nlp = English()
|
||||||
matcher = Matcher(nlp.vocab)
|
matcher = Matcher(nlp.vocab)
|
||||||
|
|
||||||
def add_event_ent(matcher, doc, i, matches):
|
def add_event_ent(matcher, doc, i, matches):
|
||||||
|
@ -322,7 +322,7 @@ def add_event_ent(matcher, doc, i, matches):
|
||||||
|
|
||||||
pattern = [{"ORTH": "Google"}, {"ORTH": "I"}, {"ORTH": "/"}, {"ORTH": "O"}]
|
pattern = [{"ORTH": "Google"}, {"ORTH": "I"}, {"ORTH": "/"}, {"ORTH": "O"}]
|
||||||
matcher.add("GoogleIO", add_event_ent, pattern)
|
matcher.add("GoogleIO", add_event_ent, pattern)
|
||||||
doc = nlp(u"This is a text about Google I/O.")
|
doc = nlp(u"This is a text about Google I/O")
|
||||||
matches = matcher(doc)
|
matches = matcher(doc)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user