SHARE
TWEET

Untitled

a guest Oct 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #-----------------------------------------------------------
  2. # Parameters:   None
  3. # Return:       list
  4. # Description:  Return a list with English language letter frequencies
  5. #               first element is frequency of 'a'
  6. #-----------------------------------------------------------
  7. def get_freqTable():
  8.     freqTable = [0.08167,0.01492,0.02782, 0.04253, 0.12702,0.02228, 0.02015,
  9.                  0.06094, 0.06966, 0.00153, 0.00772, 0.04025, 0.02406, 0.06749,
  10.                  0.07507, 0.01929, 0.00095, 0.05987, 0.06327, 0.09056, 0.02758,
  11.                  0.00978, 0.0236, 0.0015, 0.01974, 0.00074]
  12.     return freqTable
  13.  
  14. #-----------------------------------------------------------
  15. # Parameters:   text (str)
  16. # Return:       list: wordCount
  17. # Description:  Count frequency of letters in a given text
  18. #               Returns a list, first element is count of 'a'
  19. #               Counts both 'a' and 'A' as one character
  20. #-----------------------------------------------------------
  21. def get_charCount(text):
  22.     return [text.count(chr(97+i))+text.count(chr(65+i)) for i in range(26)]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top