擅长:python、mysql、java
<p>一个简单的方法是为NN、VB等保留<a href="http://en.wikipedia.org/wiki/Stop_words" rel="nofollow" title="Stop Words">stop word</a>列表,这些是高频词,通常不会给句子添加太多语义内容。</p>
<p>下面的代码片段显示了每种类型的单词标记的不同列表,但是您也可以为动词和名词(例如<a href="http://www.ranks.nl/resources/stopwords.html" rel="nofollow">this</a>one)使用一个停止词列表。</p>
<pre><code>stop_words = dict(
NNP=['first', 'second'],
NN=['thing'],
VBP=['do','done'],
VB=[],
NNS=['lets', 'things'],
)
def filter_stop_words(pos_list):
return [[token, token_type]
for token, token_type in pos_list
if token.lower() not in stop_words[token_type]]
</code></pre>