Expand description
The frequency
module, providing various utilities relating to frequency analysis.
Functions§
- cased_
counts - Returns a frequency map of the given text. The turned map maps characters to the number of
times they appear in the given string. To get a frequency map that maps characters to percentages,
use
frequency::of_cased()
. - character_
score - closest_
english_ letter - Returns the English character whose frequency is closest to the given frequency percentage.
- counts
- Returns a frequency map of the given text. The turned map maps characters to the number of
times they appear in the given string. To get a frequency map that maps characters to percentages,
use
Frequency::of()
. - distribution_
score - Returns a “score” in
(0, 1]
that describes how well the given text’s letter frequencies fit the same distribution as standard English. A higher score (closer to 1) indicates the text’s frequency is closer to English. - english
- Returns the frequencies of each letter of the English alphabet as a map between
characters and percentage of words they appear in. The returned map will include both
lowercase and uppercase characters, with the lowercase and uppercase variant of each
letter having the same frequency value. To get a specific subset, use
Frequency::english_lowercase()
orFrequency::english_uppercase()
. - english_
lowercase - Returns the frequencies of each letter of the English alphabet as a map between
characters and percentage of words they appear in. The returned map will include
only lowercase characters. To get a different subset, use
Frequency::english_uppercase()
orFrequency::english()
for both. - english_
uppercase - Returns the frequencies of each letter of the English alphabet as a map between
characters and percentage of words they appear in. The returned map will include
only uppercase characters. To get a different subset, use
Frequency::english_lowercase()
orFrequency::english()
for both. - mapped_
to_ english - Converts each character in the given text to the character that has the closest frequency in the English alphabet. This will not reuse characters, i.e., if the closest frequency to ‘B’ is ‘E’ and the closest frequency to ‘C’ is also ‘E’, once ‘B’ is mapped to ‘E’, ‘C’ cannot be mapped to ‘E’ and will be mapped to something else.
- of
- Returns a frequency map of the given text. The returned map maps characters to
the percent of the entire string that the character makes up. To get the counts of each character,
use
frequency::counts()
. This is also case-insensitive; The case-sensitive version isfrequency::of_cased
. - of_
cased - Returns a frequency map of the given text. The returned map maps characters to
the percent of the entire string that the character makes up. To get the counts of each character,
use
frequency::counts()
. This is also case-sensitive; The case-insensitive version isfrequency::of
.