I can't stand text abbreviations, mainly because for the most part I have no idea what most of them mean. Of course, cut backs need to be made, so if they are necessary to fit the text in the character limit, I'll allow them.
You have to write a program that takes passage of text and determines whether text abbreviations are required to fit the passage in the 140 character limit (as used by Twitter).
The passage can be read from a plaintext file, supplied via system arguments or input by a user. You may not hardcode it.
Your program needs to replace all abbreviations (Note: Don't, can't, won't etc. are allowed) found in the passage and replace them with full words. If the expanded passage fits within 140 characters, then abbreviations are unneccessary. Otherwise, abbreviations are necessary. Any unknown abbreviations should be treated as standard words.
The output should be boolean (
True if necessary or
False otherwise) but if the passage was longer than 140 characters in the first place, then
Tl;dr should be printed.
All abbreviations required are detailed here. You decide how you parse the information. You may store the list in a local file of any name, providing that the list is taken from the provided URL.
Abbreviations should be defined as all in capital letters (eg. LOL, LMFAO, OP not lol, lmfao, op).
Note: In several cases, the abbreviation is not the standard format (
abbreviation -> meaning) and sometimes has multiple meanings, words and/or spellings. Ignore all of these cases. For clarification, all abbreviations that you need to worry about should be single word.
Ignore all non alphabetic abbreviations (e.g. Ignore <3,99). Abbreviations that start with an alphabetic character can be parsed (e.g. Do not ignore A/S/L,L8).
Test cases (taken from random tweets)
IDG people who MSG U and still lag even THO U reply straight away like how did U become that busy in 5 secs that U can't communicate LOL CYA
If your role models are celebrities; Athletes, Actors, Singers, Politicians, etc then you need a life coach. ASAP.
For your information: we technically live about 80 milliseconds in the past because that's how long it takes our brains to process information.
The shortest code wins.
Based upon the alt-text of xkcd 1083