Program in python 3.x. Please add comments in order to increase understanding of
ID: 3872212 • Letter: P
Question
Program in python 3.x. Please add comments in order to increase understanding of the solution. (If possible try to make the code as simple as possible). Thanks
Texting on portable devices has developed a set of abbreviations due to the neces- sary brevity of text messages. Create a dictionary of texting abbreviations and use it to write functions that can translate to and from English. Use all the abbrevia- tions found in this link under List of Text Messaging & SMS Abbreviations (http://www.connexin.net/internet-acronyms.html For example: "L8R" translates to "Later", and vice-versa. Write a program where the user can choose to type text or an abbreviation, and the program will traslate the input using the dictionary.Explanation / Answer
dic_abbre_to_english = {u'MTFBWY': u'May the Force be with You', u'JTLYK': u'Just to Let You Know', u'PROP(S)': u'Proper Respect / Proper Recognition', u'ASAP': u'As Soon as Possible', u'KMN': u'Kill Me Now', u'W8': u'Wait', u'POS': u'Parent over Shoulder', u'ALAP': u'As Late as Possible', u'FC': u'Fingers Crossed', u'NSFW': u'Not Safe for Work', u'IDK': u"I Don't Know", u'NIMBY': u'Not in my Backyard', u'TMI': u'Too Much Information', u'NAZ': u'Name, Address, ZIP', u'MYOB': u'Mind Your Own Business', u'CTN': u'Cannot talk now', u'KFY': u'Kiss for You', u'PAL': u'Parents are Listening', u'IDC': u"I Don't Care", u'JC': u'Just Checking', u'RU': u'Are You', u'RN': u'Right Now', u'NM': u'Never Mind / Nothing Much', u'CYT': u'See You Tomorrow', u'SO': u'Significant Other', u'EOD': u'End of Day', u'J/K ': u'Just Kidding', u'AEAP': u'As Early as Possible', u'E123': u'Easy as 1, 2, 3', u'NC': u'No Comment', u'ILU / ILY': u'I Love You', u'N-A-Y-L': u'In a While', u'2nte': u'Tonight', u'SMIM': u'Send Me an Instant Message', u'NP': u'No Problem', u'OATUS': u'On a totally Unrelated Subject', u'PIR': u'Parent in Room', u'B4YKI': u'Before You Know it', u'C-P': u'Sleepy', u'FOAF': u'Friend of a Friend', u'HAK': u'Hugs and Kisses', u'CUS': u'See You Soon', u'BFF': u'Best Friends, Forever', u'BM&Y': u'Between Me and You', u'SITD': u'Still in the Dark', u'P911': u'Parent Alert', u'MoF': u'Male or Female', u'SLAP': u'Sounds like a Plan', u'NTIM': u'Not that it Matters', u'OIC': u'Oh, I See', u'XOXOXOX': u'Hugs, Kisses, ...', u'GR8 ': u'Great', u'IMU': u'I Miss You', u'WYCM': u'Will You Call Me?', u'NVM': u'Never Mind', u'QT': u'Cutie', u'PAW': u'Parents are Watching', u'2moro ': u'Tomorrow', u'OTL': u'Out to Lunch', u'F2F': u'Face to Face', u'BRT': u'Be right There', u'BTAM': u'Be that as it May', u'CWOT': u'Complete Waste of Time', u'WYWH': u'Wish You Were Here', u'SEP': u"Someone else's Problem", u'KPC': u'Keeping Parents Clueless', u'OMW': u'On My Way', u'L8R ': u'Later', u'B3': u'Blah, Blah, Blah', u'OTP': u'On the Phone', u'IRL': u'In Real Life', u'EM?': u'Excuse Me?', u'ASL': u'Age / Sex / Location?', u'WB': u'Welcome Back', u'BRB': u'Be right Back', u'UR': u'Your / You are'}
dic_english_to_abbre = {u'In a While': u'N-A-Y-L', u'Sounds like a Plan': u'SLAP', u'Name, Address, ZIP': u'NAZ', u'Your / You are': u'UR', u'Will You Call Me?': u'WYCM', u'As Soon as Possible': u'ASAP', u'Cannot talk now': u'CTN', u'Too Much Information': u'TMI', u'Send Me an Instant Message': u'SMIM', u'Friend of a Friend': u'FOAF', u'Never Mind / Nothing Much': u'NM', u'Complete Waste of Time': u'CWOT', u'Just to Let You Know': u'JTLYK', u'Significant Other': u'SO', u'Hugs, Kisses, ...': u'XOXOXOX', u'Parent over Shoulder': u'POS', u'Keeping Parents Clueless': u'KPC', u'Excuse Me?': u'EM?', u'Wish You Were Here': u'WYWH', u'May the Force be with You': u'MTFBWY', u'Not Safe for Work': u'NSFW', u'Are You': u'RU', u'On a totally Unrelated Subject': u'OATUS', u'Fingers Crossed': u'FC', u'Parents are Watching': u'PAW', u'Between Me and You': u'BM&Y', u'Right Now': u'RN', u'Kiss for You': u'KFY', u'Easy as 1, 2, 3': u'E123', u'Oh, I See': u'OIC', u'On the Phone': u'OTP', u'Before You Know it': u'B4YKI', u'Best Friends, Forever': u'BFF', u'Not in my Backyard': u'NIMBY', u'I Miss You': u'IMU', u'Mind Your Own Business': u'MYOB', u'Face to Face': u'F2F', u'Wait': u'W8', u'Great': u'GR8 ', u'Welcome Back': u'WB', u'As Late as Possible': u'ALAP', u'Later': u'L8R ', u'End of Day': u'EOD', u'Parents are Listening': u'PAL', u'As Early as Possible': u'AEAP', u'Be right There': u'BRT', u'In Real Life': u'IRL', u'Male or Female': u'MoF', u'See You Tomorrow': u'CYT', u'I Love You': u'ILU / ILY', u'Parent in Room': u'PIR', u'Be right Back': u'BRB', u'No Problem': u'NP', u'No Comment': u'NC', u'Not that it Matters': u'NTIM', u'Still in the Dark': u'SITD', u"Someone else's Problem": u'SEP', u'Hugs and Kisses': u'HAK', u'Just Kidding': u'J/K ', u'Out to Lunch': u'OTL', u"I Don't Know": u'IDK', u'Blah, Blah, Blah': u'B3', u'Parent Alert': u'P911', u'Just Checking': u'JC', u'Sleepy': u'C-P', u'See You Soon': u'CUS', u'Be that as it May': u'BTAM', u'Tonight': u'2nte', u"I Don't Care": u'IDC', u'Cutie': u'QT', u'Kill Me Now': u'KMN', u'Age / Sex / Location?': u'ASL', u'Never Mind': u'NVM', u'Proper Respect / Proper Recognition': u'PROP(S)', u'Tomorrow': u'2moro ', u'On My Way': u'OMW'}
def translate_english_to_abbreviation(phase):
if phase in dic_english_to_abbre:
print("abbreviation of ", phase , " is : " , dic_english_to_abbre[phase])
else:
print("abbreviation not found")
def translate_abbreviation_to_english(abbre):
if abbre in dic_abbre_to_english:
print("Full form of abbreviation ", abbre , " is : " , dic_abbre_to_english[abbre])
else:
print("abbreviation invalid")
translate_abbreviation_to_english('MTFBWY')
translate_english_to_abbreviation('In a While')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.