获取名称错误名称“句子流”未定义

2024-06-06 17:28:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用三元组和双元组,因为我不想只使用单数字。在

bigramer = gensim.models.Phrases(sentences)
model = Word2Vec(bigramer[sentences], workers=num_workers, \
            size=num_features, min_count = min_word_count, \
            window = context, sample = downsampling)
from nltk import bigrams
from nltk import trigrams
from gensim.models import Phrases
from gensim.models.phrases import Phraser
trigrams = Phrases(bigrams[sentence_stream])

但是,我有这个错误。在

^{pr2}$

Tags: fromimportmodelscountsentencesminnum三元组
1条回答
网友
1楼 · 发布于 2024-06-06 17:28:47

我通过将代码重写为:

bigram = Phrases(sentences, min_count=1, threshold=1)
print list(bigram[sentences])

trigram = Phrases(bigram[sentences],min_count=1, threshold=1)
print list(trigram[bigram[sentences]])

相关问题 更多 >