Changing Gender
July 26, 2016
The culture wars have my head spinning so fast that I need a computer to help me out. One day I might say “He is my brother.” and the very next day, speaking about the same person, say “She is my sister.”
Your task is to write a program that changes the gender of the words in a string. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Similar solution to yours but in Perl… I create the map in three parts – for those words for which you can only map one way (actually they have an alternative mapping elsewhere) – those words for which I can pluralise with “s” and those I can’t…
By extending the map with the ucfirst and uc versions of the strings – I can then just use a “join map split” to do the translation.