* Add POS attribute support in get_attr

This commit is contained in:
Matthew Honnibal 2015-09-06 04:13:03 +02:00
parent bf38b3b883
commit fd1eeb3102
1 changed files with 4 additions and 0 deletions

View File

@ -12,6 +12,7 @@ from ..attrs cimport ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX, LENGTH, CLUST
from ..attrs cimport POS, LEMMA, TAG, DEP, HEAD, SPACY, ENT_IOB, ENT_TYPE from ..attrs cimport POS, LEMMA, TAG, DEP, HEAD, SPACY, ENT_IOB, ENT_TYPE
from ..parts_of_speech import UNIV_POS_NAMES from ..parts_of_speech import UNIV_POS_NAMES
from ..parts_of_speech cimport CONJ, PUNCT, NOUN from ..parts_of_speech cimport CONJ, PUNCT, NOUN
from ..parts_of_speech cimport univ_pos_t
from ..lexeme cimport check_flag from ..lexeme cimport check_flag
from ..lexeme cimport get_attr as get_lex_attr from ..lexeme cimport get_attr as get_lex_attr
from .spans cimport Span from .spans cimport Span
@ -327,6 +328,9 @@ cdef class Doc:
elif attr_id == TAG: elif attr_id == TAG:
for i in range(length): for i in range(length):
tokens[i].tag = values[i] tokens[i].tag = values[i]
elif attr_id == POS:
for i in range(length):
tokens[i].pos = <univ_pos_t>values[i]
elif attr_id == DEP: elif attr_id == DEP:
for i in range(length): for i in range(length):
tokens[i].dep = values[i] tokens[i].dep = values[i]