1 Star 1 Fork 1

影子的约定/ChatBotCourse

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
word_segment.py 786 Bytes
一键复制 编辑 原始数据 按行查看 历史
lichuang 提交于 2016-10-16 17:36 . add gensim word2vec
# coding:utf-8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import jieba
from jieba import analyse
def segment(input, output):
input_file = open(input, "r")
output_file = open(output, "w")
while True:
line = input_file.readline()
if line:
line = line.strip()
seg_list = jieba.cut(line)
segments = ""
for str in seg_list:
segments = segments + " " + str
segments = segments + "\n"
output_file.write(segments)
else:
break
input_file.close()
output_file.close()
if __name__ == '__main__':
if 3 != len(sys.argv):
print "Usage: ", sys.argv[0], "input output"
sys.exit(-1)
segment(sys.argv[1], sys.argv[2]);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/pjx123/ChatBotCourse.git
git@gitee.com:pjx123/ChatBotCourse.git
pjx123
ChatBotCourse
ChatBotCourse
master

搜索帮助