name;Fred;Bob;Mary verb;throws;eats;chases;breaks article;a;the;this adj;big;red;small;blue do;wagon;ball;hot-dogHere, for example, the category word verb is associated with the List of exemplar words throws, eats, chases, and breaks.
Second, print a sorted version of this Map: the category words
must be printed in alphabetical order, one per line, each followed -on the
same line- by its List of exemplar words, which must also
printed in alphabetical order.
For the input file shown above, the program should print the following lines:
Map (sorted alphabetically by Category and by Exemplars)
adj can be replaced by [big, blue, red, small]
article can be replaced by [a, the, this]
do can be replaced by [ball, hot-dog, wagon]
name can be replaced by [Bob, Fred, Mary]
verb can be replaced by [breaks, chases, eats, throws]
If you finish this part correctly, you will at least be awarded 50% credit.
Third, read a line of category words from a file and build a sentence
(store it in a List) by selecting one random exemplar word for
each category word that is read.
All words are separated by one semi-colon character.
For example, the input file sentence.txt contains the following
line:
name;verb;article;adj;do
It indicates a name is to be followed by a verb, which is
followed by an article, etc.
Finally, print the generated sentence that was stored in the List of
exemplar words.
For example, with these input files the program might print the following line:
[Fred, chases, this, big, ball]
Of course, other sentences are just as likely to occur.
Running the program more than once should produce different results (try it),
but always using appropriate exemplar words selected from these
five category words.
Note that all the input files will be perfect: the right size, with no
misspellings, etc.
Enter Category Word file name: substitutions.txt Map (sorted alphabetically by Category then Word) adj can be replaced by [big, blue, red, small] article can be replaced by [a, the, this] do can be replaced by [ball, hot-dog, wagon] name can be replaced by [Bob, Fred, Mary] verb can be replaced by [breaks, chases, eats, throws] Enter sentence generation file name: sentence.txt Generated Sentence using the pattern: name;verb;article;adj;do [Fred, chases, this, big, ball]Of course, other sentences are just as likely to occur. Running the program more than once should produce different results (try it), but always using exemplar words selected from these five category words.