mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 21:57:15 +03:00
* Add sense and sense_ properties to Token objects
This commit is contained in:
parent
8f068dc6fe
commit
e99e15574e
|
@ -15,6 +15,7 @@ from .parts_of_speech cimport CONJ, PUNCT
|
||||||
from .lexeme cimport check_flag
|
from .lexeme cimport check_flag
|
||||||
from .spans import Span
|
from .spans import Span
|
||||||
from .structs cimport UniStr
|
from .structs cimport UniStr
|
||||||
|
from .senses import STRINGS as SENSE_STRINGS
|
||||||
|
|
||||||
from unidecode import unidecode
|
from unidecode import unidecode
|
||||||
# Compiler crashes on memory view coercion without this. Should report bug.
|
# Compiler crashes on memory view coercion without this. Should report bug.
|
||||||
|
@ -462,6 +463,10 @@ cdef class Token:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return self.c.dep
|
return self.c.dep
|
||||||
|
|
||||||
|
property sense:
|
||||||
|
def __get__(self):
|
||||||
|
return self.c.sense
|
||||||
|
|
||||||
property repvec:
|
property repvec:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
cdef int length = self.vocab.repvec_length
|
cdef int length = self.vocab.repvec_length
|
||||||
|
@ -646,6 +651,11 @@ cdef class Token:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return self.vocab.strings[self.c.dep]
|
return self.vocab.strings[self.c.dep]
|
||||||
|
|
||||||
|
property sense_:
|
||||||
|
def __get__(self):
|
||||||
|
return SENSE_STRINGS[self.c.sense]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_pos_id_to_string = {id_: string for string, id_ in UNIV_POS_NAMES.items()}
|
_pos_id_to_string = {id_: string for string, id_ in UNIV_POS_NAMES.items()}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user