Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-----------------------------------------------------------
- # Parameters: None
- # Return: list
- # Description: Return a list with English language letter frequencies
- # first element is frequency of 'a'
- #-----------------------------------------------------------
- def get_freqTable():
- freqTable = [0.08167,0.01492,0.02782, 0.04253, 0.12702,0.02228, 0.02015,
- 0.06094, 0.06966, 0.00153, 0.00772, 0.04025, 0.02406, 0.06749,
- 0.07507, 0.01929, 0.00095, 0.05987, 0.06327, 0.09056, 0.02758,
- 0.00978, 0.0236, 0.0015, 0.01974, 0.00074]
- return freqTable
- #-----------------------------------------------------------
- # Parameters: text (str)
- # Return: list: wordCount
- # Description: Count frequency of letters in a given text
- # Returns a list, first element is count of 'a'
- # Counts both 'a' and 'A' as one character
- #-----------------------------------------------------------
- def get_charCount(text):
- return [text.count(chr(97+i))+text.count(chr(65+i)) for i in range(26)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement