This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
(ns cipher-analytical-machine.symbols.frequencies
(:gen-class))
(defn map-to-string
"Convert the map of frequencies to the frequency string. Letters are sorted by frequency in descending order."
[frequency-map]
(->>frequency-map
(reduce (fn [accel](conj accel))[])
(sort-by last)
(map first)
(reverse)
(apply str)))
(def english-letter-frequencies{
\a0.0804
\b0.0154
\c0.0306
\d0.0399
\e0.1251
\f0.0230
\g0.0196
\h0.0549
\i0.0726
\j0.0016
\k0.0067
\l0.0414
\m0.0253
\n0.0709
\o0.0760
\p0.0200
\q0.0011
\r0.0612
\s0.0654
\t0.0925
\u0.0271
\v0.0099
\w0.0192
\x0.0019
\y0.0173
\z0.0009
})
(def ukrainian-letter-frequencies{
\а0.064
\б0.013
\в0.046
\г0.013
\ґ0.0001
\д0.027
\е0.042
\є0.005
\ж0.007
\з0.020
\и0.055
\і0.044
\ї0.010
\й0.009
\к0.033
\л0.027
\м0.029
\н0.068
\о0.086
\п0.025
\р0.043
\с0.037
\т0.045
\у0.027
\ф0.003
\х0.011
\ц0.010
\ч0.011
\ш0.005
\щ0.004
\ь0.016
\ю0.008
\я0.019
\ 0.138
})
(defn default-frequency-factory
"Returns a default map of letter frequencies for a language"