British author Sarah Caudwell wrote four mystery novels without revealing the gender of main character Hilary Tamar.

Sarah Caudwell
Pencil sketch of Sarah Caudwell.

Like Caudwell herself, sleuth Hilary Tamar taught law at Oxford and was witty, erudite, and incisive. In the four novels — Thus Was Adonis Murdered, The Shortest Way to Hades, The Sirens Sang of Murder, and The Sybil in Her Grave — Tamar acts as mentor to four barristers in "legal whodunits" that revolve around the intricacies of the British legal system. Tamar, who serves as both storyteller and detective, writes in the first person, often communicates with the other characters by letter, and is addressed directly when present:

"So you see, Hilary," said Selena, "no one's on holiday. Except Julia, of course. She should be in Venice by now."

"Julia?" I said, much astonished. "You haven't let Julia go off on her own to Venice, surely?"

"Am I," asked Selena, "Julia's keeper?"

"Yes," I said, rather severely, for her attitude seemed to me irresponsible.

"Others speak to Hilary or use the name — one never knows for sure whether Hilary is woman or man," notes Sally McConnell-Ginet in Greville G. Corbett's The Expression of Gender. "Caudwell manages this so skillfully that people reading the novels do not always notice the absence of definitive gendering of Hilary: they sometimes mentally provide she or he on the basis of whichever familiar gender assumptions happen to attract their attention."

"Very few people seemed to notice that there was any doubt," Caudwell said. "Usually they referred to Hilary as certainly female or certainly male. It's now mentioned in the jacket copy and, having been tipped off, readers become very angry at me for not resolving it at the end of the book." But she had determined never to reveal Tamar's gender. "I think Hilary is sort of a quintessential Oxford don," she said. "I don't really regard Oxford dons as being determined by gender."

This never bothered her fans, who love the books for their brilliance and humor. Writing in The New York Times Book Review, Newgate Callendar praised Caudwell's "polished, stylized prose," "a kind of English that has not been around since the days of Oscar Wilde." Robert Bork once said, "In my opinion, there can't be too many Sarah Caudwell novels." Alas, there are only four — she passed away in 2000.

Assignment

Your task is to change gender of the words in a given sentence, where words are defined as the longest sequence of consecutive letters. To do this, you proceed as follows:

All three function must assume that all words that occur in the given dictionary (both the keys and their associated values) only contain lowercase letters. In addition, they may also assume that, as is the case for the keys, also all values in the given dictionary differ from each other. When looking up words in a dictionary, the function should not make any distinction between uppercase and lowercase letters.

Example

>>> translations = {'he':'she', 'brother':'sister'}
>>> translate('he', translations)
'she'
>>> translate('HE', translations)
'SHE'
>>> translate('He', translations)
'She'
>>> translate('brother', translations)
'sister'
>>> translate('my', translations)
'my'

>>> sexChange('He is my brother.', translations)
'She is my sister.'

>>> undoSexChange('She is my sister.', translations)
'He is my brother.'