SMS language is a term for the abbreviations and slang commonly used with mobile phone text messaging. Early mobile phone messaging encouraged users to use abbreviations because i) text entry was difficult, requiring multiple key presses on a small keypad to generate each letter, ii) messages were limited to a maximal number of characters, and iii) operators were charging a cost per letter.
Once SMS language became popular, it took on a life of its own and was often used outside of its original context. At its peak, it was the cause of vigorous debate about its potentially detrimental effect on literacy, but with the advent of alphabetic keyboards on smartphones its use — and the controversies surrounding it — have receded.
Some people compress text messages by replacing doubled letters with single letters and by retaining only those vowels that begin a word. Note that the order in which these two operations are executed is important: first removal of duplicates and then removal of vowels. Your task is to implement these operations, such that they can be used to abbreviate text messages. To do so, you have to implement the following four functions that each take a single string argument:
A function removeDuplicates that returns the string resulting from reduction of successive repetitions of the same character to the first occurrence of the character. No distinction should be made between upper case and lower case letters in comparing characters.
A function removeVowels that returns the string after removal of all vowels. However, the first character of the string is always retained, even if it is a vowel. As vowels, we consider the letters a, e, i, o and u, both in their upper case and lower case versions.
A function txtWord that returns the string resulting from successively applying the functions removeDuplicates and removeVowels to the given string.
A function txtSentence that returns the string resulting from applying the function txtWord to each word in the given string. In this, words are defined as the longest possible uninterrupted succession of letters. All characters that are not part of a word are simply retained in the sentence.
>>> removeDuplicates('bookkeeper')
'bokeper'
>>> removeDuplicates('Aardvark')
'Ardvark'
>>> removeDuplicates('eELGRASS')
'eLGRAS'
>>> removeVowels('bookkeeper')
'bkkpr'
>>> removeVowels('Aardvark')
'Ardvrk'
>>> removeVowels('eELGRASS')
'eLGRSS'
>>> txtWord('Some')
'Sm'
>>> txtWord('people')
'ppl'
>>> txtWord('compress')
'cmprs'
>>> txtWord('text')
'txt'
>>> txtWord('messages')
'msgs'
>>> txtSentence('And now for something completely different!')
'And nw fr smthng cmpltly dfrnt!'
>>> txtSentence('Some people compress text messages by replacing doubled letters with single letters and by retaining only those vowels that begin a word.')
'Sm ppl cmprs txt msgs by rplcng dbld ltrs wth sngl ltrs and by rtnng only ths vwls tht bgn a wrd.'