<jupyter_start><jupyter_text>Understanding the Pre-trained Word2Vec  Importing the libraries and modules<jupyter_code>import gensim
from gensim.models import KeyedVectors<jupyter_output><empty_output><jupyter_text>Load pre-trained vectors<jupyter_code>model = KeyedVectors.load_word2vec_format('/Users/amankedia/Desktop/Sunday/nlp-book/Chapter 5/Code/GoogleNews-vectors-negative300.bin', binary=True)<jupyter_output><empty_output><jupyter_text>Vocabulary size<jupyter_code>len(model.wv.vocab)<jupyter_output>/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).
  """Entry point for launching an IPython kernel.<jupyter_text>Word vector size<jupyter_code>model.vector_size<jupyter_output><empty_output><jupyter_text>Vocabulary<jupyter_code>model.wv.vocab<jupyter_output>/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).
  """Entry point for launching an IPython kernel.<jupyter_text>Word vector for India<jupyter_code>model.wv['India']<jupyter_output>/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).
  """Entry point for launching an IPython kernel.<jupyter_text>Finding the word most similar to Delhi<jupyter_code>model.most_similar('Delhi')<jupyter_output><empty_output><jupyter_text>Validating the Relationship : vector(Man) – vector (King) + vector (Queen) = vector (Woman)<jupyter_code>result = model.most_similar(positive=['man', 'queen'], negative=['king'], topn=1)
print(result)
result = model.most_similar(positive=['man', 'queen'], negative=['king'], topn=2)
print(result)<jupyter_output>[('woman', 0.7609435319900513), ('girl', 0.6139994263648987)]<jupyter_text>Validating the Relationship : vector(France) + vector(Rome) - vector(Italy) = vector (Paris)<jupyter_code>result = model.most_similar(positive=['France', 'Rome'], negative=['Italy'], topn=1)
print(result)<jupyter_output>[('Paris', 0.7190686464309692)]
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.03684210526315789, 'mean_word_length': 8.78969957081545, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '414001', 'license': 'MIT', 'n_tokens_mistral': 878, 'n_tokens_neox': 799, 'n_words': 131, 'path': 'Chapter05/Understanding the Pre-trained Word2Vec.ipynb', 'repo_name': 'arifmudi/Hands-On-Python-Natural-Language-Processing', 'size': '2280'}