Spacy: Problems with Lexeme

Created on 30 Apr 2017  路  2Comments  路  Source: explosion/spaCy

Hi! The following doesn't work:

import spacy
nlp = spacy.load('en')
print(max(lex.lex_id for lex in nlp.vocab) + 1)
print([lex.text for lex in nlp.vocab if not lex.has_vector])

It gives errors like:

AttributeError: 'spacy.lexeme.Lexeme' object has no attribute 'lex_id'
AttributeError: 'spacy.lexeme.Lexeme' object has no attribute 'text'

But Lexeme should have attributes text and lex_id according to the documentation.

My Environment

spacy.info()

Info about spaCy

    spaCy version      1.8.2          
    Location           /home/dan/miniconda/envs/py36/lib/python3.6/site-packages/spacy
    Platform           Linux-4.8.0-49-generic-x86_64-with-debian-stretch-sid
    Python version     3.6.0          
    Installed models    en, en_core_web_md
bug

Most helpful comment

Thanks. Workaround for now:

  • Instead of lex.text you can use lex.orth_
  • Instead of lex.lex_id you can use lex.rank

All 2 comments

Thanks. Workaround for now:

  • Instead of lex.text you can use lex.orth_
  • Instead of lex.lex_id you can use lex.rank

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TropComplique picture TropComplique  路  3Comments

besirkurtulmus picture besirkurtulmus  路  3Comments

cverluise picture cverluise  路  3Comments

bebelbop picture bebelbop  路  3Comments

prashant334 picture prashant334  路  3Comments