mirror of https://github.com/fxsjy/jieba.git
add one more example
parent
9ff5b09c15
commit
64b3c0d0e0
@ -0,0 +1,28 @@
|
||||
'''
|
||||
usage example (find top 100 words in abc.txt):
|
||||
|
||||
cat abc.txt | python jiebacmd.py | sort | uniq -c | sort -nr -k1 | head -100
|
||||
|
||||
|
||||
'''
|
||||
|
||||
|
||||
import sys
|
||||
sys.path.append("../")
|
||||
|
||||
import jieba
|
||||
|
||||
default_encoding='utf-8'
|
||||
|
||||
if len(sys.argv)>1:
|
||||
default_encoding = sys.argv[1]
|
||||
|
||||
while True:
|
||||
line = sys.stdin.readline()
|
||||
if line=="":
|
||||
break
|
||||
line = line.strip()
|
||||
for word in jieba.cut(line):
|
||||
print word.encode(default_encoding)
|
||||
|
||||
|
Loading…
Reference in New Issue