### Install and Run Visdom Server Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/Training_visualizations.ipynb Instructions for installing the Visdom library and starting its server for visualization. ```bash pip install visdom python -m visdom.server ``` -------------------------------- ### DTM Model Initialization and Setup Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/dtm_example.ipynb This snippet demonstrates the initial setup for using the DtmModel, including checking for the DTM environment variable and configuring logging. It ensures the necessary environment is prepared before proceeding with the model. ```python import logging import os from gensim import corpora, utils from gensim.models.wrappers.dtmmodel import DtmModel import numpy as np if not os.environ.get('DTM_PATH', None): raise ValueError("SKIP: You need to set the DTM path") ``` ```python logger = logging.getLogger() logger.setLevel(logging.DEBUG) logging.debug("test") ``` -------------------------------- ### Gensim Topic Coherence Setup Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/topic_coherence_tutorial.ipynb Imports necessary libraries for Gensim topic modeling, coherence calculation, and optional visualization with pyLDAvis. Includes error handling for pyLDAvis installation. ```python from __future__ import print_function import os import logging import json import warnings try: raise ImportError import pyLDAvis.gensim CAN_VISUALIZE = True pyLDAvis.enable_notebook() from IPython.display import display except ImportError: ValueError("SKIP: please install pyLDAvis") CAN_VISUALIZE = False import numpy as np from gensim.models import CoherenceModel, LdaModel, HdpModel from gensim.models.wrappers import LdaVowpalWabbit, LdaMallet from gensim.corpora import Dictionary warnings.filterwarnings('ignore') # To ignore all warnings that arise here to enhance clarity ``` -------------------------------- ### Gensim Doc2Vec Example Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/EN.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt This snippet illustrates how to train and use a Doc2Vec model with Gensim. Doc2Vec learns vector representations for documents. This example covers preparing tagged documents and training a model. Requires Gensim installed (`pip install gensim`). ```python from gensim.models.doc2vec import Doc2Vec, TaggedDocument # Sample documents with tags documents = [ TaggedDocument(words=['this', 'is', 'the', 'first', 'document'], tags=['DOC1']), TaggedDocument(words=['this', 'is', 'the', 'second', 'document'], tags=['DOC2']), TaggedDocument(words=['and', 'this', 'is', 'the', 'third', 'one'], tags=['DOC3']), TaggedDocument(words=['learning', 'from', 'documents', 'is', 'fun'], tags=['DOC4']) ] # Initialize and train Doc2Vec model model = Doc2Vec(vector_size=100, window=5, min_count=1, workers=4) model.build_vocab(documents) model.train(documents, total_examples=model.corpus_count, epochs=10) # Get vector for a document doc_vector = model.dv['DOC1'] print(f"Vector for 'DOC1': {doc_vector[:5]}...") # Infer vector for a new document new_doc_vector = model.infer_vector(['this', 'is', 'a', 'new', 'document']) print(f"Inferred vector for new document: {new_doc_vector[:5]}...") # Find similar documents similar_docs = model.dv.most_similar('DOC1', topn=2) print(f"Documents similar to 'DOC1': {similar_docs}") ``` -------------------------------- ### Gensim Downloader API Example Source: https://github.com/piskvorky/gensim/wiki/How-to-author-documentation Demonstrates how to use Gensim's downloader API to fetch data for documentation examples. This helps ensure documentation remains up-to-date and reduces the burden on users by providing readily available datasets. ```python from gensim.downloader import info, load # Get information about available datasets print(info()) # Load a dataset (e.g., 'glove-wiki-gigaword-50') # model = load('glove-wiki-gigaword-50') # Use the loaded model for examples ``` -------------------------------- ### Example Training Configuration Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/atmodel_prediction_tutorial.ipynb This snippet shows an example of how to configure and start the training process for the topic model. It specifies the directory for training data and calls the preprocessing and corpus creation functions with specific parameters. ```python traindata_dir = "/tmp/C50train" train_docs, train_author2doc = preprocess_docs(traindata_dir) train_corpus_50_20, train_dictionary_50_20 = create_corpus_dictionary(train_docs, 0.5, 20) ``` -------------------------------- ### Initialize Logging Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_downloader_api.ipynb Configures the logging format and level for Gensim operations. This helps in monitoring the download and training process. ```python import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) ``` -------------------------------- ### Get Detailed Model/Corpus Information Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/downloader_api_tutorial.ipynb Fetches and prints detailed information about a specific model or corpus, using 'fake-news' as an example. ```python fake_news_info = api.info('fake-news') print(json.dumps(fake_news_info, indent=4)) ``` -------------------------------- ### Setting Up Python Virtual Environment Source: https://github.com/piskvorky/gensim/blob/develop/CONTRIBUTING.md Instructions for creating and activating a Python virtual environment for Gensim development. ```shell pip install virtualenv; virtualenv gensim_env source gensim_env/bin/activate ``` ```shell pip install -e .[test] pip install -e .[test-win] ``` -------------------------------- ### Gensim Word Embeddings Example Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/EN.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt This snippet demonstrates how to load and use pre-trained word embeddings from Gensim. It shows how to access word vectors and perform similarity calculations. Ensure you have the Gensim library installed (`pip install gensim`) and a pre-trained model file (e.g., GoogleNews-vectors-negative300.bin). ```python from gensim.models import KeyedVectors # Load pre-trained word vectors model_path = 'path/to/your/GoogleNews-vectors-negative300.bin' word_vectors = KeyedVectors.load_word2vec_format(model_path, binary=True) # Get vector for a word vector_king = word_vectors['king'] print(f"Vector for 'king': {vector_king[:5]}...") # Find similar words similar_words = word_vectors.most_similar('queen', topn=5) print(f"Words similar to 'queen': {similar_words}") # Calculate similarity between two words similarity = word_vectors.similarity('man', 'woman') print(f"Similarity between 'man' and 'woman': {similarity}") # Analogy task analogy_result = word_vectors.most_similar(positive=['king', 'woman'], negative=['man'], topn=1) print(f"Analogy 'king' - 'man' + 'woman' = {analogy_result}") ``` -------------------------------- ### Sphinx Gallery Example Download Links Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_doc.rst HTML snippets providing download links for the Python source code and Jupyter notebook of a Sphinx Gallery example. These are typically generated by Sphinx Gallery. ```html .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_doc.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_doc.ipynb ` ``` -------------------------------- ### Basic C++ Example Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/ldavowpalwabbit.txt A simple C++ code snippet demonstrating basic syntax. This snippet is likely a starting point for more complex programs. ```cplusplus #include int main() { std::cout << "Hello, World!\n"; return 0; } ``` -------------------------------- ### List Available Models Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_downloader_api.ipynb Iterates through and prints the names, record counts, and short descriptions of all available pre-trained models in gensim-data. ```python import json info = api.info() for model_name, model_data in sorted(info['models'].items()): print( '%s (%d records): %s' % ( model_name, model_data.get('num_records', -1), model_data['description'][:40] + '...', ) ) ``` -------------------------------- ### Pluralization Examples (Dollar) Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'dollar'. Each entry shows a singular noun and its plural form. ```English dollar dollars donkey donkeys dollar dollars dream dreams dollar dollars eagle eagles dollar dollars elephant elephants dollar dollars eye eyes dollar dollars finger fingers dollar dollars goat goats dollar dollars hand hands dollar dollars horse horses dollar dollars lion lions dollar dollars machine machines dollar dollars mango mangoes dollar dollars man men dollar dollars melon melons dollar dollars monkey monkeys dollar dollars mouse mice dollar dollars onion onions dollar dollars pear pears dollar dollars pig pigs dollar dollars pineapple pineapples dollar dollars rat rats dollar dollars road roads dollar dollars snake snakes dollar dollars woman women dollar dollars banana bananas dollar dollars bird birds dollar dollars bottle bottles dollar dollars building buildings dollar dollars car cars dollar dollars cat cats dollar dollars child children dollar dollars cloud clouds dollar dollars color colors dollar dollars computer computers dollar dollars cow cows dollar dollars dog dogs ``` -------------------------------- ### Build and Upload Documentation Source: https://github.com/piskvorky/gensim/wiki/Maintainer-page Compiles the C extensions in-place and then builds the HTML documentation, uploading it to the project's documentation website. ```bash python setup.py build_ext --inplace make -C docs/src html upload ``` -------------------------------- ### Pluralization Examples (Cow) Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'cow'. Each entry shows a singular noun and its plural form. ```English cow cows dog dogs cow cows dollar dollars cow cows donkey donkeys cow cows dream dreams cow cows eagle eagles cow cows elephant elephants cow cows eye eyes cow cows finger fingers cow cows goat goats cow cows hand hands cow cows horse horses cow cows lion lions cow cows machine machines cow cows mango mangoes cow cows man men cow cows melon melons cow cows monkey monkeys cow cows mouse mice cow cows onion onions cow cows pear pears cow cows pig pigs cow cows pineapple pineapples cow cows rat rats cow cows road roads cow cows snake snakes cow cows woman women cow cows banana bananas cow cows bird birds cow cows bottle bottles cow cows building buildings cow cows car cars cow cows cat cats cow cows child children cow cows cloud clouds cow cows color colors cow cows computer computers ``` -------------------------------- ### Optional Logging Setup Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/nmslibtutorial.ipynb Provides an option to set up basic logging for the application. If LOGS is set to True, it configures the logging format and level. ```python LOGS = False if LOGS: import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) ``` -------------------------------- ### Sphinx-Gallery Example Downloads Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/index.rst Provides links to download all example code in both Python source and Jupyter notebook formats, generated by Sphinx-Gallery. ```APIDOC Download all examples in Python source code: auto_examples_python.zip Download all examples in Jupyter notebooks: auto_examples_jupyter.zip ``` -------------------------------- ### Pluralization Examples (Color) Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'color'. Each entry shows a singular noun and its plural form. ```English color colors monkey monkeys color colors mouse mice color colors onion onions color colors pear pears color colors pig pigs color colors pineapple pineapples color colors rat rats color colors road roads color colors snake snakes color colors woman women color colors banana bananas color colors bird birds color colors bottle bottles color colors building buildings color colors car cars color colors cat cats color colors child children color colors cloud clouds ``` -------------------------------- ### Prepare for Gensim Release Source: https://github.com/piskvorky/gensim/wiki/Maintainer-page Clones the Gensim repository, sets up the development environment, and installs necessary dependencies for release preparation. It also outlines the environment variable and script execution for the release process. ```bash cd /tmp git clone git@github.com:RaRe-Technologies/gensim.git && cd /tmp/gensim git remote add upstream git@github.com:RaRe-Technologies/gensim.git # expected by prepare.sh pip install -e . pip install requests # expected by update_changelog.py export RELEASE=1.2.3 # The version you'll be releasing bash release/prepare.sh $RELEASE ``` -------------------------------- ### Pluralization Examples (Computer) Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'computer'. Each entry shows a singular noun and its plural form. ```English computer computers cow cows computer computers dog dogs computer computers dollar dollars computer computers donkey donkeys computer computers dream dreams computer computers eagle eagles computer computers elephant elephants computer computers eye eyes computer computers finger fingers computer computers goat goats computer computers hand hands computer computers horse horses computer computers lion lions computer computers machine machines computer computers mango mangoes computer computers man men computer computers melon melons computer computers monkey monkeys computer computers mouse mice computer computers onion onions computer computers pear pears computer computers pig pigs computer computers pineapple pineapples computer computers rat rats computer computers road roads computer computers snake snakes computer computers woman women computer computers banana bananas computer computers bird birds computer computers bottle bottles computer computers building buildings computer computers car cars computer computers cat cats computer computers child children computer computers cloud clouds computer computers color colors ``` -------------------------------- ### Run Gensim Tests Locally Source: https://github.com/piskvorky/gensim/wiki/Developer-page Steps to install Gensim from the current directory, install additional testing and documentation dependencies, and execute the unit tests using pytest. ```bash pip install -e . # compile and install Gensim from the current directory pip install -e .[docs,test] # additional dependencies in case you also need to rebuild the HTML docs pytest gensim # run tests ``` -------------------------------- ### Pluralization Examples (Donkey) Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'donkey'. Each entry shows a singular noun and its plural form. ```English donkey donkeys dream dreams donkey donkeys eagle eagles donkey donkeys elephant elephants donkey donkeys eye eyes donkey donkeys finger fingers donkey donkeys goat goats donkey donkeys hand hands donkey donkeys horse horses donkey donkeys lion lions donkey donkeys machine machines donkey donkeys mango mangoes donkey donkeys man men donkey donkeys melon melons donkey donkeys monkey monkeys donkey donkeys mouse mice donkey donkeys onion onions donkey donkeys pear pears donkey donkeys pig pigs donkey donkeys pineapple pineapples donkey donkeys rat rats donkey donkeys road roads donkey donkeys snake snakes donkey donkeys woman women donkey donkeys banana bananas donkey donkeys bird birds donkey donkeys bottle bottles donkey donkeys building buildings donkey donkeys car cars ``` -------------------------------- ### Download Pre-trained Models and Corpora Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/index.rst Demonstrates simple and quick access to common corpora and pre-trained models available in gensim. This guide is useful for users who need to quickly load and use existing resources for their NLP tasks. ```python from gensim.scripts.download import download download('word2vec-google-news-300') ``` -------------------------------- ### Pluralization Examples (Dog) Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'dog'. Each entry shows a singular noun and its plural form. ```English dog dogs dollar dollars dog dogs donkey donkeys dog dogs dream dreams dog dogs eagle eagles dog dogs elephant elephants dog dogs eye eyes dog dogs finger fingers dog dogs goat goats dog dogs hand hands dog dogs horse horses dog dogs lion lions dog dogs machine machines dog dogs mango mangoes dog dogs man men dog dogs melon melons dog dogs monkey monkeys dog dogs mouse mice dog dogs onion onions dog dogs pear pears dog dogs pig pigs dog dogs pineapple pineapples dog dogs rat rats dog dogs road roads dog dogs snake snakes dog dogs woman women dog dogs banana bananas dog dogs bird birds dog dogs bottle bottles dog dogs building buildings dog dogs car cars dog dogs cat cats dog dogs child children dog dogs cloud clouds dog dogs color colors dog dogs computer computers dog dogs cow cows ``` -------------------------------- ### Sphinx Gallery File Explanations Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_doc.ipynb Explains the purpose of various files generated by Sphinx Gallery for documentation examples, including the Python script, MD5 hash, RST, IPYNB, and execution time tracking. ```rst .. Note:: You may be wondering what all those other files are. Sphinx Gallery puts a copy of your Python script in ``auto_examples/tutorials``. The .md5 contains MD5 hash of the script to enable easy detection of modifications. Gallery also generates .rst (RST for Sphinx) and .ipynb (Jupyter notebook) files from the script. Finally, ``sg_execution_times.rst`` contains the time taken to run each example. ``` -------------------------------- ### Pluralization Examples (Dog) Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/gallery/tutorials/datasets/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'dog'. Each entry shows a singular noun and its plural form. ```English dog dogs dollar dollars dog dogs donkey donkeys dog dogs dream dreams dog dogs eagle eagles dog dogs elephant elephants dog dogs eye eyes dog dogs finger fingers dog dogs goat goats dog dogs hand hands dog dogs horse horses dog dogs lion lions dog dogs machine machines dog dogs mango mangoes dog dogs man men dog dogs melon melons dog dogs monkey monkeys dog dogs mouse mice dog dogs onion onions dog dogs pear pears dog dogs pig pigs dog dogs pineapple pineapples dog dogs rat rats dog dogs road roads dog dogs snake snakes dog dogs woman women dog dogs banana bananas dog dogs bird birds dog dogs bottle bottles dog dogs building buildings dog dogs car cars dog dogs cat cats dog dogs child children dog dogs cloud clouds dog dogs color colors dog dogs computer computers dog dogs cow cows ``` -------------------------------- ### Testing Word2Vec Matrix Synopsis Model Details Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_downloader_api.rst Provides details for the testing model '__testing_word2vec-matrix-synopsis'. Includes description, parameters, preprocessing steps, related links, checksum, file name, and parts. ```json { "__testing_word2vec-matrix-synopsis": { "description": "[THIS IS ONLY FOR TESTING] Word vecrors of the movie matrix.", "parameters": { "dimensions": 50 }, "preprocessing": "Converted to w2v using a preprocessed corpus. Converted to w2v format with `python3.5 -m gensim.models.word2vec -train -output `.", "read_more": [], "checksum": "534dcb8b56a360977a269b7bfc62d124", "file_name": "__testing_word2vec-matrix-synopsis.gz", "parts": 1 } } ``` -------------------------------- ### Pluralization Examples (Computer) Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/gallery/tutorials/datasets/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'computer'. Each entry shows a singular noun and its plural form. ```English computer computers cow cows computer computers dog dogs computer computers dollar dollars computer computers donkey donkeys computer computers dream dreams computer computers eagle eagles computer computers elephant elephants computer computers eye eyes computer computers finger fingers computer computers goat goats computer computers hand hands computer computers horse horses computer computers lion lions computer computers machine machines computer computers mango mangoes computer computers man men computer computers melon melons computer computers monkey monkeys computer computers mouse mice computer computers onion onions computer computers pear pears computer computers pig pigs computer computers pineapple pineapples computer computers rat rats computer computers road roads computer computers snake snakes computer computers woman women computer computers banana bananas computer computers bird birds computer computers bottle bottles computer computers building buildings computer computers car cars computer computers cat cats computer computers child children computer computers cloud clouds computer computers color colors ``` -------------------------------- ### Pluralization Examples (Dollar) Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/gallery/tutorials/datasets/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'dollar'. Each entry shows a singular noun and its plural form. ```English dollar dollars donkey donkeys dollar dollars dream dreams dollar dollars eagle eagles dollar dollars elephant elephants dollar dollars eye eyes dollar dollars finger fingers dollar dollars goat goats dollar dollars hand hands dollar dollars horse horses dollar dollars lion lions dollar dollars machine machines dollar dollars mango mangoes dollar dollars man men dollar dollars melon melons dollar dollars monkey monkeys dollar dollars mouse mice dollar dollars onion onions dollar dollars pear pears dollar dollars pig pigs dollar dollars pineapple pineapples dollar dollars rat rats dollar dollars road roads dollar dollars snake snakes dollar dollars woman women dollar dollars banana bananas dollar dollars bird birds dollar dollars bottle bottles dollar dollars building buildings dollar dollars car cars dollar dollars cat cats dollar dollars child children dollar dollars cloud clouds dollar dollars color colors dollar dollars computer computers dollar dollars cow cows dollar dollars dog dogs ``` -------------------------------- ### Download Example Scripts Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_doc2vec_imdb.rst Provides links to download the Python source code and Jupyter notebook for the 'run_doc2vec_imdb.py' example. ```html .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_doc2vec_imdb.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_doc2vec_imdb.ipynb ` ``` -------------------------------- ### Import Gensim Downloader API Source: https://github.com/piskvorky/gensim/blob/develop/docs/notebooks/downloader_api_tutorial.ipynb Imports the necessary gensim.downloader module and configures basic logging. ```python import logging import gensim.downloader as api logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) ``` -------------------------------- ### Pluralization Examples (Cow) Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/gallery/tutorials/datasets/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'cow'. Each entry shows a singular noun and its plural form. ```English cow cows dog dogs cow cows dollar dollars cow cows donkey donkeys cow cows dream dreams cow cows eagle eagles cow cows elephant elephants cow cows eye eyes cow cows finger fingers cow cows goat goats cow cows hand hands cow cows horse horses cow cows lion lions cow cows machine machines cow cows mango mangoes cow cows man men cow cows melon melons cow cows monkey monkeys cow cows mouse mice cow cows onion onions cow cows pear pears cow cows pig pigs cow cows pineapple pineapples cow cows rat rats cow cows road roads cow cows snake snakes cow cows woman women cow cows banana bananas cow cows bird birds cow cows bottle bottles cow cows building buildings cow cows car cars cow cows cat cats cow cows child children cow cows cloud clouds cow cows color colors cow cows computer computers ``` -------------------------------- ### Pluralization Examples (Donkey) Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/gallery/tutorials/datasets/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'donkey'. Each entry shows a singular noun and its plural form. ```English donkey donkeys dream dreams donkey donkeys eagle eagles donkey donkeys elephant elephants donkey donkeys eye eyes donkey donkeys finger fingers donkey donkeys goat goats donkey donkeys hand hands donkey donkeys horse horses donkey donkeys lion lions donkey donkeys machine machines donkey donkeys mango mangoes donkey donkeys man men donkey donkeys melon melons donkey donkeys monkey monkeys donkey donkeys mouse mice donkey donkeys onion onions donkey donkeys pear pears donkey donkeys pig pigs donkey donkeys pineapple pineapples donkey donkeys rat rats donkey donkeys road roads donkey donkeys snake snakes donkey donkeys woman women donkey donkeys banana bananas donkey donkeys bird birds donkey donkeys bottle bottles donkey donkeys building buildings donkey donkeys car cars ``` -------------------------------- ### Gensim Initialization Example Source: https://github.com/piskvorky/gensim/blob/develop/gensim/test/test_data/test_glove.txt This snippet demonstrates a basic initialization pattern, likely for a Gensim model or component. It shows how to import and instantiate a class, which is a fundamental step in using the library. ```python from gensim.models import Word2Vec # Example usage: model = Word2Vec(sentences=data, vector_size=100, window=5, min_count=5, workers=4) model.save("word2vec.model") ``` -------------------------------- ### Running Gensim Documentation Scripts Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/auto_examples/howtos/run_doc.ipynb Shows the command to execute a Gensim documentation script directly from the command line for testing. ```python python myscript.py ``` -------------------------------- ### Pluralization Examples (Color) Source: https://github.com/piskvorky/gensim/blob/develop/docs/src/gallery/tutorials/datasets/questions-words.txt Demonstrates the pluralization of singular nouns starting with 'color'. Each entry shows a singular noun and its plural form. ```English color colors monkey monkeys color colors mouse mice color colors onion onions color colors pear pears color colors pig pigs color colors pineapple pineapples color colors rat rats color colors road roads color colors snake snakes color colors woman women color colors banana bananas color colors bird birds color colors bottle bottles color colors building buildings color colors car cars color colors cat cats color colors child children color colors cloud clouds ```