知识卡片

问题卡 · 6240.e

词型数量不等于稀有词数

理解等级:中级

len(tokens)数全部词次,len(fdist.keys())数互异词型,不能按示例注释说成罕见单词数量。找低频词需要查看每个词的实际次数并定义低频阈值;同样,按http开头筛词表得到的是这类互异词型数,不是所有URL出现次数或已核验的有效URL数。

后续示例使用hapaxes()取得恰出现一次的词型;它与len(fdist.keys())的全部互异词型数不同。若需要前十高频词,应确认排序依据而不是直接取任意items的前十。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 2 处

    • · 查看原书依据

      len(fdist.keys()) # 不是停用词的普通单词 [w for w in fdist.keys()[:100] \ if w.lower() not in nltk.corpus.stopwords.words('english')] # 不是URL的长单词 [w for w in fdist.keys() if len(w) > 15 and

    • · 查看原书依据

      fdist.hapaxes()) top_10_words_sans_stop_words = [w for w in fdist.items() if w[0] not in stop_words][:10] print post['title'] print '\tNum Sentences:'.ljust(25), len(sentences) pri

    参考来源

    - 位置:《社交网站的数据挖掘与分析(原书第2版)》第4章《4.4.1 自然语言工具包概述》(spine87;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0076.html;u064-ch04-019)。 - 结论依据:原文在“len(fdist.keys())”附近的定义、例子或代码支撑本卡核心说明:len(tokens)数全部词次,len(fdist.keys())数互异词型,不能按示例注释说成罕见单词数量。边界按已读前提解释;示例未执行。 - 原始内容:len(fdist.keys()) # 不是停用词的普通单词 [w for w in fdist.keys()[:100] \ if w.lower() not in nltk.corpus.stopwords.words('english')] # 不是URL的长单词 [w for w in fdist.keys() if len(w) > 15 and - 位置:《社交网站的数据挖掘与分析(原书第2版)》第5章《5.3.2 人类语言数据的句子检测》(spine94;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0083.html;u078-ch04-019)。 - 结论依据:本节hapaxes才是只出现一次的词集合,词型数与单现词数分别统计。 - 原始内容:fdist.hapaxes()) top_10_words_sans_stop_words = [w for w in fdist.items() if w[0] not in stop_words][:10] print post['title'] print '\tNum Sentences:'.ljust(25), len(sentences) pri