Random Sentence Generation

First, read a file of words one line at a time, building a Map whose key is the first word on the line and whose value is a List of all subsequent words on that line. All words are separated by one semi-colon character. For example, the input file substitutions.txt contains the following lines:
  name;Fred;Bob;Mary
  verb;throws;eats;chases;breaks
  article;a;the;this
  adjective;big;red;small;blue
  noun;wagon;ball;hot-dog
Here, 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.