Fix gaps in Lexeme API. Closes #1031

This commit is contained in:
Matthew Honnibal 2017-07-22 13:53:48 +02:00
parent 83e1b5f1e3
commit 0ae3807d7d
2 changed files with 22 additions and 0 deletions

View File

@ -159,6 +159,10 @@ cdef class Lexeme:
def __get__(self): def __get__(self):
return self.c.id return self.c.id
property lex_id:
def __get__(self):
return self.c.id
property repvec: property repvec:
def __get__(self): def __get__(self):
raise AttributeError("lex.repvec has been renamed to lex.vector") raise AttributeError("lex.repvec has been renamed to lex.vector")
@ -173,6 +177,11 @@ cdef class Lexeme:
def __get__(self): def __get__(self):
return self.vocab.strings[self.c.orth] return self.vocab.strings[self.c.orth]
property text:
def __get__(self):
return self.vocab.strings[self.c.orth]
property lower: property lower:
def __get__(self): return self.c.lower def __get__(self): return self.c.lower
def __set__(self, int x): self.c.lower = x def __set__(self, int x): self.c.lower = x

View File

@ -0,0 +1,13 @@
from ...vocab import Vocab
def test_lexeme_text():
vocab = Vocab()
lex = vocab[u'the']
assert lex.text == u'the'
def test_lexeme_lex_id():
vocab = Vocab()
lex1 = vocab[u'the']
lex2 = vocab[u'be']
assert lex1.lex_id != lex2.lex_id