本文整理汇总了Python中dictionary.Dictionary.all_docs方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.all_docs方法的具体用法?Python Dictionary.all_docs怎么用?Python Dictionary.all_docs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.all_docs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dictionary_all_docs
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import all_docs [as 别名]
def test_dictionary_all_docs():
d = Dictionary()
assert_eq([], d.all_docs())
d.add_term('asdf', 1, 1)
assert_eq([1], d.all_docs())
d.add_term('asdf', 2, 1)
assert_eq([1, 2], d.all_docs())
d.add_term('qwer', 1, 1)
d.add_term('zxcv', 1, 1)
assert_eq([1, 2], d.all_docs())
示例2: test_dictionary_to_json_from_json
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import all_docs [as 别名]
def test_dictionary_to_json_from_json():
d = Dictionary()
d.add_term('asdf', 1, 1)
d.add_term('asdf', 2, 1)
d.add_term('qwer', 1, 1)
d.add_term('zxcv', 1, 1)
d2 = Dictionary.from_json(d.to_json())
assert_eq(d2.all_docs(), d.all_docs())
assert_eq(d2.all_terms(), d.all_terms())
assert_eq(d2.get_frequency('asdf'), d.get_frequency('asdf'))
assert_eq(d2.get_frequency('qwer'), d.get_frequency('qwer'))
assert_eq(d2.get_frequency('zxcv'), d.get_frequency('zxcv'))
assert_eq(d2.get_head('asdf'), d.get_head('asdf'))
assert_eq(d2.get_head('qwer'), d.get_head('qwer'))
assert_eq(d2.get_head('zxcv'), d.get_head('zxcv'))
assert_eq(d2.get_tail('asdf'), d.get_tail('asdf'))
assert_eq(d2.get_tail('qwer'), d.get_tail('qwer'))
assert_eq(d2.get_tail('zxcv'), d.get_tail('zxcv'))