I before E except after C: Difference between revisions

No edit summary
(6 intermediate revisions by 3 users not shown)
Line 2,701:
 
rule is not plausible
</pre>
 
 
=={{header|langur}}==
{{trans|Perl}}
<syntaxhighlight lang="langur">
val words = split("\n", readfile("./data/unixdict.txt")) -> rest
 
val print = impure fn(support, against) {
val ratio = support / against
writeln "{{support}} / {{against}} = {{ratio : r2}}:", (ratio < 2) * " NOT", " PLAUSIBLE"
return if(ratio >= 2: 1; 0)
}
 
val ks = fw/ei cei ie cie/
var cnt = {:}
 
for w in words {
for k in ks {
cnt[k; 0] += if(k in w: 1; 0)
}
}
 
var support = cnt'ie - cnt'cie
var against = cnt'ei - cnt'cei
 
var result = print(support, against)
result += print(cnt'cei, cnt'cie)
 
writeln "Overall:", (result < 2) * " NOT", " PLAUSIBLE\n"
</syntaxhighlight>
 
{{out}}
<pre>465 / 213 = 2.18: PLAUSIBLE
13 / 24 = 0.54: NOT PLAUSIBLE
Overall: NOT PLAUSIBLE
</pre>
 
Line 4,435 ⟶ 4,471:
(To be plausible, one word count must exceed another by 2 times)
</pre>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">program i_before_e_except_after_c;
init cie := 0, xie := 0, cei := 0, xei := 0;
 
dict := open("unixdict.txt", "r");
loop doing word := getline(dict); while word /= om do
classify(word);
end loop;
close(dict);
 
p :=
plausible("I before E when not preceded by C", xie, cie) and
plausible("E before I when preceded by C", cei, xei);
print;
print("I before E, except after C:" + (if p then "" else " not" end)
+ " plausible.");
 
proc classify(word);
if "ie" in word then
if "cie" in word then cie +:= 1;
else xie +:= 1;
end if;
elseif "ei" in word then
if "cei" in word then cei +:= 1;
else xei +:= 1;
end if;
end if;
end proc;
 
proc plausible(clause, feature, opposite);
p := 2 * feature > opposite;
print(clause + ":" + (if p then "" else " not" end) + " plausible.");
return p;
end proc;
end program;</syntaxhighlight>
{{out}}
<pre>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|Swift}}==
Line 4,498 ⟶ 4,575:
E before I when preceded by C is not plausable
I before E except after C is not plausible</pre>
 
 
=={{header|True BASIC}}==
Line 5,040 ⟶ 5,116:
 
Also there are seven words which fall into two categories and which have therefore been double-counted.
<syntaxhighlight lang="ecmascriptwren">import "io" for File
import "./pattern" for Pattern
import "./fmt" for Fmt
 
var yesNo = Fn.new { |b| (b) ? "yes" : "no" }
Line 5,122 ⟶ 5,198:
And the code and results for the 'stretch goal' which has just the one double-counted word:
 
<syntaxhighlight lang="ecmascriptwren">import "io" for File
import "./pattern" for Pattern
import "./fmt" for Fmt
 
var yesNo = Fn.new { |b| (b) ? "yes" : "no" }
Line 5,201 ⟶ 5,277:
Plausible overall: no
</pre>
 
 
=={{header|Yabasic}}==
1,007

edits