I before E except after C: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add CLU) |
Not a robot (talk | contribs) (Add Draco) |
||
Line 1,581: | Line 1,581: | ||
'I before E when not preceded by C' is plausible with evidence 2.147465 |
'I before E when not preceded by C' is plausible with evidence 2.147465 |
||
'E before I when preceded by C' is not plausible with evidence 0.541667</pre> |
'E before I when preceded by C' is not plausible with evidence 0.541667</pre> |
||
=={{header|Draco}}== |
|||
<lang draco>\util.g |
|||
/* variables to hold totals for each possibility */ |
|||
word cie, xie, cei, xei; |
|||
/* classify a word and add it to the proper total */ |
|||
proc nonrec classify(*char w) void: |
|||
if CharsIndex(w, "ie") /= -1 then |
|||
if CharsIndex(w, "cie") /= -1 |
|||
then cie := cie + 1 |
|||
else xie := xie + 1 |
|||
fi |
|||
elif CharsIndex(w, "ei") /= -1 then |
|||
if CharsIndex(w, "cei") /= -1 |
|||
then cei := cei + 1 |
|||
else xei := xei + 1 |
|||
fi |
|||
fi |
|||
corp |
|||
/* see if a clause is plausible */ |
|||
proc nonrec plausible(*char clause; word match, nomatch) bool: |
|||
bool p; |
|||
p := 2*match > nomatch; |
|||
writeln(clause, ": ", if p then "" else "not " fi, "plausible."); |
|||
p |
|||
corp |
|||
proc nonrec main() void: |
|||
file() dict_file; |
|||
channel input text dict_ch; |
|||
[256] char line; |
|||
bool p; |
|||
cie := 0; |
|||
xie := 0; |
|||
cei := 0; |
|||
xei := 0; |
|||
/* read every word */ |
|||
open(dict_ch, dict_file, "unixdict.txt"); |
|||
while readln(dict_ch; &line[0]) do |
|||
classify(&line[0]) |
|||
od; |
|||
close(dict_ch); |
|||
/* print statistics */ |
|||
writeln("CIE: ", cie:5); |
|||
writeln("xIE: ", xie:5); |
|||
writeln("CEI: ", cei:5); |
|||
writeln("xEI: ", xei:5); |
|||
/* see if the propositions are plausible */ |
|||
p := plausible("I before E when not preceded by C", xie, cie); |
|||
p := plausible("E before I when preceded by C", cei, xei) and p; |
|||
writeln("I before E except after C: ", |
|||
if p then "" else "not " fi, |
|||
"plausible.") |
|||
corp</lang> |
|||
{{out}} |
|||
<pre>CIE: 24 |
|||
xIE: 465 |
|||
CEI: 13 |
|||
xEI: 209 |
|||
I before E when not preceded by C: plausible. |
|||
E before I when preceded by C: not plausible. |
|||
I before E except after C: not plausible.</pre> |
|||
=={{header|Elixir}}== |
=={{header|Elixir}}== |