在任何一种语言中,停用词(stop word)指的是那些出现频率非常高的常见词,但是对短语的含义而言,这些词承载的实质性信息内容却少得多。一些常见的停用词的例子如下:
1.a, an
2.the, this
3.and, or
4.of, on
从传统上说,NLP 流水线都会剔除停用词,以便减小从文本中提取信息时的计算压力。
stop_words = ['a', 'an', 'the', 'on', 'of', 'off', 'this', 'is']
tokens = ['the', 'house', 'is', 'on', 'fire']
tokens_without_stopwords = [x for x in tokens if x not in stop_words]
print(tokens_without_stopwords)