本文整理汇总了Python中gensim.models.phrases.Phrases.scoring方法的典型用法代码示例。如果您正苦于以下问题:Python Phrases.scoring方法的具体用法?Python Phrases.scoring怎么用?Python Phrases.scoring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gensim.models.phrases.Phrases
的用法示例。
在下文中一共展示了Phrases.scoring方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSaveLoadStringScoring
# 需要导入模块: from gensim.models.phrases import Phrases [as 别名]
# 或者: from gensim.models.phrases.Phrases import scoring [as 别名]
def testSaveLoadStringScoring(self):
""" Saving and loading a Phrases object with a string scoring parameter.
This should ensure backwards compatibility with the previous version of Phrases"""
try:
bigram = Phrases(self.sentences, min_count=1, threshold=1)
bigram.scoring = "default"
bigram.save("test_phrases_testSaveLoadStringScoring_temp_save.pkl")
bigram_loaded = Phrases.load("test_phrases_testSaveLoadStringScoring_temp_save.pkl")
seen_scores = set()
test_sentences = [['graph', 'minors', 'survey', 'human', 'interface', 'system']]
for phrase, score in bigram_loaded.export_phrases(test_sentences):
seen_scores.add(round(score, 3))
assert seen_scores == set([
5.167, # score for graph minors
3.444 # score for human interface
])
finally:
if os.path.exists("test_phrases_testSaveLoadStringScoring_temp_save.pkl"):
os.remove("test_phrases_testSaveLoadStringScoring_temp_save.pkl")