"E:\\apppath\\lib\\site-packages\\ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).\n",
" \"\"\"Entry point for launching an IPython kernel.\n"
]
},
{
"data": {
"text/plain": [
"<gensim.models.keyedvectors.Word2VecKeyedVectors at 0x2586fc66e08>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.wv"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"E:\\apppath\\lib\\site-packages\\ipykernel_launcher.py:10: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).\n",
" # Remove the CWD from sys.path while we load stuff.\n",
"E:\\apppath\\lib\\site-packages\\ipykernel_launcher.py:14: RuntimeWarning: invalid value encountered in true_divide\n",
" top_idxs = [x[1] for x in p_rank] # top_idxs存放相似度最高的(存在qlist里的)问题的下表 \n",
" \n",
" return [alist[x] for x in top_idxs ] # 返回相似度最高的问题对应的答案,作为TOP5答案 "
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Chengdu Shuangliu International Airport', 'Chengdu Shuangliu International Airport', 'aerodrome with facilities for flights to take off and land', 'Nanjing Dajiaochang Airport', 'newspapers']\n",
"['Plymouth City Airport', 'aerodrome with facilities for flights to take off and land', 'Nanjing Dajiaochang Airport', 'Wye College campus', 'six months']\n",
"['Myanmar', 'foreign aid', '10 days', 'the British government', 'access is blocked to local and foreign websites including avesta.tj, Tjknews.com, ferghana.ru, centrasia.ru']\n",
" top_idxs = [x[1] for x in p_rank] # top_idxs存放相似度最高的(存在qlist里的)问题的下表\n",
"\n",
" return [alist[x] for x in top_idxs] # 返回相似度最高的问题对应的答案,作为TOP5答案"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"airport\n",
"wa\n",
"shut\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"E:\\apppath\\lib\\site-packages\\ipykernel_launcher.py:10: DeprecationWarning: Call to deprecated `wv` (Attribute will be removed in 4.0.0, use self instead).\n",
" # Remove the CWD from sys.path while we load stuff.\n"