mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-06 06:03:11 +03:00
Add set_struct_attr staticmethod to token
This commit is contained in:
parent
fb69aa648f
commit
87613edf8f
|
@ -3,6 +3,7 @@ from ..vocab cimport Vocab
|
||||||
from ..structs cimport TokenC
|
from ..structs cimport TokenC
|
||||||
from ..attrs cimport *
|
from ..attrs cimport *
|
||||||
from ..typedefs cimport attr_t, flags_t
|
from ..typedefs cimport attr_t, flags_t
|
||||||
|
from ..parts_of_speech cimport univ_pos_t
|
||||||
from .doc cimport Doc
|
from .doc cimport Doc
|
||||||
from ..lexeme cimport Lexeme
|
from ..lexeme cimport Lexeme
|
||||||
|
|
||||||
|
@ -52,3 +53,23 @@ cdef class Token:
|
||||||
return token.ent_type
|
return token.ent_type
|
||||||
else:
|
else:
|
||||||
return Lexeme.get_struct_attr(token.lex, feat_name)
|
return Lexeme.get_struct_attr(token.lex, feat_name)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
cdef inline attr_t set_struct_attr(TokenC* token, attr_id_t feat_name,
|
||||||
|
attr_t value) nogil:
|
||||||
|
if feat_name == LEMMA:
|
||||||
|
token.lemma = value
|
||||||
|
elif feat_name == POS:
|
||||||
|
token.pos = <univ_pos_t>value
|
||||||
|
elif feat_name == TAG:
|
||||||
|
token.tag = value
|
||||||
|
elif feat_name == DEP:
|
||||||
|
token.dep = value
|
||||||
|
elif feat_name == HEAD:
|
||||||
|
token.head = value
|
||||||
|
elif feat_name == SPACY:
|
||||||
|
token.spacy = value
|
||||||
|
elif feat_name == ENT_IOB:
|
||||||
|
token.ent_iob = value
|
||||||
|
elif feat_name == ENT_TYPE:
|
||||||
|
token.ent_type = value
|
||||||
|
|
Loading…
Reference in New Issue
Block a user