本文整理汇总了Python中histogram.Histogram.add_word方法的典型用法代码示例。如果您正苦于以下问题:Python Histogram.add_word方法的具体用法?Python Histogram.add_word怎么用?Python Histogram.add_word使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类histogram.Histogram
的用法示例。
在下文中一共展示了Histogram.add_word方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inserts
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import add_word [as 别名]
def test_inserts(words, tree):
hist = Histogram(tree)
for i in words:
hist.add_word(i)
示例2: test_frequency
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import add_word [as 别名]
hist.add_word(i)
def test_frequency(word, hist):
hist.frequency(word)
WORDS_ALL = get_full_word_list()
WORDS_100 = WORDS_ALL[:100]
if __name__ == "__main__":
radix_freq = Histogram(RadixTree)
binary_freq = Histogram(BinaryTree)
for word in WORDS_ALL:
radix_freq.add_word(word)
binary_freq.add_word(word)
print("radix_space: ", len(pickle.dumps(radix_freq)))
print("binary_space: ", len(pickle.dumps(binary_freq)))
radix_insert_test = "test_inserts(WORDS_100, RadixTree)"
binary_insert_test = "test_inserts(WORDS_100, BinaryTree)"
radix_freq_test = "test_frequency('{}', radix_freq)".format(WORDS_ALL[-1])
binary_freq_test = "test_frequency('{}',binary_freq)".format(WORDS_ALL[-1])
trial_nums = [10, 100, 1000, 10000]
row = ["num", "radix_insert", "binary_insert", "radix_freq", "binary_freq"]
print(row)