I before E except after C: Difference between revisions

m
{{out}}
m (→‎{{header|REXX}}: reinstated original bullet points.)
m ({{out}})
Line 1:
{{task}}
The phrase [[wp:I before E except after C|"I before E, except after C"]] is a widely known mnemonic which is supposed to help when spelling English words.
widely known mnemonic which is supposed to help when spelling English words.
 
;Task Description:
Using the word list from [http://www.puzzlers.org/pub/wordlists/unixdict.txt http://www.puzzlers.org/pub/wordlists/unixdict.txt], check if the two sub-clauses of the phrase are plausible individually:
of the phrase are plausible individually:
# ''"I before E when not preceded by C"''
# ''"E before I when preceded by C"''
Line 43 ⟶ 45:
return, WebRequest.ResponseText
}</lang>
{{out}}
'''Output:'''
<pre>"I before E when not preceded by C" is plausible.
466 cases for and 217 cases against is a ratio of 2.147465.
Line 100 ⟶ 102:
 
=={{header|C}}==
Inspired by the J solution, but implemented as a single pass through the data, we have [http://flex.sourceforge.net/ flex] build the finite state machine in C. This may in turn motivate me to provide a second J solution as a single pass FSM. Please find the program output hidden at the top of the source as part of the build and example run.
we have [http://flex.sourceforge.net/ flex] build the finite state machine in C.
This may in turn motivate me to provide a second J solution as a single pass FSM.
Please find the program output hidden at the top of the source as part of the build and example run.
<lang c>
%{
Line 252 ⟶ 257:
</lang>
 
{{out}}
<pre>
Output:
[^c]ie [pro] multiple matches in: siegfried
[^c]ie [against] multiple matches in: weinstein
Line 320 ⟶ 325:
</lang>
 
{{out}}
Output:
<pre>Dictionary:
The rule "I before E when not preceded by C" is PLAUSIBLE. There were 465 examples and 213 counter-examples.
Line 465 ⟶ 470:
 
</lang>
{{out}}
Output:
<pre>
 
The number of words in unixdict.txt 25104
 
Line 591 ⟶ 595:
printf "*** Rule 2 is %splausible.\n" (if rule2Plausible then "" else "im")</lang>
 
{{out}}
The output:
 
<pre>
Checking Rule 1: "I before E when not preceded by C"...
Line 631 ⟶ 634:
end</lang>
 
Output{{out}} of running with <tt>--showcounts</tt> flag:
 
<pre>
-> ei --showcounts <unixdict.txt
Line 673 ⟶ 675:
end</lang>
 
{{out}}
with output:
<pre>
->ei2 --showcounts <1_2*txt
Line 802 ⟶ 804:
</lang>
 
{{out}}
Output:
<pre>Plausible count: 384
Implausible count: 204
Line 1,008 ⟶ 1,010:
</lang>
 
{{out}}
Output:
<pre>
Checking plausibility of "I before E except after C":
Line 1,055 ⟶ 1,057:
print 'Overall: ', 'NOT ' x ($result < 2), "PLAUSIBLE.\n";</lang>
 
{{out}}
Output:
 
<pre>I before E when not preceded by C: 465 / 213 = 2.18. PLAUSIBLE
E before I when preceded by C: 13 / 24 = 0.54. NOT PLAUSIBLE
Line 1,071 ⟶ 1,072:
}
}</lang>
{{out}}
Output:
<pre>I before E when not preceded by C: 8148 / 4826 = 1.69. NOT PLAUSIBLE
E before I when preceded by C: 327 / 994 = 0.33. NOT PLAUSIBLE
Line 1,349 ⟶ 1,350:
print_result(*stretch_stats())</lang>
 
To produce{{out|Produces this extra output:}}
<pre>Checking plausibility of "I before E except after C"
And taking account of word frequencies in British English:
Line 1,376 ⟶ 1,377:
message("The whole phrase is ", (if (p1 && p2) "" else "not "), "plausible.")</lang>
 
{{out}}
Output:
 
<pre>(1) is plausible.
(2) is not plausible.
Line 1,416:
(plausibility "Word frequencies (stretch goal)" "1_2_all_freq.txt" parse-frequency-data)</lang>
 
{{outputout}}
 
<pre>
Dictionary:
Line 1,477 ⟶ 1,476:
end /*forever*/
return</lang>
'''output'''{{out}} when using the default dictionary
<pre>
lines in the UNIXDICT.TXT dictionary: 25104
Line 1,577 ⟶ 1,576:
end /*forever*/
return</lang>
'''output'''{{out}} when using the default dictionary and default word frequency list
<pre>
lines in the WORDFREQ.TXT list: 7727
Line 1,617 ⟶ 1,616:
puts "Overall: #{overall_plausible ? 'Plausible' : 'Implausible'}."
</lang>
{{out}}
Output:
<pre>
I before E when not preceded by C:
Line 1,715 ⟶ 1,714:
end func;</lang>
 
{{out}}
Output:
<pre>
Checking plausibility of "I before E except after C":
Anonymous user