diff --git a/spacy/language.py b/spacy/language.py index 8e50e298e..771d14de4 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -29,6 +29,7 @@ from . import util from .lemmatizer import Lemmatizer from .attrs import TAG, DEP, ENT_IOB, ENT_TYPE, HEAD, PROB, LANG, IS_STOP +from .syntax.parser import get_templates class BaseDefaults(object): @@ -98,14 +99,14 @@ class BaseDefaults(object): return Parser.load(self.path / 'deps', vocab, ArcEager) else: return Parser.blank(vocab, ArcEager, - Parser.default_templates('%s-parser' % self.lang)) + features=self.parser_features, labels=self.parser_labels) def Entity(self, vocab): if self.path and (self.path / 'ner').exists(): return Parser.load(self.path / 'ner', vocab, BiluoPushDown) else: return Parser.blank(vocab, BiluoPushdown, - Parser.default_templates('%s-entity' % self.lang)) + features=self.entity_features, labels=self.entity_labels) def Matcher(self, vocab): if self.path: @@ -120,9 +121,13 @@ class BaseDefaults(object): nlp.parser, nlp.entity] - dep_labels = {0: {'ROOT': True}} + parser_labels = {0: {'ROOT': True}} - ner_labels = {0: {'PER': True, 'LOC': True, 'ORG': True, 'MISC': True}} + entity_labels = {0: {'PER': True, 'LOC': True, 'ORG': True, 'MISC': True}} + + parser_features = get_templates('parser') + + entity_features = get_templates('ner') stop_words = set() diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 0419c339d..344a13fad 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -89,6 +89,14 @@ cdef class Parser: model.load(str(path / 'model')) return cls(vocab, moves, model, **cfg) + @classmethod + def blank(cls, Vocab vocab, moves_class, **cfg): + moves = moves_class(vocab.strings, cfg.get('labels', {})) + templates = get_templates(cfg.get('features', tuple())) + model = ParserModel(templates) + return cls(vocab, moves, model, **cfg) + + def __init__(self, Vocab vocab, transition_system, ParserModel model, **cfg): self.moves = transition_system self.model = model diff --git a/spacy/tests/conftest.py b/spacy/tests/conftest.py index cc64ee46f..901f459dd 100644 --- a/spacy/tests/conftest.py +++ b/spacy/tests/conftest.py @@ -3,6 +3,7 @@ import os import spacy + @pytest.fixture(scope="session") def EN(): return spacy.load("en") @@ -21,7 +22,6 @@ def pytest_addoption(parser): help="include slow tests") - def pytest_runtest_setup(item): for opt in ['models', 'vectors', 'slow']: if opt in item.keywords and not item.config.getoption("--%s" % opt):