def removeCommonWords(self, sentence, common_words, tokenized=False):
"""Takes a sentence and list of stopwords and removes the stopwords from the sentence."""
if not tokenized:
words = sentence.split(' ')
else:
words = sentence
final_sentence = []
for word in words:
word = word.translate(string.maketrans("", ""), string.punctuation)
word = word.lower()
if word in common_words:
continue
else:
final_sentence.append(word)
return final_sentence
SentenceComparator.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录