相关疑难解决方法(0)

Python字符串中的u前缀是什么?

像:

u'Hello'
Run Code Online (Sandbox Code Playgroud)

我的猜测是它表示"Unicode",它是否正确?

如果是这样,从什么时候开始?

python syntax

204
推荐指数
4
解决办法
18万
查看次数

为文本挖掘创建词汇词典

我有以下代码:

train_set = ("The sky is blue.", "The sun is bright.")
test_set = ("The sun in the sky is bright.",
    "We can see the shining sun, the bright sun.")
Run Code Online (Sandbox Code Playgroud)

现在我试图计算这样的词频:

    from sklearn.feature_extraction.text import CountVectorizer
    vectorizer = CountVectorizer()
Run Code Online (Sandbox Code Playgroud)

接下来我想打印词汇表。因此我这样做:

vectorizer.fit_transform(train_set)
print vectorizer.vocabulary
Run Code Online (Sandbox Code Playgroud)

现在我得到的输出没有。虽然我期待这样的事情:

{'blue': 0, 'sun': 1, 'bright': 2, 'sky': 3}
Run Code Online (Sandbox Code Playgroud)

任何想法哪里出了问题?

python nlp text-mining

2
推荐指数
1
解决办法
8415
查看次数

标签 统计

python ×2

nlp ×1

syntax ×1

text-mining ×1