jieba/test/test_pos_file.py
Sun Junyi b62f052927 PEP8
2013-07-03 17:21:21 +08:00

22 lines
399 B
Python

import sys,time
import sys
sys.path.append("../")
import jieba
jieba.initialize()
import jieba.posseg as pseg
url = sys.argv[1]
content = open(url,"rb").read()
t1 = time.time()
words = list(pseg.cut(content))
t2 = time.time()
tm_cost = t2-t1
log_f = open("1.log","wb")
for w in words:
log_f.write(bytes(w.word+"/"+w.flag+" ",'utf-8'))
print('speed' , len(content)/tm_cost, " bytes/second")