假设我有一个字符串text = "A compiler translates code from a source language"。我想做两件事:
我需要使用NLTK库遍历每个单词和词干。词干的函数是PorterStemmer().stem_word(word)。我们必须把争论的“话”传递出去。我怎么才能把每个词都截住,然后把词干句拿回来呢?我需要从text字符串中删除某些停止词。包含停止词的列表存储在<e
使用下面的代码(我承认这有点麻烦),我用逗号分隔字符串,但条件是当字符串包含逗号分隔的单个单词时,字符串不分开,例如:它不分隔"Yup, there's a reason why you want tomasturbating, is directly beneficial to the circulation, and can reduce the likelihood of a heart attack&quo