projects
/
cipher-tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
37cc0fd
)
Multiprocessing now working
author
Neil Smith
<neil.git@njae.me.uk>
Sun, 3 Nov 2013 13:55:05 +0000
(13:55 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Sun, 3 Nov 2013 13:55:05 +0000
(13:55 +0000)
cipher.py
patch
|
blob
|
history
diff --git
a/cipher.py
b/cipher.py
index 7fffd522759f3aa7cf74084480ca0099c19f59ef..8eb689ca6a55cbe18a9a4375e9580d689113dcce 100644
(file)
--- a/
cipher.py
+++ b/
cipher.py
@@
-436,9
+436,9
@@
def keyword_break_mp(message, wordlist=keywords, metric=norms.euclidean_distance
(('elephant', 1), 0.41643991598441...)
"""
with Pool() as pool:
(('elephant', 1), 0.41643991598441...)
"""
with Pool() as pool:
-
keys = [(word, wrap
) for word in wordlist for wrap in range(3)]
+
helper_args = [(message, word, wrap, metric, target_counts, message_frequency_scaling
) for word in wordlist for wrap in range(3)]
# breaks = map(lambda kw: keyword_break_one(message, kw[0], kw[1], metric, target_counts, message_frequency_scaling), keys)
# breaks = map(lambda kw: keyword_break_one(message, kw[0], kw[1], metric, target_counts, message_frequency_scaling), keys)
- breaks = pool.starmap(
lambda k, w: keyword_break_one(message, k, w, metric, target_counts, message_frequency_scaling), key
s, 1000)
+ breaks = pool.starmap(
keyword_break_one, helper_arg
s, 1000)
return min(breaks, key=lambda k: k[1])
def keyword_break_one(message, keyword, wrap_alphabet, metric, target_counts, message_frequency_scaling):
return min(breaks, key=lambda k: k[1])
def keyword_break_one(message, keyword, wrap_alphabet, metric, target_counts, message_frequency_scaling):