Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix word2vec doc-comment example of KeyedVectors usage, issue 2669 #2789

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@

.. sourcecode:: pycon

>>> from gensim.test.utils import common_texts, get_tmpfile
>>> from gensim.test.utils import common_texts
>>> from gensim.models import Word2Vec
>>> from tempfile import mkdtemp
>>> from os import chdir
>>>
>>> path = get_tmpfile("word2vec.model")
>>> path = mkdtemp() # make a note of this path if you need it for later
>>> chdir(path)
>>>
>>> model = Word2Vec(common_texts, size=100, window=5, min_count=1, workers=4)
>>> model.save("word2vec.model")
Expand Down Expand Up @@ -70,10 +73,8 @@

>>> from gensim.models import KeyedVectors
>>>
>>> path = get_tmpfile("wordvectors.kv")
>>>
>>> model.wv.save(path)
>>> wv = KeyedVectors.load("model.wv", mmap='r')
>>> model.wv.save("wordvectors.kv")
>>> wv = KeyedVectors.load("wordvectors.kv", mmap='r')
>>> vector = wv['computer'] # numpy vector of a word

Gensim can also load word vectors in the "word2vec C format", as a
Expand Down