59 lines
2.2 KiB
Text
59 lines
2.2 KiB
Text
$ include "seed7_05.s7i";
|
|
include "gethttp.s7i";
|
|
include "float.s7i";
|
|
|
|
const integer: PLAUSIBILITY_RATIO is 2;
|
|
|
|
const func boolean: plausibilityCheck (in string: comment, in integer: x, in integer: y) is func
|
|
result
|
|
var boolean: plausible is FALSE;
|
|
begin
|
|
writeln(" Checking plausibility of: " <& comment);
|
|
if x > PLAUSIBILITY_RATIO * y then
|
|
writeln(" PLAUSIBLE. As we have counts of " <& x <& " vs " <& y <&
|
|
" words, a ratio of " <& flt(x) / flt(y) digits 1 lpad 4 <& " times");
|
|
elsif x > y then
|
|
writeln(" IMPLAUSIBLE. As although we have counts of " <& x <& " vs " <& y <&
|
|
" words, a ratio of " <& flt(x) / flt(y) digits 1 lpad 4 <& " times does not make it plausible");
|
|
else
|
|
writeln(" IMPLAUSIBLE, probably contra-indicated. As we have counts of " <& x <& " vs " <& y <&
|
|
" words, a ratio of " <& flt(x) / flt(y) digits 1 lpad 4 <& " times");
|
|
end if;
|
|
plausible := x > PLAUSIBILITY_RATIO * y;
|
|
end func;
|
|
|
|
const func integer: count (in string: stri, in array string: words) is func
|
|
result
|
|
var integer: count is 0;
|
|
local
|
|
var integer: index is 0;
|
|
begin
|
|
for key index range words do
|
|
if pos(words[index], stri) <> 0 then
|
|
incr(count);
|
|
end if;
|
|
end for;
|
|
end func;
|
|
|
|
const proc: main is func
|
|
local
|
|
var array string: words is 0 times "";
|
|
var integer: cie is 0;
|
|
var integer: cei is 0;
|
|
var integer: not_c_ie is 0;
|
|
var integer: not_c_ei is 0;
|
|
begin
|
|
words := split(lower(getHttp("wiki.puzzlers.org/pub/wordlists/unixdict.txt")), "\n");
|
|
cie := count("cie", words);
|
|
cei := count("cei", words);
|
|
not_c_ie := count("ie", words) - cie;
|
|
not_c_ei := count("ei", words) - cei;
|
|
writeln("Checking plausibility of \"I before E except after C\":");
|
|
if plausibilityCheck("I before E when not preceded by C", not_c_ie, not_c_ei) and
|
|
plausibilityCheck("E before I when preceded by C", cei, cie) then
|
|
writeln("OVERALL IT IS PLAUSIBLE!");
|
|
else
|
|
writeln("OVERALL IT IS IMPLAUSIBLE!");
|
|
writeln("(To be plausible, one word count must exceed another by " <& PLAUSIBILITY_RATIO <& " times)");
|
|
end if;
|
|
end func;
|