本文整理汇总了Python中nltk.stem.PorterStemmer.stopwords方法的典型用法代码示例。如果您正苦于以下问题:Python PorterStemmer.stopwords方法的具体用法?Python PorterStemmer.stopwords怎么用?Python PorterStemmer.stopwords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.stem.PorterStemmer
的用法示例。
在下文中一共展示了PorterStemmer.stopwords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trueSynSetStr
# 需要导入模块: from nltk.stem import PorterStemmer [as 别名]
# 或者: from nltk.stem.PorterStemmer import stopwords [as 别名]
if strippedSynset != 'None':
strippedSynset = trueSynSetStr(posStripped, strippedSynset)
thisWordInfo=(ps.stem(word.strip()),posStripped,strippedSynset)
prev = len(sentList)-1
if prev >= 0:
pre=sentList[prev][0]
sentList[prev][2]=thisWordInfo
sentList.append([thisWordInfo,pre,post])
return sentList
def synsetIsNone(wordtuple):
return wordtuple[2]=='None'
def posIsNone(wordtuple):
return wordtuple[1] == 'None'
if __name__=='__main__':
trainSet,testSet = prepareDataSet()
#clusterer = KMeansClusterer(num_means= 10, distance=calculateDistance)
#clusterer.cluster(trainSet)
tagged_sent = pos_tag (word_tokenize(argv[1]))
ps = PorterStemmer()
for word,pos in tagged_sent:
stwrds=ps.stopwords('english')
if word in stwrds:
continue
postag= wordnetpos(pos,decorator='')
if ( postag==''):
postag = None
syns = wn.synsets(word,postag)