chartbeat-labs / textacy

NLP, before and after spaCy
https://textacy.readthedocs.io
Other
2.21k stars 249 forks source link

Local variable 'spacy_lang' referenced before assignment #205

Closed ProxyCausal closed 6 years ago

ProxyCausal commented 6 years ago

Tried installing the latest developer version of textacy in the master, by cloning the git into local directory and using pip install -e Imported textacy.spacier.utils.make_doc_from_text_chunks (couldn't wait for 0.6.2) and used it with add text to Corpus

Got this error

UnboundLocalError                         Traceback (most recent call last)
<ipython-input-8-cbd2470b16ae> in <module>()
      7 for i in np.arange(len(flat_corpus)):
      8     if len(flat_corpus[i]) >= long_texts:
----> 9         doc = textacy.spacier.utils.make_doc_from_text_chunks(flat_corpus[i], english, chunk_size=100000)
     10         corpus.add_text(doc)
     11     else:

c:\users\gdev\documents\research\nlp\textacy\textacy\spacier\utils.py in make_doc_from_text_chunks(text, lang, chunk_size)
     66     # iterate over text chunks and accumulate components needed to make a doc
     67     while i < text_len:
---> 68         chunk_doc = spacy_lang(text[i: i + chunk_size])
     69         words.extend(tok.text for tok in chunk_doc)
     70         spaces.extend(bool(tok.whitespace_) for tok in chunk_doc)

UnboundLocalError: local variable 'spacy_lang' referenced before assignment
bdewilde commented 6 years ago

Oof, that's my mistake — commit imminent with the bugfix.