Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何在gensim中配置bigram模型以包含自定义bigram?_Python 3.x_Gensim - Fatal编程技术网

Python 3.x 如何在gensim中配置bigram模型以包含自定义bigram?

Python 3.x 如何在gensim中配置bigram模型以包含自定义bigram?,python-3.x,gensim,Python 3.x,Gensim,假设我有要在句子流中训练的数据 phrases = Phrases(sentence_stream) bigram_model = Phraser(phrases) 现在,如果我在一些测试数据上尝试我的bigram_模型并检查输出 sent = [u'the', u'mayor', u'of', u'new', u'york', u'was', u'there'] print(bigram_model[sent]) [u'the', u'mayor', u'of', u'new_york',

假设我有要在句子流中训练的数据

phrases = Phrases(sentence_stream)
bigram_model = Phraser(phrases)
现在,如果我在一些测试数据上尝试我的bigram_模型并检查输出

sent = [u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
print(bigram_model[sent])
[u'the', u'mayor', u'of', u'new_york', u'was', u'there']
现在,假设您希望在我的bigram\u模型中添加自定义bigram,如\u mayor,以便输出应该包含

[u'the_mayor', u'of', u'new_york', u'was', u'there']
关于如何配置bigram_模型有什么建议吗