# -*- coding:utf8 -*- import os import jieba def splitSentence(inputFile): fin = open(inputFile, 'r') #以读的方式打开文件 global fout #以写得方式打开文件 #print fin global stop for eachLine in fin: #print eachLine line = eachLine.strip()#.decode('utf-8', 'ignore') #去除
Try caching the stopwords object, as shown below. Constructing this each time you call the function seems to be the bottleneck. from nltk.corpus import stopwords cachedStopWords = stopwords.words("english") def testFuncOld(): text = 'hello bye t
ElasticSearch 2 (24) - 语言处理系列之停用词:性能与精度 摘要 在信息检索早期,磁盘和内存相较我们今天的使用只是很小的一部分.将索引空间保持在一个较小的水平是至关重要的,节省每个字节都意味着巨大的性能提升.词干提取(参见 缩减单词至词根形式(Reducing Words to Their Root Form))的重要性不仅是因为它让搜索的内容更广泛.让检索的能力更深入,还因为它是压缩索引空间的工具. 要减少索引空间的另一个简单的方法就是索引更少的词.在搜索中,有些词要比其他