小编Pra*_*uri的帖子

如何使用gensim从语料库中提取短语

为了预处理语料库,我计划从语料库中提取常用短语,为此我尝试在gensim中使用短语模型,我尝试下面的代码,但它没有给我想要的输出.

我的代码

from gensim.models import Phrases
documents = ["the mayor of new york was there", "machine learning can be useful sometimes"]

sentence_stream = [doc.split(" ") for doc in documents]
bigram = Phrases(sentence_stream)
sent = [u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
print(bigram[sent])
Run Code Online (Sandbox Code Playgroud)

产量

[u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
Run Code Online (Sandbox Code Playgroud)

但它应该成为

[u'the', u'mayor', u'of', u'new_york', u'was', u'there']
Run Code Online (Sandbox Code Playgroud)

但是当我试图打印火车数据的词汇时,我可以看到二元组,但它不能使用测试数据,我哪里出错了?

print bigram.vocab

defaultdict(<type 'int'>, {'useful': 1, 'was_there': 1, 'learning_can': 1, 'learning': 1, 'of_new': 1, 'can_be': 1, 'mayor': 1, 'there': 1, …
Run Code Online (Sandbox Code Playgroud)

python nlp gensim

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

在hadoop多集群中更改ssh默认端口

我的Hadoop muti节点集群有3个节点,一个namenode和两个datanode,由于某些原因,我想使用默认的ssh端口号,所以我正在使用Hbase来存储数据,但是如果我更改了默认的ssh端口号,则应该使用什么配置我将不得不在hadoop和hbase中进行更改吗?

我看到了链接,该链接仅说明了hadoop的配置更改,但是我认为Hbase,Zookeper和Yarn的配置也需要更改。我对吗?如果是,我需要在hadoop和hbase中做哪些更改?

Hadoop版本2.7.1

HBase版本1.0.1.1

帮助赞赏:)

ssh hadoop hbase

3
推荐指数
1
解决办法
2966
查看次数

标签 统计

gensim ×1

hadoop ×1

hbase ×1

nlp ×1

python ×1

ssh ×1