5. Solutions: Using sed to implement regular past tense inflection

Fetch and name the verb list:

  wget http://www.inf.ed.ac.uk/teaching/courses/inf1-cg/labs/lab4/verbs.txt
  VERBS=verbs.txt

Produce the morphological rule named "pasttense".

  alias pasttense='sed "s/$/ d/g"'
  pasttense $VERBS

You should get the same list as before, where the suffix "d" has been added to each verb in the file.

The first of these, which we'll call 'VBanaptyxis', can be implemented with the following sed command:

  alias VBanaptyxis='sed "s/t d/t ah d/g; s/d d/d ah d/g "'

We can add this to the past tense forms morphological rule from the previous section as follows:

  pasttense $VERBS | VBanaptyxis

The second phonological rule, called 'VBdevoicing', can be implemented with the following sed command:

  alias VBdevoicing='sed "s/p d/p t/g; s/t d/t t/g; s/k d/k t/g; s/s d/s t/g"'

Note that we can create more complex sed commands by combining them using the semi-colon ';'.

  pasttense $VERBS | VBdevoicing

Finally, we can combine the two phonological rules to run one after the other:

  pasttense $VERBS | VBanaptyxis | VBdevoicing