RosettaCodeData/Task/I-before-E-except-after-C/PL-I/i-before-e-except-after-c.pli
2023-07-01 13:44:08 -04:00

49 lines
1.2 KiB
Text

iBeforeE: procedure options(main);
declare dict file;
open file(dict) title('unixdict.txt');
on endfile(dict) go to report;
declare (cie, xie, cei, xei) fixed;
declare word char(32) varying;
cie = 0;
xie = 0;
cei = 0;
xei = 0;
do while('1'b);
get file(dict) list(word);
if index(word, 'ie') ^= 0 then
if index(word, 'cie') ^= 0 then
cie = cie + 1;
else
xie = xie + 1;
if index(word, 'ei') ^= 0 then
if index(word, 'cei') ^= 0 then
cei = cei + 1;
else
xei = xei + 1;
end;
report:
close file(dict);
put skip list('CIE:', cie);
put skip list('xIE:', xie);
put skip list('CEI:', cei);
put skip list('xEI:', xei);
declare (ieNotC, eiC) bit;
ieNotC = xie * 2 > cie;
eiC = cei * 2 > xei;
put skip list('I before E when not preceded by C:');
if ^ieNotC then put list('not');
put list('plausible.');
put skip list('E before I when preceded by C:');
if ^eiC then put list('not');
put list('plausible.');
put skip list('I before E, except after C:');
if ^(ieNotC & eiC) then put list('not');
put list('plausible.');
end iBeforeE;