本文整理汇总了Python中dictionary.Dictionary.set_words方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.set_words方法的具体用法?Python Dictionary.set_words怎么用?Python Dictionary.set_words使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.set_words方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test2
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import set_words [as 别名]
def test2():
dictionary = Dictionary()
dictionary.set_words(["KISSED"])
board = Board()
rack = "KISSEDQ"
solutions = board.generate_solutions(rack, dictionary)
solution = board.find_best_solution(solutions, dictionary)
if solution:
print "Winner: %s" % solution
board.add_solution(solution)
print board
assert solution and solution.score == 32
示例2: test_cross_with_blank
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import set_words [as 别名]
def test_cross_with_blank(self):
dic = Dictionary()
dic.set_words(["SA","JETS"])
board = Board()
board.add_word('JET', 5, 4, VERTICAL)
sol= Solution(8, 4, HORIZONTAL, 'SA', [])
sol.determine_score(board, dic)
self.assertEqual(sol.score, 13)
sol= Solution(8, 4, HORIZONTAL, 'SA', [0])
sol.determine_score(board, dic)
self.assertEqual(sol.score, 11)
board.add_solution(sol)
示例3: test_blanks_with_same_letter
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import set_words [as 别名]
def test_blanks_with_same_letter(self):
dic = Dictionary()
dic.set_words(["ABA"])
board = Board()
solutions = []
board.generate_solutions_in_line('?BA', dic, 7, HORIZONTAL, solutions)
words = set([(str(s)) for s in solutions])
self.assertEqual(words, set(['ABa (7,7,H)',
'aBA (7,7,H)',
'ABa (7,5,H)',
'aBA (7,5,H)',
'ABa (7,6,H)',
'aBA (7,6,H)']))
示例4: test_two_letter_one_blank
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import set_words [as 别名]
def test_two_letter_one_blank(self):
dic = Dictionary()
dic.set_words(["DUCE","EGRUGEAI"])
board = Board()
board.add_word('DUCE', 7, 4, HORIZONTAL)
sol= Solution(7, 7, VERTICAL, 'EGRUGEAI', [1])
sol.determine_score(board, dic)
sol= Solution(7, 7, VERTICAL, 'EGRUGEAI', [4])
sol.determine_score(board, dic)
solutions = board.generate_solutions('RUIAG?E', dic)
solution = board.find_best_solution(solutions, dic)
self.assertEqual(solution.score, 80)
示例5: test1
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import set_words [as 别名]
def test1():
dictionary = Dictionary()
dictionary.set_words(["OOZ", "OOZS", "PROSAIC", "PROC", "CC"])
board = Board()
# With this bug we'll get "PROC" but we want "PROSAIC" (where the S is the plural
# of "OOS"), which is longer.
board.add_word("OOZ", Board.SIZE/2, Board.SIZE/2 - 2, HORIZONTAL)
board.add_word("CC", Board.SIZE/2 + 1, Board.SIZE/2 - 2, HORIZONTAL)
rack = "PROSAIC"
solutions = board.generate_solutions(rack, dictionary)
solution = board.find_best_solution(solutions, dictionary)
if solution:
print "Winner: %s" % solution
board.add_solution(solution)
print board