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

3def _create_dictionary_table(text_string) -> dict:

4

5 # Removing stop words

6 stop_words = set(stopwords.words("english"))

7

8 words = word_tokenize(text_string)

9

10 # Reducing words to their root form

11 stem = PorterStemmer()

12

13 # Creating dictionary for the word frequency table

14 frequency_table = dict()

15 for wd in words:

16 wd = stem.stem(wd)

17 if wd in stop_words:

18 continue

推荐阅读