How to resolve the algorithm I before E except after C step by step in the uBasic/4tH programming language
How to resolve the algorithm I before E except after C step by step in the uBasic/4tH 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 uBasic/4tH programming language
Source code in the ubasic/4th programming language
If Set(a, Open ("unixdict.txt", "r")) < 0 Then Print "Cannot open \qunixdict.txt\q" : End
x = Set (y, Set (p, Set (q, 0)))
Do While Read (a)
w = Tok(0)
If FUNC(_Search(w, "cei")) > -1 Then x = x + 1
If FUNC(_Search(w, "cie")) > -1 Then y = y + 1
If FUNC(_Search(w, "ie")) > -1 Then p = p + 1
If FUNC(_Search(w, "ei")) > -1 Then q = q + 1
Loop
Print "The plausibility of 'I before E when not preceded by C' is ";
Print Show (Iif (p>(q+q), "True", "False"))
Print "The plausibility of 'E before I when preceded by C' is ";
Print Show (Iif (x>(y+y), "True", "False"))
Print "The plausibility of the phrase 'I before E except after C' is ";
Print Show (Iif ((x>(y+y))*(p>(q+q)), "True", "False"))
Close a
End
_Search
Param (2)
Local (1)
For c@ = 0 to Len (a@) - Len (b@)
If Comp(Clip(Chop(a@,c@),Len(a@)-c@-Len(b@)),b@)=0 Then Unloop : Return (c@)
Next
Return (-1)
You may also check:How to resolve the algorithm Lucas-Lehmer test step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Date manipulation step by step in the Frink programming language
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Additive primes step by step in the Red programming language
You may also check:How to resolve the algorithm Morse code step by step in the C++ programming language