From a2d2078465d71dafb74b30af7510518c50ffb3fc Mon Sep 17 00:00:00 2001 From: cloudaice Date: Fri, 10 May 2013 22:55:04 +0200 Subject: [PATCH] =?UTF-8?q?=E5=B0=86tab=E6=8D=A2=E6=88=90=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC=EF=BC=8C=E4=BD=BF=E7=94=A8is=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=98=AF=E5=90=A6=E4=B8=BANone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/extract_tags.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/extract_tags.py b/test/extract_tags.py index 58e7de3..3298749 100644 --- a/test/extract_tags.py +++ b/test/extract_tags.py @@ -5,29 +5,26 @@ import jieba import jieba.analyse from optparse import OptionParser -USAGE ="usage: python extract_tags.py [file name] -k [top k]" +USAGE = "usage: python extract_tags.py [file name] -k [top k]" parser = OptionParser(USAGE) -parser.add_option("-k",dest="topK") +parser.add_option("-k", dest="topK") opt, args = parser.parse_args() -if len(args) <1: - print USAGE - sys.exit(1) +if len(args) < 1: + print USAGE + sys.exit(1) file_name = args[0] -if opt.topK==None: - topK=10 +if opt.topK is None: + topK = 10 else: - topK = int(opt.topK) + topK = int(opt.topK) +content = open(file_name, 'rb').read() -content = open(file_name,'rb').read() - -tags = jieba.analyse.extract_tags(content,topK=topK) +tags = jieba.analyse.extract_tags(content, topK=topK) print ",".join(tags) - -