I before E except after C: Difference between revisions

Add ed example
(added langur language example)
(Add ed example)
 
(4 intermediate revisions by one other user not shown)
Line 1,840:
E before I when preceded by C: not plausible.
I before E except after C: not plausible.</pre>
 
=={{header|ed}}==
 
There are two files, one per hypothesis.
 
<syntaxhighlight lang="sed">
# i-before-e.ed
H
# Remove all the non-rule-related words
v/(ie|ei)/d
# Replace the occurences with one-letter markers
g/ei/s/.*/e/
g/ie/s/.*/i/
,j
# Remove 1 occurence of e (alternative) per two i (null)
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
s/eii//g
s/iie//g
# Check whether there are more i's in the output (null hypothesis true) or not
,p
Q
</syntaxhighlight>
 
<syntaxhighlight lang="sed">
# e-before-i-with-c.ed
H
# Remove all the non-rule-related words
v/(cie|cei)/d
# Replace the occurences with one-letter markers
g/ei/s/.*/e/
g/ie/s/.*/i/
,j
# Remove 1 occurence of i (alternative) per two e (null)
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
s/eei//
s/iee//
# Check whether there are more e's in the output (null hypothesis true) or not
,p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ cat i-before-e.ed | ed -lEGs unixdict.txt
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiieeeeeeeeeeiiiiiii</pre>
 
Has more i's so the "i before e" hypothesis is plausible.
 
<pre>$ cat e-before-i-with-c.ed | ed -lEGs unixdict.txt
ieiiieiieiiiiieiiiiiiiiie</pre>
 
Has more i's, so the "e before i when preceded by c" is not plausible.
Thus, the whole rule is not plausible.
 
=={{header|Elixir}}==
Line 2,706 ⟶ 2,796:
=={{header|langur}}==
{{trans|Perl}}
<syntaxhighlight lang="langur">val .words = rest split "\n", readfile "./data/unixdict.txt"
val words = split("\n", readfile("./data/unixdict.txt")) -> rest
 
val .print = impure fn(.support, .against) {
val .ratio = .support / .against
writeln "{{.support}} / {{.against}} = {{.ratio : r2}}: ", if(.ratio < 2:) "NOT* "; NOT", "), "PLAUSIBLE"
return if(.ratio >= 2: 1; 0)
}
 
val .keysks = fw/ei cei ie cie/
var .countcnt = {:}
 
for .w in .words {
for .k in .keysks {
.countcnt[.k; 0] += if(.k in .w: 1; 0)
}
}
 
var .support = .countcnt'ie - .countcnt'cie
var .against = .countcnt'ei - .countcnt'cei
 
var .result = .print(.support, .against)
.result += .print(.countcnt'cei, .countcnt'cie)
 
writeln "Overall: ", if(.result < 2:) "NOT* "; NOT", "), "PLAUSIBLE\n"</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
<pre>465 / 213 = 2.18: PLAUSIBLE
13 / 24 = 0.54: NOT PLAUSIBLE
Overall: NOT PLAUSIBLE
</pre>
 
 
=={{header|Lasso}}==
110

edits