知识卡片
词组计数要区分位置和可能类型
ngram_range=(1,2)同时提取单词和相邻二元组。长度L的序列有L−n+1个n元位置,而词表上理论可能类型随V的n次方增长;不能混称位置数随文本长度指数增长,也不能保证任何语料二元类型必多于一元。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
>>> ngram_vectorizer = CountVectorizer(ngram_range=(1, 2)) >>> ngram_vectors = ngram_vectorizer.fit_transform(corpus) >>> ngram_vectors <16x616 sparse matrix of type '<class 'numpy.int64'>' with 772 stored elements in Compressed Sparse Row format> While looking at the dimensionality of the new count vectors, you probably noticed that these vectors are significantly longer. There are always more unique 2-grams (pairs of words) than unique tokens. Check out the n-gram counts for that
参考来源
- 位置:《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_vectorizer = CountVectorizer(ngram_range=(1, 2)) >>> ngram_vectors = ngram_vectorizer.fit_transform(corpus) >>> ngram_vectors <16x616 sparse matrix of type '<class 'numpy.int64'>' with 772 stored elements in Compressed Sparse Row format> While looking at the dimensionality of the new count vectors, you probably noticed that these vectors are significantly longer. There are always more unique 2-grams (pairs of words) than unique tokens. Check out the n-gram counts for that