spaCy/spacy/pipeline.pyx

67 lines
1.8 KiB
Cython
Raw Normal View History

# coding: utf8
from __future__ import unicode_literals
from .syntax.parser cimport Parser
2017-03-11 13:00:20 +00:00
from .syntax.beam_parser cimport BeamParser
from .syntax.ner cimport BiluoPushDown
from .syntax.arc_eager cimport ArcEager
from .tagger import Tagger
# TODO: The disorganization here is pretty embarrassing. At least it's only
# internals.
from .syntax.parser import get_templates as get_feature_templates
from .attrs import DEP, ENT_TYPE
cdef class EntityRecognizer(Parser):
"""
Annotate named entities on Doc objects.
"""
TransitionSystem = BiluoPushDown
2017-03-11 13:00:20 +00:00
feature_templates = get_feature_templates('ner')
def add_label(self, label):
Parser.add_label(self, label)
if isinstance(label, basestring):
label = self.vocab.strings[label]
2017-03-15 14:27:41 +00:00
cdef class BeamEntityRecognizer(BeamParser):
"""
Annotate named entities on Doc objects.
"""
2017-03-15 14:27:41 +00:00
TransitionSystem = BiluoPushDown
feature_templates = get_feature_templates('ner')
2017-03-15 14:27:41 +00:00
def add_label(self, label):
Parser.add_label(self, label)
2017-03-15 14:27:41 +00:00
if isinstance(label, basestring):
label = self.vocab.strings[label]
2017-03-11 17:11:30 +00:00
cdef class DependencyParser(Parser):
TransitionSystem = ArcEager
feature_templates = get_feature_templates('basic')
def add_label(self, label):
Parser.add_label(self, label)
if isinstance(label, basestring):
label = self.vocab.strings[label]
2017-03-15 14:27:41 +00:00
cdef class BeamDependencyParser(BeamParser):
TransitionSystem = ArcEager
feature_templates = get_feature_templates('basic')
def add_label(self, label):
Parser.add_label(self, label)
2017-03-15 14:27:41 +00:00
if isinstance(label, basestring):
label = self.vocab.strings[label]
__all__ = [Tagger, DependencyParser, EntityRecognizer, BeamDependencyParser, BeamEntityRecognizer]