* Fix Issue #43: TAG attr not supported. Also add DEP attr, while I'm at it. Need better way of ensuring future changes don't break in similar way.

This commit is contained in:
Matthew Honnibal 2015-04-07 05:54:53 +02:00
parent 6674d719a5
commit b64b2bd910
3 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ from ..attrs cimport SUFFIX as _SUFFIX
from ..attrs cimport LEMMA as _LEMMA from ..attrs cimport LEMMA as _LEMMA
from ..attrs cimport POS as _POS from ..attrs cimport POS as _POS
from ..attrs cimport TAG as _TAG from ..attrs cimport TAG as _TAG
from ..attrs cimport DEP as _DEP
cpdef enum: cpdef enum:
@ -35,3 +36,4 @@ cpdef enum:
LEMMA = _LEMMA LEMMA = _LEMMA
POS = _POS POS = _POS
TAG = _TAG TAG = _TAG
DEP = _DEP

View File

@ -9,7 +9,7 @@ from .vocab cimport EMPTY_LEXEME
from .typedefs cimport attr_id_t, attr_t from .typedefs cimport attr_id_t, attr_t
from .typedefs cimport LEMMA from .typedefs cimport LEMMA
from .typedefs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER from .typedefs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER
from .typedefs cimport POS, LEMMA from .typedefs cimport POS, LEMMA, TAG, DEP
from .parts_of_speech import UNIV_POS_NAMES from .parts_of_speech import UNIV_POS_NAMES
from .lexeme cimport check_flag from .lexeme cimport check_flag
from .spans import Span from .spans import Span
@ -25,6 +25,7 @@ cimport cython
from cpython.mem cimport PyMem_Malloc, PyMem_Free from cpython.mem cimport PyMem_Malloc, PyMem_Free
from libc.string cimport memcpy from libc.string cimport memcpy
DEF PADDING = 5 DEF PADDING = 5
@ -40,6 +41,10 @@ cdef attr_t get_token_attr(const TokenC* token, attr_id_t feat_name) nogil:
return token.lemma return token.lemma
elif feat_name == POS: elif feat_name == POS:
return token.pos return token.pos
elif feat_name == TAG:
return token.tag
elif feat_name == DEP:
return token.dep
else: else:
return get_lex_attr(token.lex, feat_name) return get_lex_attr(token.lex, feat_name)

View File

@ -81,6 +81,9 @@ cpdef enum attr_id_t:
CLUSTER CLUSTER
LEMMA LEMMA
POS POS
TAG
DEP
ENT