【问题标题】:PorterStemmer: No Stemming Output nor Error while running on SpyderPorterStemmer:在 Spyder 上运行时没有词干输出或错误
【发布时间】:2018-12-20 08:36:51
【问题描述】:

As evident in my Spyder's screen-shot 和下面的代码,我没有得到任何输出或任何错误。我错过了什么?:

import nltk
from nltk.stem import PorterStemmer

paragraph = "The Times of India issued its first edition on 3 November 
             1838 as The Bombay Times and Journal of Commerce.[13][14] 
             The paper published Wednesdays and Saturdays under the 
             direction of Raobahadur Narayan Dinanath Velkar, a 
             Maharashtrian Reformist, and contained news from Britain and the world, as well as the Indian Subcontinent. J.E. Brennan was its first editor.[15][16] In 1850, it began to publish 
             daily editions."

sentences = nltk.sent_tokenize(paragraph)
stemmer = PorterStemmer()

for i in range(len(sentences)):
    words = nltk.word_tokenize(sentences[i])
    newwords = [stemmer.stem(word) for word in words]
    sentences[i] = ' '.join(newwords)    

【问题讨论】:

  • 你忘记print声明了吗?
  • 在 spyder 的变量资源管理器中,您可以看到脚本的变量数据

标签: python nltk spyder stemming


【解决方案1】:

感谢@prashant rana,我的按钮是点击帮助而不是变量资源管理器

【讨论】:

    猜你喜欢
    • 2015-10-16
    • 1970-01-01
    • 2020-12-14
    • 2012-08-23
    • 2021-09-11
    • 2019-08-29
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    相关资源
    最近更新 更多