Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that uses a pointer-based linked list to manage a spell checker/translator. ------------------------------------------------------------- 1) Your program must read in each word of the

Write a program that uses a pointer-based linked list to manage a spell checker/translator.

-------------------------------------------------------------

1) Your program must read in each word of the input file (hw8data.txt) and put each word into a separate link in a linked list (you *MUST* create a pointer-based linked list for this). For each word, you need to create a link that can hold that word precisely (i.e. the payload section must be sized specifically for each word). In other words, your structure for the linked list *CANNOT* look like this:

struct node { char word[n]; struct node *next;

}

It *MUST* look like this:

struct node { char *word; struct node *next;

}

The difference is that in the required form, there is no space allocated for the text. You will have to use malloc/calloc to allocate that space. However, you can use a static array of length 42 to read the words from the file.

-------------------------------------------------------------

2) You need to create a second word linked list that contains the correct word for each word in the hw8data.txt file. By correct, I mean a word that when it replaces the matching word in the hw8data.txt file the poem makes sense. We will call this the codex file.

3) Your program must read in each word of the codex file(hw8codex.txt) and put each word into a separate link in the linked list (you *MUST* create a pointer-based linked list for this). For each word, you need to create a link that can hold that word precisely (i.e. the payload section must be sized specifically for each word). In other words, the same rules apply for this linked list as in the first linked-list. Your structure for the linked list *MUST* look like this:

struct codex { char *word1; char *word2; struct codex *next; }

At this point you MUST have 2 linked lists.

4) You must traverse the hw8data linked list replacing each word with the translated word from the hw8codex linked list. In some cases the existing word will be removed

(e.g. "plane" "lee" may become "plainly" so "lee" must be removed from the linked list). In other cases the codex word may be longer or shorter than the original word, in these cases the original link must be deleted and replaced with a new link. This guarantees that the memory consumption will be optimal/minimal. You can do this with every replaced word if you like. You **CANNOT** simply create a third linked list, you are only allowed to have 2 linked lists, in total.

5)You must traverse the hw8data linked list displaying the corrected poem. The display MUST have the same exact format as the hw8data.txt file. This means you will have to keep track of puncuation marks and line feeds.

-------------------------------------------------------------

6) Create seperate functions that insert into the two linked lists(LIST_INSERT_POEM() and LIST_INSERT_CODEX()). Create a function that corrects that poem (LIST_CORRECT()). Create a function to display/traverse the corrected poem (LIST_DISPLAY()). Create seperate functions that free the two linked lists (LIST_FREE_POEM() and LIST_FREE_CODEX()).

hw8data is

Eye have a spelling chequer, It came with my Pea Sea. It plane lee marks four my revue, Miss Steaks I can knot sea. Eye strike the quays and type a whirred, And weight four it two say, Weather eye am write oar wrong, It tells me straight aweigh. Eye ran this poem threw it, Your shore real glad two no. Its vary polished in its weigh. My chequer tolled me sew. A chequer is a bless thing, It freeze yew lodes of thyme. It helps me right all stiles of righting, And aides me when eye rime. Each frays come posed up on my screen, Eye trussed too bee a joule. The chequer pours over every word, Two cheque sum spelling rule.

hw8codex.txt

Eye I eye I chequer checker Pea P Sea C plane plainly lee skip four for revue review Miss Mistakes Steaks skip knot not sea see quays keys whirred word weight wait Two To two to Weather Whether write right oar or aweigh away threw through Your You're shore sure two to no know Its It's vary very weigh way tolled told sew so bless blessed freeze frees yew you lodes loads thyme time right write stiles styles righting writing aides aids rime rhyme frays phrase come composed posed skip trussed trusted too to bee be joule jewel cheque check sum some

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago

Question

6. What data will she need?

Answered: 1 week ago