I before E except after C: Difference between revisions

Content added Content deleted
No edit summary
Line 2,706: Line 2,706:
=={{header|langur}}==
=={{header|langur}}==
{{trans|Perl}}
{{trans|Perl}}
<syntaxhighlight lang="langur">val .words = rest split "\n", readfile "./data/unixdict.txt"
<syntaxhighlight lang="langur">
val words = split("\n", readfile("./data/unixdict.txt")) -> rest


val .print = impure fn(.support, .against) {
val print = impure fn(support, against) {
val .ratio = .support / .against
val ratio = support / against
writeln "{{.support}} / {{.against}} = {{.ratio : r2}}:", if(.ratio < 2: " NOT"; ""), " PLAUSIBLE"
writeln "{{support}} / {{against}} = {{ratio : r2}}:", (ratio < 2) * " NOT", " PLAUSIBLE"
return if(.ratio >= 2: 1; 0)
return if(ratio >= 2: 1; 0)
}
}


val .keys = fw/ei cei ie cie/
val ks = fw/ei cei ie cie/
var .count = {:}
var cnt = {:}


for .w in .words {
for w in words {
for .k in .keys {
for k in ks {
.count[.k; 0] += if(.k in .w: 1; 0)
cnt[k; 0] += if(k in w: 1; 0)
}
}
}
}


var .support = .count'ie - .count'cie
var support = cnt'ie - cnt'cie
var .against = .count'ei - .count'cei
var against = cnt'ei - cnt'cei


var .result = .print(.support, .against)
var result = print(support, against)
.result += .print(.count'cei, .count'cie)
result += print(cnt'cei, cnt'cie)


writeln "Overall:", if(.result < 2: " NOT"; ""), " PLAUSIBLE\n"
writeln "Overall:", (result < 2) * " NOT", " PLAUSIBLE\n"
</syntaxhighlight>
</syntaxhighlight>