Skip to content

Commit

Permalink
fixed fstring
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJDen committed Sep 16, 2023
1 parent a5d1aff commit d1babe2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion word2vec_supervised_guesser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"import word2vec_loader as wv_loader\n",
"\n",
"limit = 200_000\n",
"print(\"Loading {limit} keys\")\n",
"print(f\"Loading {limit} keys\")\n",
"google_news_wv = wv_loader.load_word2vec_keyedvectors(wv_loader.GOOGLE_NEWS_PATH_NAME, limit)"
]
},
Expand Down
24 changes: 20 additions & 4 deletions word2vec_unsupervised_guessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,31 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Loading {limit} keys\n"
"Loading 200000 keys\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/jadenrodriguez/Projects/decrypto-ai-research/word2vec_unsupervised_guessing.ipynb Cell 2\u001b[0m line \u001b[0;36m5\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/jadenrodriguez/Projects/decrypto-ai-research/word2vec_unsupervised_guessing.ipynb#W1sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m limit \u001b[39m=\u001b[39m \u001b[39m200_000\u001b[39m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/jadenrodriguez/Projects/decrypto-ai-research/word2vec_unsupervised_guessing.ipynb#W1sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mLoading \u001b[39m\u001b[39m{\u001b[39;00mlimit\u001b[39m}\u001b[39;00m\u001b[39m keys\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/jadenrodriguez/Projects/decrypto-ai-research/word2vec_unsupervised_guessing.ipynb#W1sZmlsZQ%3D%3D?line=4'>5</a>\u001b[0m google_news_wv \u001b[39m=\u001b[39m wv_loader\u001b[39m.\u001b[39;49mload_word2vec_keyedvectors(wv_loader\u001b[39m.\u001b[39;49mGOOGLE_NEWS_PATH_NAME, limit)\n",
"File \u001b[0;32m~/Projects/decrypto-ai-research/word2vec_loader.py:16\u001b[0m, in \u001b[0;36mload_word2vec_keyedvectors\u001b[0;34m(path_str, limit)\u001b[0m\n\u001b[1;32m 13\u001b[0m google_news_wv\u001b[39m.\u001b[39msave_word2vec_format(path_str)\n\u001b[1;32m 14\u001b[0m \u001b[39mdel\u001b[39;00m google_news_wv\n\u001b[0;32m---> 16\u001b[0m \u001b[39mreturn\u001b[39;00m gensim\u001b[39m.\u001b[39;49mmodels\u001b[39m.\u001b[39;49mKeyedVectors\u001b[39m.\u001b[39;49mload_word2vec_format(path_str, limit\u001b[39m=\u001b[39;49mlimit)\n",
"File \u001b[0;32m~/Projects/decrypto-ai-research/.venv/lib/python3.11/site-packages/gensim/models/keyedvectors.py:1719\u001b[0m, in \u001b[0;36mKeyedVectors.load_word2vec_format\u001b[0;34m(cls, fname, fvocab, binary, encoding, unicode_errors, limit, datatype, no_header)\u001b[0m\n\u001b[1;32m 1672\u001b[0m \u001b[39m@classmethod\u001b[39m\n\u001b[1;32m 1673\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mload_word2vec_format\u001b[39m(\n\u001b[1;32m 1674\u001b[0m \u001b[39mcls\u001b[39m, fname, fvocab\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, binary\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m, encoding\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mutf8\u001b[39m\u001b[39m'\u001b[39m, unicode_errors\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mstrict\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[1;32m 1675\u001b[0m limit\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, datatype\u001b[39m=\u001b[39mREAL, no_header\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m,\n\u001b[1;32m 1676\u001b[0m ):\n\u001b[1;32m 1677\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Load KeyedVectors from a file produced by the original C word2vec-tool format.\u001b[39;00m\n\u001b[1;32m 1678\u001b[0m \n\u001b[1;32m 1679\u001b[0m \u001b[39m Warnings\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1717\u001b[0m \n\u001b[1;32m 1718\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 1719\u001b[0m \u001b[39mreturn\u001b[39;00m _load_word2vec_format(\n\u001b[1;32m 1720\u001b[0m \u001b[39mcls\u001b[39;49m, fname, fvocab\u001b[39m=\u001b[39;49mfvocab, binary\u001b[39m=\u001b[39;49mbinary, encoding\u001b[39m=\u001b[39;49mencoding, unicode_errors\u001b[39m=\u001b[39;49municode_errors,\n\u001b[1;32m 1721\u001b[0m limit\u001b[39m=\u001b[39;49mlimit, datatype\u001b[39m=\u001b[39;49mdatatype, no_header\u001b[39m=\u001b[39;49mno_header,\n\u001b[1;32m 1722\u001b[0m )\n",
"File \u001b[0;32m~/Projects/decrypto-ai-research/.venv/lib/python3.11/site-packages/gensim/models/keyedvectors.py:2069\u001b[0m, in \u001b[0;36m_load_word2vec_format\u001b[0;34m(cls, fname, fvocab, binary, encoding, unicode_errors, limit, datatype, no_header, binary_chunk_size)\u001b[0m\n\u001b[1;32m 2065\u001b[0m _word2vec_read_binary(\n\u001b[1;32m 2066\u001b[0m fin, kv, counts, vocab_size, vector_size, datatype, unicode_errors, binary_chunk_size, encoding\n\u001b[1;32m 2067\u001b[0m )\n\u001b[1;32m 2068\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m-> 2069\u001b[0m _word2vec_read_text(fin, kv, counts, vocab_size, vector_size, datatype, unicode_errors, encoding)\n\u001b[1;32m 2070\u001b[0m \u001b[39mif\u001b[39;00m kv\u001b[39m.\u001b[39mvectors\u001b[39m.\u001b[39mshape[\u001b[39m0\u001b[39m] \u001b[39m!=\u001b[39m \u001b[39mlen\u001b[39m(kv):\n\u001b[1;32m 2071\u001b[0m logger\u001b[39m.\u001b[39minfo(\n\u001b[1;32m 2072\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mduplicate words detected, shrinking matrix size from \u001b[39m\u001b[39m%i\u001b[39;00m\u001b[39m to \u001b[39m\u001b[39m%i\u001b[39;00m\u001b[39m\"\u001b[39m,\n\u001b[1;32m 2073\u001b[0m kv\u001b[39m.\u001b[39mvectors\u001b[39m.\u001b[39mshape[\u001b[39m0\u001b[39m], \u001b[39mlen\u001b[39m(kv),\n\u001b[1;32m 2074\u001b[0m )\n",
"File \u001b[0;32m~/Projects/decrypto-ai-research/.venv/lib/python3.11/site-packages/gensim/models/keyedvectors.py:1974\u001b[0m, in \u001b[0;36m_word2vec_read_text\u001b[0;34m(fin, kv, counts, vocab_size, vector_size, datatype, unicode_errors, encoding)\u001b[0m\n\u001b[1;32m 1972\u001b[0m \u001b[39mif\u001b[39;00m line \u001b[39m==\u001b[39m \u001b[39mb\u001b[39m\u001b[39m'\u001b[39m\u001b[39m'\u001b[39m:\n\u001b[1;32m 1973\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mEOFError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39munexpected end of input; is count incorrect or file otherwise damaged?\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m-> 1974\u001b[0m word, weights \u001b[39m=\u001b[39m _word2vec_line_to_vector(line, datatype, unicode_errors, encoding)\n\u001b[1;32m 1975\u001b[0m _add_word_to_kv(kv, counts, word, weights, vocab_size)\n",
"File \u001b[0;32m~/Projects/decrypto-ai-research/.venv/lib/python3.11/site-packages/gensim/models/keyedvectors.py:1979\u001b[0m, in \u001b[0;36m_word2vec_line_to_vector\u001b[0;34m(line, datatype, unicode_errors, encoding)\u001b[0m\n\u001b[1;32m 1978\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_word2vec_line_to_vector\u001b[39m(line, datatype, unicode_errors, encoding):\n\u001b[0;32m-> 1979\u001b[0m parts \u001b[39m=\u001b[39m utils\u001b[39m.\u001b[39mto_unicode(line\u001b[39m.\u001b[39mrstrip(), encoding\u001b[39m=\u001b[39mencoding, errors\u001b[39m=\u001b[39municode_errors)\u001b[39m.\u001b[39msplit(\u001b[39m\"\u001b[39m\u001b[39m \u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 1980\u001b[0m word, weights \u001b[39m=\u001b[39m parts[\u001b[39m0\u001b[39m], [datatype(x) \u001b[39mfor\u001b[39;00m x \u001b[39min\u001b[39;00m parts[\u001b[39m1\u001b[39m:]]\n\u001b[1;32m 1981\u001b[0m \u001b[39mreturn\u001b[39;00m word, weights\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"import word2vec_loader as wv_loader\n",
"\n",
"limit = 200_000\n",
"print(\"Loading {limit} keys\")\n",
"print(f\"Loading {limit} keys\")\n",
"google_news_wv = wv_loader.load_word2vec_keyedvectors(wv_loader.GOOGLE_NEWS_PATH_NAME, limit)"
]
},
Expand All @@ -52,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "477a36be",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -81,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "f91f30e9",
"metadata": {},
"outputs": [
Expand Down

0 comments on commit d1babe2

Please sign in to comment.