10/3 Clarifications shown in blue
I love many IKEA products, and admire the design of their products. Sometimes, though, I've noticed that some of their product names sound funny in English, or have a possible unfortunate meaning. Consider the following, some extracted from this buzzfeed post of 24 unfortunate IKEA names:
Too much wine might make you:
This is NOT my favorite lamp
I had a good workout at the gym,
and now I'm really:
I slipped in the shower, and now
I have a:
See also Simon Gilmore's video where he annoys his girlfriend with puns at IKEA. Of course if you are Swedish, this whole thing is ridiculous. See the IKEA dictionary that explains what the words really mean.
(20 points) Display each IKEA product name that can be found in the English dictionary.
The full list of the 1764 unique IKEA product words is in IKEAwords.txt (which was extracted from here). This file has been put into alphabetical order, so you can (and should) use binary search with it.
To see if words exist in English, use the 40,444 word English dictionary dictionary.txt, where the longest word has 21 characters. To lookup a word in the dictionary consider using binary search, as illustrated in binarySearch.c
Print out each word that is found.
(15 points) In addition to providing your output from stage 1, now also take some text file called inputfile.txt and capitalize each word that also matches an IKEA product name, displaying the resulting text. E.g. if inputfile.txt contained the word "cider", then that matches IKEA word CIDER, and so CIDER (in all capital letters) would be printed out. For the words that don't match, print them out as-is, with a single space between them. You don't need to number them or count them or print out the punctuation or line breaks from the original file. In this way all words from inputfile.txt get echoed to the screen, with only the IKEA matching words being capitalized. Since you don't know how many words there are in inputfile.txt you should read from that file one word at a time, handling that word as you go.
(15 points) As humans we can look at a word and ignore or substitute characters. In addition to your output from stage 2, now get your program to try to match each inputfile.txt word with all IKEA product names, where the match could now be up to 1 character different. If the letters in a word match exactly (except for the upper/lower case difference), then it should be capitalized and printed out without any further changes. If a word doesn't match exactly, then possible character changes should be handled in the order shown below. Once an IKEA match is found, the matching word should be printed out in all upper-case and no further work should be done with that word. In other words, if a match is found when deleting a character, then you would not try the subsequent steps of substituting or inserting a character, or checking for a substring.
Delete a character
E.g. The word "round" with the 'o' deleted matches IKEA word RUND. If your input file had the word "round" in it, then your program would instead display RUND.
Substitute a character
E.g. The word "call" with the 'c' changed to a 'j' matches IKEA word JALL. If your input file had the word "call" in it, then your program would instead display JALL.
Insert a new character
E.g. The word "bags" plus an extra 'I' matches IKEA word BAGIS. If your input file had the word "bags" in it, then your program would instead display BAGIS.
Match a substring
E.g. The word "back" is a substring of the IKEA word BADBACK. If your input file had the word "back" in it, then your program would instead display BADBACK.
If a word doesn't match in any of the above cases, again just print out the word in lower-case, as you did in the previous stage of the program.
(5 points) Extend stage 3 so that it does the same thing, but instead of deleting, substituting or inserting just a single character, do it for up to 3 characters. (You don't need to do the substring search for each of those.) This should be in addition to your output for stage 3. Because this can take an incredibly long time for longer words, do this incrementally:
Note that if the original word matches you will not do any of this work and the word will be printed out in all capital letters. You should have already checked delete/substitute/insert for one character in the previous stage. If the word matched at any of those points, it would be printed out in all capital letters and you are done with it.
If so far for a word there was no match, next do delete/substitute/insert (in that order) for two characters. If a word matches print it out in all capital letters and you are done with that word.
If you still don't have a match, lastly try delete/substitute/insert this time for three characters, printing it out in all capital letters if you find a match.
If there is no match, again print out the word in lower-case.