Skip to content

Commit

Permalink
Point WordEmbeddingSimilarityIndex documentation to gensim.similariti…
Browse files Browse the repository at this point in the history
…es (#3003)

* Remove deprecated init_sims from run_wmd.py

* Add missing cross-links between soft cosine measure classes

* Add normalized parameter to SoftCosineSimilarity

* Point WordEmbeddingSimilarityIndex documentation to gensim.similarities

* Add run_scm.py

* Redirect documentation of SCM and WMD to Gallery

* Run run_scm.py

* Add sphx_glr_run_scm_thumb.png

* Add sphx_glr_run_scm_001.png

* Use anonymous references in the documentation
  • Loading branch information
Witiko authored Mar 1, 2021
1 parent 5637303 commit ddeeb12
Show file tree
Hide file tree
Showing 26 changed files with 970 additions and 308 deletions.
2 changes: 1 addition & 1 deletion docs/notebooks/soft_cosine_benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"from gensim.similarities import SparseTermSimilarityMatrix\n",
"from gensim.similarities import UniformTermSimilarityIndex\n",
"from gensim.similarities import LevenshteinSimilarityIndex\n",
"from gensim.models import WordEmbeddingSimilarityIndex\n",
"from gensim.similarities import WordEmbeddingSimilarityIndex\n",
"from gensim.utils import simple_preprocess\n",
"\n",
"RANDOM_SEED = 12345\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/soft_cosine_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
"%%time\n",
"import gensim.downloader as api\n",
"\n",
"from gensim.models import WordEmbeddingSimilarityIndex\n",
"from gensim.similarities import SparseTermSimilarityMatrix\n",
"from gensim.similarities import WordEmbeddingSimilarityIndex\n",
"\n",
"w2v_model = api.load(\"glove-wiki-gigaword-50\")\n",
"similarity_index = WordEmbeddingSimilarityIndex(w2v_model)\n",
Expand Down Expand Up @@ -296,7 +296,7 @@
"from gensim.corpora import Dictionary\n",
"from gensim.models import TfidfModel\n",
"from gensim.models import Word2Vec\n",
"from gensim.models import WordEmbeddingSimilarityIndex\n",
"from gensim.similarities import WordEmbeddingSimilarityIndex\n",
"from gensim.similarities import SparseTermSimilarityMatrix\n",
"\n",
"dictionary = Dictionary(corpus)\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/src/auto_examples/howtos/run_doc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\nHow to Author Gensim Documentation\n==================================\n\nHow to author documentation for Gensim.\n\n"
"\nHow to Author Gensim Documentation\n==================================\n\nHow to author documentation for Gensim.\n"
]
},
{
Expand Down Expand Up @@ -54,7 +54,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Authoring Workflow\n------------------\n\nThere are several ways to author documentation.\nThe simplest and most straightforward is to author your ``script.py`` from scratch.\nYou'll have the following cycle:\n\n1. Make changes\n2. Run ``python script.py``\n3. Check standard output, standard error and return code\n4. If everything works well, stop.\n5. Otherwise, go back to step 1).\n\nIf the above is not your cup of tea, you can also author your documentation as a Jupyter notebook.\nThis is a more flexible approach that enables you to tweak parts of the documentation and re-run them as necessary.\n\nOnce you're happy with the notebook, convert it to a script.py.\nThere's a helpful `script <https://github.com/mpenkov/gensim/blob/numfocus/docs/src/tools/to_python.py>`__ that will do it for you.\nTo use it::\n\n python to_python.py < notebook.ipynb > script.py\n\nYou may have to touch up the resulting ``script.py``.\nMore specifically:\n\n- Update the title\n- Update the description\n- Fix any issues that the markdown-to-RST converter could not deal with\n\nOnce your script.py works, put it in a suitable subdirectory.\nPlease don't include your original Jupyter notebook in the repository - we won't be using it.\n\n"
"Authoring Workflow\n------------------\n\nThere are several ways to author documentation.\nThe simplest and most straightforward is to author your ``script.py`` from scratch.\nYou'll have the following cycle:\n\n1. Make changes\n2. Run ``python script.py``\n3. Check standard output, standard error and return code\n4. If everything works well, stop.\n5. Otherwise, go back to step 1).\n\nIf the above is not your cup of tea, you can also author your documentation as a Jupyter notebook.\nThis is a more flexible approach that enables you to tweak parts of the documentation and re-run them as necessary.\n\nOnce you're happy with the notebook, convert it to a script.py.\nThere's a helpful `script <https://github.com/RaRe-Technologies/gensim/blob/develop/docs/src/tools/to_python.py>`__ that will do it for you.\nTo use it::\n\n python to_python.py < notebook.ipynb > script.py\n\nYou may have to touch up the resulting ``script.py``.\nMore specifically:\n\n- Update the title\n- Update the description\n- Fix any issues that the markdown-to-RST converter could not deal with\n\nOnce your script.py works, put it in a suitable subdirectory.\nPlease don't include your original Jupyter notebook in the repository - we won't be using it.\n\n"
]
},
{
Expand All @@ -81,7 +81,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/auto_examples/howtos/run_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
# This is a more flexible approach that enables you to tweak parts of the documentation and re-run them as necessary.
#
# Once you're happy with the notebook, convert it to a script.py.
# There's a helpful `script <https://github.com/mpenkov/gensim/blob/numfocus/docs/src/tools/to_python.py>`__ that will do it for you.
# There's a helpful `script <https://github.com/RaRe-Technologies/gensim/blob/develop/docs/src/tools/to_python.py>`__ that will do it for you.
# To use it::
#
# python to_python.py < notebook.ipynb > script.py
Expand Down
2 changes: 1 addition & 1 deletion docs/src/auto_examples/howtos/run_doc.py.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b3db0b66859316de13e1a36fa6181657
512a76ce743dd12482d21784a76b60fe
31 changes: 10 additions & 21 deletions docs/src/auto_examples/howtos/run_doc.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
.. only:: html

.. note::
:class: sphx-glr-download-link-note
.. note::
:class: sphx-glr-download-link-note

Click :ref:`here <sphx_glr_download_auto_examples_howtos_run_doc.py>` to download the full example code
.. rst-class:: sphx-glr-example-title
Click :ref:`here <sphx_glr_download_auto_examples_howtos_run_doc.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_howtos_run_doc.py:
.. _sphx_glr_auto_examples_howtos_run_doc.py:


How to Author Gensim Documentation
Expand Down Expand Up @@ -80,15 +78,6 @@ At the very top, you need a docstring describing what your script does.
.. rst-class:: sphx-glr-script-out

Out:

.. code-block:: none
'\nTitle\n=====\n\nBrief description.\n'
The title is what will show up in the gallery.
Expand Down Expand Up @@ -135,7 +124,7 @@ If the above is not your cup of tea, you can also author your documentation as a
This is a more flexible approach that enables you to tweak parts of the documentation and re-run them as necessary.

Once you're happy with the notebook, convert it to a script.py.
There's a helpful `script <https://github.com/mpenkov/gensim/blob/numfocus/docs/src/tools/to_python.py>`__ that will do it for you.
There's a helpful `script <https://github.com/RaRe-Technologies/gensim/blob/develop/docs/src/tools/to_python.py>`__ that will do it for you.
To use it::

python to_python.py < notebook.ipynb > script.py
Expand Down Expand Up @@ -207,9 +196,9 @@ At that stage, give yourself a pat on the back: you're done!

.. rst-class:: sphx-glr-timing

**Total running time of the script:** ( 0 minutes 0.112 seconds)
**Total running time of the script:** ( 0 minutes 1.226 seconds)

**Estimated memory usage:** 6 MB
**Estimated memory usage:** 9 MB


.. _sphx_glr_download_auto_examples_howtos_run_doc.py:
Expand All @@ -222,13 +211,13 @@ At that stage, give yourself a pat on the back: you're done!
.. container:: sphx-glr-download sphx-glr-download-python
.. container:: sphx-glr-download
:download:`Download Python source code: run_doc.py <run_doc.py>`
.. container:: sphx-glr-download sphx-glr-download-jupyter
.. container:: sphx-glr-download
:download:`Download Jupyter notebook: run_doc.ipynb <run_doc.ipynb>`
Expand Down
15 changes: 5 additions & 10 deletions docs/src/auto_examples/howtos/sg_execution_times.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@

Computation times
=================
**52:12.903** total execution time for **auto_examples_howtos** files:
**00:01.226** total execution time for **auto_examples_howtos** files:

+----------------------------------------------------------------------------------------+-----------+-----------+
| :ref:`sphx_glr_auto_examples_howtos_run_doc2vec_imdb.py` (``run_doc2vec_imdb.py``) | 52:12.903 | 3494.0 MB |
+----------------------------------------------------------------------------------------+-----------+-----------+
| :ref:`sphx_glr_auto_examples_howtos_run_compare_lda.py` (``run_compare_lda.py``) | 00:00.000 | 0.0 MB |
+----------------------------------------------------------------------------------------+-----------+-----------+
| :ref:`sphx_glr_auto_examples_howtos_run_doc.py` (``run_doc.py``) | 00:00.000 | 0.0 MB |
+----------------------------------------------------------------------------------------+-----------+-----------+
| :ref:`sphx_glr_auto_examples_howtos_run_downloader_api.py` (``run_downloader_api.py``) | 00:00.000 | 0.0 MB |
+----------------------------------------------------------------------------------------+-----------+-----------+
- **00:01.226**: :ref:`sphx_glr_auto_examples_howtos_run_doc.py` (``run_doc.py``)
- **00:00.000**: :ref:`sphx_glr_auto_examples_howtos_run_compare_lda.py` (``run_compare_lda.py``)
- **00:00.000**: :ref:`sphx_glr_auto_examples_howtos_run_doc2vec_imdb.py` (``run_doc2vec_imdb.py``)
- **00:00.000**: :ref:`sphx_glr_auto_examples_howtos_run_downloader_api.py` (``run_downloader_api.py``)
Loading

0 comments on commit ddeeb12

Please sign in to comment.