mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Try to reduce memory usage of test_matcher
This commit is contained in:
parent
24563f4026
commit
7b575a119e
|
@ -3,12 +3,17 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from ..matcher import Matcher, PhraseMatcher
|
from ..matcher import Matcher, PhraseMatcher
|
||||||
from .util import get_doc
|
from .util import get_doc
|
||||||
|
from ..util import get_lang_class
|
||||||
from ..tokens import Doc
|
from ..tokens import Doc
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def en_vocab():
|
||||||
|
return get_lang_class('en').Defaults.create_vocab()
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
def matcher(en_vocab):
|
def matcher(en_vocab):
|
||||||
rules = {
|
rules = {
|
||||||
'JS': [[{'ORTH': 'JavaScript'}]],
|
'JS': [[{'ORTH': 'JavaScript'}]],
|
||||||
|
@ -76,7 +81,15 @@ def test_matcher_no_match(matcher):
|
||||||
assert matcher(doc) == []
|
assert matcher(doc) == []
|
||||||
|
|
||||||
|
|
||||||
def test_matcher_compile(matcher):
|
def test_matcher_compile(en_vocab):
|
||||||
|
rules = {
|
||||||
|
'JS': [[{'ORTH': 'JavaScript'}]],
|
||||||
|
'GoogleNow': [[{'ORTH': 'Google'}, {'ORTH': 'Now'}]],
|
||||||
|
'Java': [[{'LOWER': 'java'}]]
|
||||||
|
}
|
||||||
|
matcher = Matcher(en_vocab)
|
||||||
|
for key, patterns in rules.items():
|
||||||
|
matcher.add(key, None, *patterns)
|
||||||
assert len(matcher) == 3
|
assert len(matcher) == 3
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user