Essentially, I am trying to read some text and count instances of letters. Very simple. However, no matter what I try, I get different results for "E"
and "e"
, when I want combined results. Here is what I have:
import nltk
import re
f = open('mytext.txt')
raw = f.read()
#print raw
#print len(raw) #7234
raw.lower()
prompt = raw_input("Enter stuff: ")
potato = re.compile(r'[a-z]*', re.IGNORECASE)
potato = re.match(r'[a-z]*', prompt, re.IGNORECASE)
if potato:
print raw.count(prompt)
else:
print "try again"
#document control f "e" = 808
#print result "e" = 802, "E" = 6