一、自然语言处理笔记
1.generator与list区别
generator采用next机制,不用构建整个存储空间,而list需要构建整个存储空间
2.字符串前面加u、r、b的含义
u indicate string use unicode
r indicate do not use transfer.etc,print('/n') will make cursor to next raw,but print(r'/n') will print '/n' exactly
b indicate python2.x's bytes
3.处理步骤
1.下载wiki的原始数据包
2.用wiki的process.py解析数据包得到繁体字数据
3.opencc进行处理,转换成简体中文数据
4.jieba进行分词和词性分类
5.gensim建模
6.界面开发
4.文件上传
选择一个语料文件上传:
#视图函数代码片
file=request.files['file']
file.save
5.文件下载
#https://www.jianshu.com/p/8daa3d011cfd
from flask import send_file, send_from_directory
import os
@app.route("/download/<filename>", methods=['GET'])
def download_file(filename):
# 需要知道2个参数, 第1个参数是本地目录的path, 第2个参数是文件名(带扩展名)
directory = os.getcwd() # 假设在当前目录
return send_from_directory(directory, filename, as_attachment=True)
6.ht