def label_topic_by_probability(cls, topic_description, min_word_probability=0.010, max_words=6):
"""
Try to disambiguate a topic considering all words with a weight greater than min_word_probability
:param max_words:
:param topic_description: is a list of pairs (word, word_probability)
:param min_word_probability: is the minimum probability for words
:return: list of strings, possible wikipedia pages
"""
words = [w for w, p in topic_description if p >= min_word_probability]
words = words[:max_words]
if len(words) == 0:
# if no words are over the threshold return empty
res = []
else:
res = wikipedia.search(' '.join(words))
return res
评论列表
文章目录