name;Fred;Bob;Mary verb;throws;eats;chases;breaks article;a;the;this adjective;big;red;small;blue noun;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 be
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)
adjective
can be replaced by [big, blue, red, small]
article can be replaced by [a, the, this]
nouncan be replaced by [ball, hot-dog, wagon]
name can be replaced by [Bob, Fred, Mary]
verb can be replaced by [breaks, chases, eats, throws]
Third, read a line of category words from a file and build a sentence by selecting one random exemplar.
For example, the input file sentence.txt contains the following line:
name;verb;article;adjective;noun
It indicates a name is to be followed by a verb, which is followed by an article, etc.