mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-04 21:50:35 +03:00
Check in PatternParser that the generated Pattern is valid
This commit is contained in:
parent
e55199d454
commit
8ff4f512a2
|
@ -38,8 +38,18 @@ class PatternParser(object):
|
|||
if not pattern.nodes:
|
||||
return
|
||||
|
||||
cls.check_pattern(pattern)
|
||||
return pattern
|
||||
|
||||
@staticmethod
|
||||
def check_pattern(pattern):
|
||||
if not pattern.is_connected():
|
||||
raise ValueError("The pattern tree must be a fully connected "
|
||||
"graph.")
|
||||
|
||||
if pattern.root_node is None:
|
||||
raise ValueError("The root node of the tree could not be found.")
|
||||
|
||||
@classmethod
|
||||
def _parse_line(cls, stream, pattern, lineno):
|
||||
while not stream.closed:
|
||||
|
|
Loading…
Reference in New Issue
Block a user