3. Solutions: Using sed to implement morphological rules

The first phonological rule, called 'anaptyxis', can be implemented with the following sed command:

      alias anaptyxis='sed "s/s z/s ah z/g"'
    

We can add this to the plural morphological rule from the previous section as follows:

      plural $NOUNS | anaptyxis
    

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

      alias devoicing='sed "s/p z/p s/g; s/t z/t s/g; s/k z/k s/g; s/s z/s s/g"'
    

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

      plural $NOUNS | devoicing
    

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

      plural $NOUNS | anaptyxis | devoicing
    

To capture irregular nouns like 'goose' and 'sheep', we can create a specific rule: irregulars where we include the words that do not follow a rule

      alias irregulars='sed "s/sh iy p s/sh iy p/; s/g uw s ah z/g iy s/"'
      plural $NOUNS | anaptyxis | devoicing | irregulars