当前位置: 首页>>代码示例>>Python>>正文


Python Histogram.add_word方法代码示例

本文整理汇总了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)
开发者ID:MakeSchool-17,项目名称:twitter-bot-python-hDeraj,代码行数:6,代码来源:histogram_benchmark.py

示例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)
开发者ID:MakeSchool-17,项目名称:twitter-bot-python-hDeraj,代码行数:32,代码来源:histogram_benchmark.py


注:本文中的histogram.Histogram.add_word方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。