Introduction
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.
Challenge
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.
Determining
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.
Abbreviations
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)
1: Returns true
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
2: Returns false
If your role models are celebrities; Athletes, Actors, Singers, Politicians, etc then you need a life coach. ASAP.
3: Returns Tl;dr
For your information: we technically live about 80 milliseconds in the past because that's how long it takes our brains to process information.
Winning Criteria
The shortest code wins.
Based upon the alt-text of xkcd 1083
or
in that list? There is at least one entry where theor
is part of the acronym (2B or not 2B
) and one where it lists two variations of the acronym (ZMG or ZOMG
). There is alsoKFY -or- K4Y
(with the dashes). The acronymsLBR
andLGR
have single entry (acronym and explanation combined withand
). I think I've found a winner:THX or TX or THKS
. Other problematic ones:AS
,RTM or RTFM
(both of which come with two different explanations) \$\endgroup\$or
andand
? This isn't supposed to be a useful program, and for the golfing part, it's really quite tedious to sort all of these different cases out (there'sor
,-or-
,and
, slahes, commas, alternatives in parentheses and explanations instead of verbatim meanings). How about we just pretend those were the verbatim abbreviations and meanings? Then the only ambiguity is that some abbreviations are contained in others: e.g. there'sLOL
andLOL WUSS
. If I expandLOL
I can't expandLOL WUSS
any more. How do we handle these? \$\endgroup\$