知识卡片
查询必须沿用拟合后的词表
拟合语料得到固定词表后,查询用transform编码,才能与文档逐列比较。若拟合错用了另一个变量,或问句从未被加入索引,不能按叙述声称必然完全匹配;检查实际输入集合与变量名比相信示例输出更可靠。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
>>> ngram_docs = copy.copy(docs) >>> ngram_docs.append(question) If you compute the vector of word counts for this new sentence (question), using the same vectorizer we trained in listing 3.2, you will see that it is exactly equal to the representation of the second sentence: >>> question_vec = vectorizer.transform([question]) >>> question_vec <1x240 sparse matrix of type '<class 'numpy.int64'>' with 3 stored elements in Compressed Sparse Row format>
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》第03章《词频与逆文档频率向量》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-3.html)
- 结论依据:摘录中关于查询必须沿用拟合后的词表的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:>>> ngram_docs = copy.copy(docs) >>> ngram_docs.append(question) If you compute the vector of word counts for this new sentence (question), using the same vectorizer we trained in listing 3.2, you will see that it is exactly equal to the representation of the second sentence: >>> question_vec = vectorizer.transform([question]) >>> question_vec <1x240 sparse matrix of type '<class 'numpy.int64'>' with 3 stored elements in Compressed Sparse Row format>