I before E except after C: Difference between revisions

(Add stretch goal including word frequencies.)
Line 84:
Checking plausibility of: E before I when preceded by C
IMPLAUSIBLE, probably contra-indicated. As we have counts of 13 vs 24 words, a ratio of 0.5 times
 
OVERALL IT IS IMPLAUSIBLE!
 
(To be plausible, one word count must exceed another by 2 times)</pre>
 
===Python: Stretch Goal===
Add the following to the bottom of the previous program:
<lang python>freq = [line.strip().lower().split()
for line in urllib.request.urlopen('http://ucrel.lancs.ac.uk/bncfreq/lists/1_2_all_freq.txt')
if len(line.strip().split()) == 3]
wordfreq = [(word.decode(), int(frq))
for word, pos, frq in freq[1:]
if (b'ie' in word) or (b'ei' in word)]
cie = sum(frq for word, frq in wordfreq if 'cie' in word)
cei = sum(frq for word, frq in wordfreq if 'cei' in word)
not_c_ie = sum(frq for word, frq in wordfreq if re.search(r'(^ie|[^c]ie)', word))
not_c_ei = sum(frq for word, frq in wordfreq if re.search(r'(^ei|[^c]ei)', word))
 
print('\n\nChecking plausibility of "I before E except after C"')
print('And taking account of word frequencies in British English:')
if ( plausibility_check('I before E when not preceded by C', not_c_ie, not_c_ei)
& plausibility_check('E before I when preceded by C', cei, cie) ):
print('\nOVERALL IT IS PLAUSIBLE!')
else:
print('\nOVERALL IT IS IMPLAUSIBLE!')
print('\n(To be plausible, one word count must exceed another by %i times)' % PLAUSIBILITY_RATIO)</lang>
 
To produce this extra output:
<pre>Checking plausibility of "I before E except after C"
And taking account of word frequencies in British English:
 
Checking plausibility of: I before E when not preceded by C
IMPLAUSIBLE. As although we have counts of 8192 vs 4826 words, a ratio of 1.7 times does not make it plausible
 
Checking plausibility of: E before I when preceded by C
IMPLAUSIBLE, probably contra-indicated. As we have counts of 327 vs 994 words, a ratio of 0.3 times
 
OVERALL IT IS IMPLAUSIBLE!
Anonymous user