mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-08 04:59:34 +08:00
优化格式
This commit is contained in:
@@ -175,6 +175,7 @@
|
||||
"\n",
|
||||
"def func(line, ngrams=[]):\n",
|
||||
" # 加入我们的组合词,保证分词的准确性\n",
|
||||
" \n",
|
||||
" if ngrams != []:\n",
|
||||
" for word in ngrams:\n",
|
||||
" jieba.add_word(\"\".join(word.lower()))\n",
|
||||
@@ -182,8 +183,7 @@
|
||||
" words = [word for word in jieba.cut(str(line).lower(), cut_all=False)]\n",
|
||||
" # print(\">>> \", train)\n",
|
||||
" return \" \".join(words)\n",
|
||||
"x = df[\"comment\"].apply(lambda line: func(line))\n",
|
||||
"y"
|
||||
"x = df[\"comment\"].apply(lambda line: func(line))\n"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -210,4 +210,4 @@ if __name__ == '__main__':
|
||||
status = True
|
||||
res = model.predict(text)
|
||||
label_dic = {0:"消极的", 1:"中性的", 2:"积极的"}
|
||||
print(res, " : ",label_dic[np.argmax(res)])
|
||||
print(res, " : ", label_dic[np.argmax(res)])
|
||||
|
||||
Reference in New Issue
Block a user