Andy Sun
Andy Sun
@linkerlin , @lewsn2008 , 我找到了之前写的生成idf.txt的脚本,基本思路是对一些小说报刊语料进行分词,然后以段落为单位,统计idf. ``` python import jieba import math import sys import re re_han = re.compile(ur"([\u4E00-\u9FA5]+)") d={} total = 0 for line in open("yuliao_onlyseg.txt",'rb'): sentence = line.decode('utf-8').strip() words...
@linkerlin , 也可以math.log(total/v)
@jannson , 已关注。
@lewsn2008 , 这个文件有200多MB,怎么发给你?
@aszxqw , @lewsn2008 ,试用了一下百度云盘,分享地址:http://pan.baidu.com/share/link?shareid=4094310849&uk=1124369080
@lisnb , 我没有用过py2exe。看错误信息,'E:\python\links\romeo\dist\l ibrary.zip\jieba\finalseg\prob_start.py' 这个py文件被打包在zip里面了,所以读不出来。等会我装个py2exe试一试
@lisnb ,试了一下,确实不行。 路径问题不好处理啊,数据文件应该怎么放?
@yangboz , 这个问题解决了,你git pull更新一下。 我用cxfree试验成功了。 测试程序: hello.py ``` python #encoding=utf-8 import jieba jieba.set_dictionary("./dict.txt") jieba.initialize() s="我研究生命起源。" print " ".join(jieba.cut(s)) ``` dict.txt 放在hello.py 同级目录。
@yangboz , sorry,昨天的更新没有解决posseg读词典的路径问题,麻烦你再pull一下试一试。 下面是我的测试程序: ``` python #encoding=utf-8 import jieba jieba.set_dictionary("./dict.txt") #相对路径 #jieba.set_dictionary("c:/tmp/dict.txt") #也支持绝对路径 jieba.initialize() from jieba import posseg s="我研究生命起源。" print " ".join(jieba.cut(s)) for w in posseg.cut(s): print w.word,w.flag ```