MCPcopy
hub / github.com/explosion/spaCy / test_dependency_matcher

Function test_dependency_matcher

spacy/tests/matcher/test_dependency_matcher.py:113–133  ·  view source on GitHub ↗
(dependency_matcher, doc, patterns)

Source from the content-addressed store, hash-verified

111
112
113def test_dependency_matcher(dependency_matcher, doc, patterns):
114 assert len(dependency_matcher) == 5
115 assert "pattern3" in dependency_matcher
116 assert dependency_matcher.get("pattern3") == (None, [patterns[2]])
117 matches = dependency_matcher(doc)
118 assert len(matches) == 6
119 assert matches[0][1] == [3, 1, 2]
120 assert matches[1][1] == [4, 3, 5]
121 assert matches[2][1] == [4, 3, 2]
122 assert matches[3][1] == [4, 3]
123 assert matches[4][1] == [4, 3]
124 assert matches[5][1] == [4, 8]
125
126 span = doc[0:6]
127 matches = dependency_matcher(span)
128 assert len(matches) == 5
129 assert matches[0][1] == [3, 1, 2]
130 assert matches[1][1] == [4, 3, 5]
131 assert matches[2][1] == [4, 3, 2]
132 assert matches[3][1] == [4, 3]
133 assert matches[4][1] == [4, 3]
134
135
136def test_dependency_matcher_pickle(en_vocab, patterns, doc):

Callers

nothing calls this directly

Calls 2

dependency_matcherFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…