File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -335,12 +335,13 @@ def decode(self, ciphertext):
335
335
"Search for a decoding of the ciphertext."
336
336
self .ciphertext = ciphertext
337
337
problem = PermutationDecoderProblem (decoder = self )
338
- return search .best_first_tree_search (problem , self .score )
338
+ return search .best_first_tree_search (
339
+ problem , lambda node : self .score (node .state ))
339
340
340
- def score (self , ciphertext , code ):
341
+ def score (self , code ):
341
342
"""Score is product of word scores, unigram scores, and bigram scores.
342
343
This can get very small, so we use logs and exp."""
343
- text = decode ( ciphertext , code )
344
+ text = permutation_decode ( self . ciphertext , code )
344
345
logP = (sum ([log (self .Pwords [word ]) for word in words (text )]) +
345
346
sum ([log (self .P1 [c ]) for c in text ]) +
346
347
sum ([log (self .P2 [b ]) for b in bigrams (text )]))
You can’t perform that action at this time.
0 commit comments