<jupyter_start><jupyter_text>Use a pre-trained IMF w2v model<jupyter_code>import os 
python_root = '..'
import sys
sys.path.insert(0, python_root)
import data_util
import gensim
from gensim.models.word2vec import Word2Vec
### specify download path and extract path 
download_path = "imf_w2v.zip"
download_link = "https://www.dropbox.com/sh/6um97x52kweebfx/AACSxB0E9weItCbyQwUqvuWRa?dl=1"
extract_path = "./data"  # place data in Python project root folder
## detailed of the download_data function is in data_util module in python_root ## deta 
## if you do not yet have the data, run this code, it will set up a data folder under ./Python folder 
data_util.download_data(download_path,download_link,extract_path)
## load models ## load 
data_path = os.path.join('data','imf_160.w2v')
imf_w2v = Word2Vec.load(data_path)
model = imf_w2v.wv
vocabs = model.vocab.keys()
model.most_similar('spillovers',topn=10)
model.most_similar('npl',topn=10)
#3 this shoudl be relatively low
model.similarity('npls', 'spillovers')
## this should be very high
model.similarity('npls', 'nonperforming_loans')
model.get_vector('npl')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11198600174978128, 'fraction_numerical': 0.021872265966754154, 'mean_word_length': 6.286624203821656, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '598312', 'license': 'MIT', 'n_tokens_mistral': 436, 'n_tokens_neox': 421, 'n_words': 102, 'path': 'Python/4_word2vec/2_w2v_use_pre-trained.ipynb', 'repo_name': 'johnsonice/IMF_Textmining', 'size': '1143'}