擅长:python、mysql、java
<p>如果我理解正确的话,你想从一个标记化文本文档中准备一袋单词,这是错误的方法。在对每个文档(语料库)进行预处理之后,基本上必须回到“句子”的形式</p>
<pre><code>['hello', 'like', mountain', 'spring']
</code></pre>
<p>快去吧</p>
<pre><code>'hello like mountain spring'
</code></pre>
<p>对所有文档都这样做,这样您将拥有与示例中的数组相似的数组</p>
<pre><code>['hello like mountain summer', 'another string here', 'another also here']
</code></pre>
<p>这是我们可以开始准备一袋单词的表格,它将是:</p>
<pre><code>{hello, like, mountain, summer, another, string, here, also}
</code></pre>
<p>从这一点上,计算TF,TFID是很容易的,这是符合CountVectorizer期望的形式。你知道吗</p>