mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Fix #588: Matcher should reject empty pattern.
This commit is contained in:
parent
72b9bd57ec
commit
f1605df2ec
|
@ -273,6 +273,12 @@ cdef class Matcher:
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
|
token_specs = list(token_specs)
|
||||||
|
if len(token_specs) == 0:
|
||||||
|
msg = ("Cannot add pattern for zero tokens to matcher.\n"
|
||||||
|
"entity_key: {entity_key}\n"
|
||||||
|
"label: {label}")
|
||||||
|
raise ValueError(msg.format(entity_key=entity_key, label=label))
|
||||||
entity_key = self.normalize_entity_key(entity_key)
|
entity_key = self.normalize_entity_key(entity_key)
|
||||||
if not self.has_entity(entity_key):
|
if not self.has_entity(entity_key):
|
||||||
self.add_entity(entity_key)
|
self.add_entity(entity_key)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user