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

Source code in the 11l programming language

V PLAUSIBILITY_RATIO = 2

F plausibility_check(comment, x, y)
   print("\n  Checking plausibility of: #.".format(comment))
   I x > :PLAUSIBILITY_RATIO * y
      print(‘    PLAUSIBLE. As we have counts of #. vs #., a ratio of #2.1 times’.format(x, y, Float(x) / y))
   E
      I x > y
         print(‘    IMPLAUSIBLE. As although we have counts of #. vs #., a ratio of #2.1 times does not make it plausible’.format(x, y, Float(x) / y))
      E
         print(‘    IMPLAUSIBLE, probably contra-indicated. As we have counts of #. vs #., a ratio of #2.1 times’.format(x, y, Float(x) / y))
   R x > :PLAUSIBILITY_RATIO * y

F simple_stats()
   V words = File(‘unixdict.txt’).read().split("\n")
   V cie = Set(words.filter(word -> ‘cie’ C word)).len
   V cei = Set(words.filter(word -> ‘cei’ C word)).len
   V not_c_ie = Set(words.filter(word -> re:‘(^ie|[^c]ie)’.search(word))).len
   V not_c_ei = Set(words.filter(word -> re:‘(^ei|[^c]ei)’.search(word))).len
   R (cei, cie, not_c_ie, not_c_ei)

F print_result(cei, cie, not_c_ie, not_c_ei)
   I (plausibility_check(‘I before E when not preceded by C’, not_c_ie, not_c_ei) & plausibility_check(‘E before I when preceded by C’, cei, cie))
      print("\nOVERALL IT IS PLAUSIBLE!")
   E
      print("\nOVERALL IT IS IMPLAUSIBLE!")
   print(‘(To be plausible, one count must exceed another by #. times)’.format(:PLAUSIBILITY_RATIO))

print(‘Checking plausibility of "I before E except after C":’)
V (cei, cie, not_c_ie, not_c_ei) = simple_stats()
print_result(cei, cie, not_c_ie, not_c_ei)

  

You may also check:How to resolve the algorithm 4-rings or 4-squares puzzle step by step in the Scala programming language
You may also check:How to resolve the algorithm Doubly-linked list/Element insertion step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Find the last Sunday of each month step by step in the ALGOL W programming language
You may also check:How to resolve the algorithm Möbius function step by step in the Python programming language
You may also check:How to resolve the algorithm Meissel–Mertens constant step by step in the ALGOL 68 programming language