How to resolve the algorithm I before E except after C step by step in the Lasso programming language
How to resolve the algorithm I before E except after C step by step in the Lasso programming language
Table of Contents
Problem Statement
The phrase "I before E, except after C" is a widely known mnemonic which is supposed to help when spelling English words.
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt, check if the two sub-clauses of the phrase are plausible individually:
If both sub-phrases are plausible then the original phrase can be said to be plausible. Something is plausible if the number of words having the feature is more than two times the number of words having the opposite feature (where feature is 'ie' or 'ei' preceded or not by 'c' as appropriate).
As a stretch goal use the entries from the table of Word Frequencies in Written and Spoken English: based on the British National Corpus, (selecting those rows with three space or tab separated words only), to see if the phrase is plausible when word frequencies are taken into account.
Show your output here as well as your program.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm I before E except after C step by step in the Lasso programming language
Source code in the lasso programming language
local(cie,cei,ie,ei) = (:0,0,0,0)
local(match_ie) = regExp(`[^c]ie`)
local(match_ei) = regExp(`[^c]ei`)
with word in include_url(`http://wiki.puzzlers.org/pub/wordlists/unixdict.txt`)->asString->split("\n")
where #word >> `ie` or #word >> `ei`
do {
#word >> `cie`
? #cie++
#word >> `cei`
? #cei++
#match_ie->reset(-input=#word, -ignoreCase)&find
? #ie++
#match_ei->reset(-input=#word, -ignoreCase)&find
? #ei++
}
local(ie_plausible) = (#ie >= (2 * #ei))
local(cei_plausible) = (#cei >= (2 * #cie))
stdoutnl(
`The rule "I before E when not preceded by C" is ` +
(#ie_plausible ? '' | 'NOT-') + `PLAUSIBLE. There were ` +
#ie + ` examples and ` + #ei + ` counter-examples.`
)
stdoutnl(
`The rule "E before I when preceded by C" is ` +
(#cei_plausible ? `` | `NOT-`) + `PLAUSIBLE. There were ` +
#cei + ` examples and ` + #cie + ` counter-examples.`
)
stdoutnl(`Overall the rule is ` + (#ie_plausible and #cei_plausible ? `` | `NOT-`) + `PLAUSIBLE`)
You may also check:How to resolve the algorithm Interactive programming (repl) step by step in the Rust programming language
You may also check:How to resolve the algorithm Floyd's triangle step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Objeck programming language
You may also check:How to resolve the algorithm Window creation step by step in the Raku programming language
You may also check:How to resolve the algorithm Fractal tree step by step in the Seed7 programming language