变身抓重点小能手:机器学习中的文本摘要入门指南 | 资源( 十 )

4 sentence_weight = dict()

5

6 for sentence in sentences:

7 sentence_wordcount = (len(word_tokenize(sentence)))

8 sentence_wordcount_without_stop_words = 0

9 for word_weight in frequency_table:

10 if word_weight in sentence.lower():

11 sentence_wordcount_without_stop_words += 1

12 if sentence[:7] in sentence_weight:

13 sentence_weight[sentence[:7]] += frequency_table[word_weight]

14 else:

15 sentence_weight[sentence[:7]] = frequency_table[word_weight]

推荐阅读