Skip to content

Commit d2b6f08

Browse files
committed
Fix potential TokensNotFullyConnected error that arises from extending trees by siblings of the root token in yield_extended_trees
1 parent dbfb04a commit d2b6f08

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='spacy-pattern-builder',
8-
version='0.0.6',
8+
version='0.0.7',
99
description='Reverse engineer patterns for use with the SpaCy DependencyTreeMatcher',
1010
long_description=readme,
1111
long_description_content_type='text/markdown',

spacy_pattern_builder/mutate.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def yield_extended_trees(match_tokens):
5757
if is_root:
5858
extend_by.append(token.head)
5959
extend_by += token.children
60-
extend_by += util.siblings(token)
60+
if not is_root:
61+
# Only extend by siblings if the token is not root, as this would also require adding the common root that connects these siblings or else the tokens would not be fully connected.
62+
extend_by += util.siblings(token)
6163
extend_by = [t for t in extend_by if t]
6264
extend_by = [t for t in extend_by if t not in match_tokens]
6365
extend_by = util.de_duplicate_list(extend_by)

0 commit comments

Comments
 (0)