how to reference "corpora.Dictionary(texts)"

103 views
Skip to first unread message

tehja...@gmail.com

unread,
Mar 2, 2019, 1:54:34 PM3/2/19
to Gensim
Hi. 

issue:  at the line "dictionary = corpora.Dictionary(texts)" it reports "NameError: name 'corpora' is not defined"

I've tried this in Spyder and PyCharm, and get the same error. 
I've searched for this error, and there's nothing specific to how to, what i'll describe as, ensure there is some "corpora" instance to which it can refer. 


context:
I'm new to Python and gensim. 
my goal: Complete the gensim tutorial on "Corpora and vector spaces."
ultimate goal(s):  Use Python, gensim, LSA to extract insights from research on software users I gather while doing UX research. 

system environment:
macOS Mojave  v10.14.3 on 2017 MacBook Pro
PyCharm 2018.3.5 (Community Edition)
Build #PC-183.5912.18, built on February 26, 2019
JRE: 1.8.0_152-release-1343-b28 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o


If this exists somewhere (1) I apologize for not finding it... I'm a bit exhausted from trying and trouble-shooting; and, (2) appreciate if you can point me there. 


Humbly from a beginner,
Jay

Radim Řehůřek

unread,
Mar 2, 2019, 2:21:51 PM3/2/19
to Gensim
Hi Jay,

this seems to be a bug introduced by an external contributor recently:

My apologies. The correct way to fix this is to execute `from gensim import corpora`.

We'll fix this in the next release.

Best,
Radim

tehja...@gmail.com

unread,
Mar 2, 2019, 3:13:12 PM3/2/19
to Gensim
Thank you, Radim. I appreciate your work to share this with us, and your quick reply.

Starting with the 'import' in PyCharm, it display: 
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'gensim'

Starting with the 'import' command in Spyder, it displays: 
"ImportError: cannot import name 'corpora' from 'gensim' (unknown location)"

Is there some setup even prior to running any gensim tutorials? 


Thanks,
Jay

Radim Řehůřek

unread,
Mar 3, 2019, 6:16:24 AM3/3/19
to Gensim
No, nothing beyond installing Gensim itself.

HTH,
Radim

Jay Bird

unread,
Mar 6, 2019, 8:57:51 PM3/6/19
to gen...@googlegroups.com
Thank you. This worked. 

I'd installed Gensim in Terminal, and presumed it was present so far. Ran that in Spyder, and it found it. 

--
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages