Skip to content

Commit

Permalink
Add gensim-data repo to gensim.downloader & fix rendering of code …
Browse files Browse the repository at this point in the history
…examples (#2327)
  • Loading branch information
menshikh-iv authored Jan 10, 2019
1 parent 01f4ac8 commit a3dbdcc
Show file tree
Hide file tree
Showing 25 changed files with 23 additions and 39 deletions.
7 changes: 0 additions & 7 deletions gensim/corpora/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def doc2bow(self, document, allow_update=False, return_missing=False):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down Expand Up @@ -339,7 +338,6 @@ def filter_extremes(self, no_below=5, no_above=0.5, keep_n=100000, keep_tokens=N
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down Expand Up @@ -392,7 +390,6 @@ def filter_n_most_frequent(self, remove_n):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down Expand Up @@ -431,7 +428,6 @@ def filter_tokens(self, bad_ids=None, good_ids=None):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down Expand Up @@ -556,7 +552,6 @@ def merge_with(self, other):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down Expand Up @@ -612,7 +607,6 @@ def load_from_text(fname):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down Expand Up @@ -677,7 +671,6 @@ def from_corpus(corpus, id2word=None):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import Dictionary
Expand Down
2 changes: 0 additions & 2 deletions gensim/corpora/hashdictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def add_documents(self, documents):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import HashDictionary
Expand Down Expand Up @@ -331,7 +330,6 @@ def save_as_text(self, fname):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import HashDictionary
Expand Down
1 change: 0 additions & 1 deletion gensim/corpora/indexedcorpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def serialize(serializer, fname, corpus, id2word=None, index_fname=None,
Examples
--------
.. sourcecode:: pycon
>>> from gensim.corpora import MmCorpus
Expand Down
1 change: 0 additions & 1 deletion gensim/corpora/malletcorpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def line2doc(self, line):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down
5 changes: 5 additions & 0 deletions gensim/downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
This module is an API for downloading, getting information and loading datasets/models.
See `RaRe-Technologies/gensim-data <https://github.com/RaRe-Technologies/gensim-data>`_ repo
for more information about models/datasets/how-to-add-new/etc.
Give information about available models/datasets:
.. sourcecode:: pycon
Expand All @@ -12,6 +15,7 @@
Model example:
.. sourcecode:: pycon
>>> import gensim.downloader as api
Expand All @@ -21,6 +25,7 @@
Dataset example:
.. sourcecode:: pycon
>>> import gensim.downloader as api
Expand Down
1 change: 0 additions & 1 deletion gensim/models/atmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
Example
-------
.. sourcecode:: pycon
>>> from gensim.models import AuthorTopicModel
Expand Down
1 change: 1 addition & 0 deletions gensim/models/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
To implement a Callback, inherit from this base class and override one or more of its methods.
Create a callback to save the training model after each epoch
.. sourcecode:: pycon
>>> from gensim.test.utils import get_tmpfile
Expand Down
1 change: 1 addition & 0 deletions gensim/models/fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
--------------
Initialize and train a model:
.. sourcecode:: pycon
>>> from gensim.test.utils import common_texts
Expand Down
2 changes: 2 additions & 0 deletions gensim/models/keyedvectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
>>> word_vectors = model.wv
Persist the word vectors to disk with
.. sourcecode:: pycon
>>> from gensim.test.utils import get_tmpfile
Expand All @@ -90,6 +91,7 @@
You can perform various syntactic/semantic NLP word tasks with the trained vectors.
Some of them are already built-in
.. sourcecode:: pycon
>>> import gensim.downloader as api
Expand Down
1 change: 1 addition & 0 deletions gensim/models/ldamulticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
Usage examples
--------------
The constructor estimates Latent Dirichlet Allocation model parameters based on a training corpus
.. sourcecode:: pycon
>>> from gensim.test.utils import common_corpus, common_dictionary
Expand Down
1 change: 0 additions & 1 deletion gensim/models/phrases.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down
5 changes: 1 addition & 4 deletions gensim/models/poincare.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
Examples
--------
Initialize and train a model from a list
.. sourcecode:: pycon
Expand All @@ -32,6 +31,7 @@
>>> model.train(epochs=50)
Initialize and train a model from a file containing one relation per line
.. sourcecode:: pycon
>>> from gensim.models.poincare import PoincareModel, PoincareRelations
Expand Down Expand Up @@ -851,7 +851,6 @@ def word_vec(self, word):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down Expand Up @@ -1308,7 +1307,6 @@ def norm(self, node_or_vector):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down Expand Up @@ -1351,7 +1349,6 @@ def difference_in_hierarchy(self, node_or_vector_1, node_or_vector_2):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down
2 changes: 0 additions & 2 deletions gensim/models/rpmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Examples
--------
.. sourcecode:: pycon
>>> from gensim.models import RpModel
Expand Down Expand Up @@ -119,7 +118,6 @@ def __getitem__(self, bow):
Examples
----------
.. sourcecode:: pycon
>>> from gensim.models import RpModel
Expand Down
6 changes: 5 additions & 1 deletion gensim/models/translation_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
>>> model_it = KeyedVectors.load_word2vec_format(datapath("IT.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt"))
Define word pairs (that will be used for construction of translation matrix
.. sourcecode:: pycon
>>> word_pairs = [
Expand All @@ -34,18 +35,21 @@
... ]
Fit :class:`~gensim.models.translation_matrix.TranslationMatrix`
.. sourcecode:: pycon
>>> trans_model = TranslationMatrix(model_en, model_it, word_pairs=word_pairs)
Apply model (translate words "dog" and "one")
.. sourcecode:: pycon
>>> trans_model.translate(["dog", "one"], topn=3)
OrderedDict([('dog', [u'cane', u'gatto', u'cavallo']), ('one', [u'uno', u'due', u'tre'])])
Save / load model
.. sourcecode:: pycon
>>> with temporary_file("model_file") as fname:
Expand All @@ -57,6 +61,7 @@
==================================================================================
Prepare data and models
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down Expand Up @@ -171,7 +176,6 @@ class TranslationMatrix(utils.SaveLoad):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.models import KeyedVectors
Expand Down
3 changes: 2 additions & 1 deletion gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@
from disk on-the-fly, without loading the entire corpus into RAM.
It also means you can continue training the model later:
.. sourcecode:: pycon
>>> model = Word2Vec.load("word2vec.model")
>>> model.train([["hello", "world"]], total_examples=1, epochs=1)
(0, 2)
The trained word vectors are stored in a :class:`~gensim.models.keyedvectors.KeyedVectors` instance in `model.wv`:
.. sourcecode:: pycon
>>> vector = model.wv['computer'] # numpy vector of a word
Expand Down Expand Up @@ -1409,7 +1411,6 @@ def __init__(self, source, max_sentence_length=MAX_WORDS_IN_BATCH, limit=None):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import datapath
Expand Down
1 change: 0 additions & 1 deletion gensim/models/wrappers/dtmmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import common_corpus, common_dictionary
Expand Down
1 change: 0 additions & 1 deletion gensim/models/wrappers/ldamallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
Examples
--------
.. sourcecode:: pycon
>>> from gensim.test.utils import common_corpus, common_dictionary
Expand Down
1 change: 1 addition & 0 deletions gensim/models/wrappers/ldavowpalwabbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
--------
Train model
.. sourcecode:: pycon
>>> from gensim.test.utils import common_corpus, common_dictionary
Expand Down
3 changes: 1 addition & 2 deletions gensim/parsing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* :func:`~gensim.parsing.preprocessing.remove_stopwords` - remove all stopwords from string
* :func:`~gensim.parsing.preprocessing.preprocess_string` - preprocess string (in default NLP meaning)
Examples:
Examples
---------
.. sourcecode:: pycon
Expand Down Expand Up @@ -390,7 +390,6 @@ def preprocess_documents(docs):
Examples
--------
.. sourcecode:: pycon
>>> from gensim.parsing.preprocessing import preprocess_documents
Expand Down
Loading

0 comments on commit a3dbdcc

Please sign in to comment.