I before E except after C: Difference between revisions

Added Julia language
m (typo)
(Added Julia language)
Line 1,147:
-- the rule "I before E when not preceded by C" is plausible
as ratio = 464/217 ~ 214%</lang>
 
=={{header|Julia}}==
<lang julia># v0.0.6
 
open("unixdict.txt") do txtfile
rule1, notrule1, rule2, notrule2 = 0, 0, 0, 0
for word in eachline(txtfile)
# "I before E when not preceded by C"
if ismatch(r"ie"i, word)
if ismatch(r"cie"i, word)
notrule1 += 1
else
rule1 += 1
end
end
# "E before I when preceded by C"
if ismatch(r"ei"i, word)
if ismatch(r"cei"i, word)
rule2 += 1
else
notrule2 += 1
end
end
end
 
print("Plausibility of \"I before E when not preceded by C\": ")
println(rule1 > 2 * notrule1 ? "PLAUSIBLE" : "UNPLAUSIBLE")
print("Plausibility of \"E before I when preceded by C\":")
println(rule2 > 2 * notrule2 ? "PLAUSIBLE" : "UNPLAUSIBLE")
end</lang>
 
{{out}}
<pre>Plausibility of "I before E when not preceded by C": PLAUSIBLE
Plausibility of "E before I when preceded by C":UNPLAUSIBLE</pre>
 
=={{header|Kotlin}}==
Line 1,600 ⟶ 1,634:
sub plausible($good, $bad, $msg) {
if $good > 2*$bad {
say "$msg: PLAUSIBLE ($good vs. $bad ✘)";
return True;
} else {
say "$msg: NOT PLAUSIBLE ($good vs. $bad ✘)";
return False;
}
Line 1,617 ⟶ 1,651:
{{out}}
 
<pre>I before E when not preceded by C: PLAUSIBLE (466 vs. 217 ✘)
E before I when preceded by C: NOT PLAUSIBLE (13 vs. 24 ✘)
I before E except after C: NOT PLAUSIBLE</pre>
 
Line 1,686 ⟶ 1,720:
sub plausible($good, $bad, $msg) {
if $good > 2*$bad {
say "$msg: PLAUSIBLE ($good vs. $bad ✘)";
return True;
} else {
say "$msg: NOT PLAUSIBLE ($good vs. $bad ✘)";
return False;
}
Line 1,704 ⟶ 1,738:
 
{{out}}
<pre>I before E when not preceded by C: NOT PLAUSIBLE (8222 vs. 4826 ✘)
E before I when preceded by C: NOT PLAUSIBLE (327 vs. 994 ✘)
I before E except after C: NOT PLAUSIBLE</pre>
 
Anonymous user