基本信息
源码名称:运维聚类(自然语言处理方法)的问答机器人
源码大小:58.17M
文件格式:.zip
开发语言:Python
更新时间:2021-11-22
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 4 元×
微信扫码支付:4 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
"import pandas as pd\n",
"import re\n",
"import codecs\n",
" \n",
"#将excel转化为txt文件\n",
"def exceltotxt(excel_dir, txt_dir): \n",
" with codecs.open(txt_dir, 'w', 'utf-8') as f:\n",
" neg=pd.read_excel(excel_dir, header=None, index=None)\n",
" f.write(neg.to_string())\n",
" \n",
"\n",
" #去除记录行首的数字和空格\n",
"def del_linehead_number_speace(orig_txt_dir,saveas_txt_dir):\n",
" with open(orig_txt_dir,'r ',encoding='UTF-8') as f, open(saveas_txt_dir,'r ',encoding='UTF-8') as fw:\n",
" lines = f.readlines()\n",
" print(len(lines)) #行数\n",
" texts = [re.sub(r'(\\d) (\\s) ','',lines[num]) for num in range(len(lines)) ]\n",
" \n",
" texts = list(set(texts)) #去重如果要保留重复记录注释该行\n",
" \n",
" line_num = len(texts)\n",
"# for num in range(line_num): #查看转化后的文本\n",
"# print(texts[num])\n",
" fw.writelines(texts)\n",
" \n",
"exceltotxt('operation_issues.xlsx', 'operation_temp_issues.txt') \n",
"del_linehead_number_speace('operation_temp_issues.txt','operation_issues.txt')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Building prefix dict from the default dictionary ...\n",
"Dumping model to file cache C:\\Users\\hu\\AppData\\Local\\Temp\\jieba.cache\n",
"Loading model cost 0.869 seconds.\n",
"Prefix dict has been built successfully.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
当公司相关人员遇到运维问题时,将问题以文字描述,发送给运维机器人后,可得到相应解决方案,实现常见操作类运维问题自行解决。
"import pandas as pd\n",
"import re\n",
"import codecs\n",
" \n",
"#将excel转化为txt文件\n",
"def exceltotxt(excel_dir, txt_dir): \n",
" with codecs.open(txt_dir, 'w', 'utf-8') as f:\n",
" neg=pd.read_excel(excel_dir, header=None, index=None)\n",
" f.write(neg.to_string())\n",
" \n",
"\n",
" #去除记录行首的数字和空格\n",
"def del_linehead_number_speace(orig_txt_dir,saveas_txt_dir):\n",
" with open(orig_txt_dir,'r ',encoding='UTF-8') as f, open(saveas_txt_dir,'r ',encoding='UTF-8') as fw:\n",
" lines = f.readlines()\n",
" print(len(lines)) #行数\n",
" texts = [re.sub(r'(\\d) (\\s) ','',lines[num]) for num in range(len(lines)) ]\n",
" \n",
" texts = list(set(texts)) #去重如果要保留重复记录注释该行\n",
" \n",
" line_num = len(texts)\n",
"# for num in range(line_num): #查看转化后的文本\n",
"# print(texts[num])\n",
" fw.writelines(texts)\n",
" \n",
"exceltotxt('operation_issues.xlsx', 'operation_temp_issues.txt') \n",
"del_linehead_number_speace('operation_temp_issues.txt','operation_issues.txt')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Building prefix dict from the default dictionary ...\n",
"Dumping model to file cache C:\\Users\\hu\\AppData\\Local\\Temp\\jieba.cache\n",
"Loading model cost 0.869 seconds.\n",
"Prefix dict has been built successfully.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [