-
-
Save bartolsthoorn/b27ae8826d11b96cac40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tests for string (WORD) gibberish | |
def gibberish_probability_fine(string) | |
# Calculate how many % of string is consonants | |
consonants = Common::CONSONANTS | Common::NUMBERS | ['-', '_'] | |
fraction = string.downcase.count(consonants.join('').downcase).to_f/string.length.to_f | |
# fraction 0.0 - 1.0 turn into 1.0 - 0.0 - 1.0 | |
# 0.0 => 1.0 | |
# 0.5 => 0.0 | |
# 1.0 => 1.0 | |
fraction = (fraction-0.5).abs*2 | |
return fraction | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment