How to resolve the algorithm I before E except after C step by step in the Yabasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm I before E except after C step by step in the Yabasic 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 Yabasic programming language

Source code in the yabasic programming language

open "unixdict.txt" for reading as #1

repeat
    line input #1 pal$
    if instr(pal$, "ie") then 
		if instr(pal$, "cie") then CI = CI + 1 else XI = XI + 1 : fi
	endif
    if instr(pal$, "ei") then 
		if instr(pal$, "cei") then CE = CE + 1 else XE = XE + 1 : fi
	endif
until eof(1)
close #1

print "CIE: ", CI
print "xIE: ", XI
print "CEI: ", CE
print "xEI: ", XE
print "\nI before E when not preceded by C: ";
if 2 * XI <= CI then print "not "; : fi
print "plausible."
print "E before I when preceded by C: ";
if 2 * CE <= XE then print "not "; : fi
print "plausible."
end

  

You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the PHP programming language
You may also check:How to resolve the algorithm Longest common subsequence step by step in the Tcl programming language
You may also check:How to resolve the algorithm Conditional structures step by step in the XPL0 programming language
You may also check:How to resolve the algorithm UTF-8 encode and decode step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Fōrmulæ programming language