Module frequency

Source
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() or Frequency::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() or Frequency::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() or Frequency::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 is frequency::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 is frequency::of.