projects
/
cipher-training.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated letter frequencies, updated test values to reflect them
[cipher-training.git]
/
language_models.py
diff --git
a/language_models.py
b/language_models.py
index 929746888d036fb54de3f1fbf228e296e0bcd027..ceb4596eb2fd87d3d2375f338892f9652525f2d4 100644
(file)
--- a/
language_models.py
+++ b/
language_models.py
@@
-140,14
+140,14
@@
def Pbigrams(letters):
return sum(P2l[p] for p in ngrams(letters, 2))
return sum(P2l[p] for p in ngrams(letters, 2))
-def cosine_
distance
_score(text):
+def cosine_
similarity
_score(text):
"""Finds the dissimilarity of a text to English, using the cosine distance
of the frequency distribution.
"""Finds the dissimilarity of a text to English, using the cosine distance
of the frequency distribution.
- >>> cosine_
distance
_score('abcabc') # doctest: +ELLIPSIS
- 0.
370847405
...
+ >>> cosine_
similarity
_score('abcabc') # doctest: +ELLIPSIS
+ 0.
26228882
...
"""
"""
- return norms.cosine_
distance
(english_counts,
+ return norms.cosine_
similarity
(english_counts,
collections.Counter(sanitise(text)))
collections.Counter(sanitise(text)))