ReplaceInternetSlang - Convert Internet Slang into sentences

ReplaceInternetSlang is a function that converts Internet Slang / Jargon into readable text. The function has been designed in a manner so, say your string contains "lollies", it won't detect the lol inside of the word.

  • Detects multiple occurences of the same word.
  • Advanced detection of whether the occurence was a word or not.

Instructions

  1. Create a new class, call it InternetSlang.vb.
  2. Copy and paste the code provided into the class.
  3. Read the example on how to call this function from another class.

[VB.NET]

''' <summary>
''' This class converts InternetSlang into readable text.
''' </summary>
''' <remarks></remarks>

Public Class InternetSlang
    ''' <summary>
    ''' This array holds all of the words we would like to search for, and its alternative
    ''' meaning.
    ''' </summary>
    ''' <remarks>For use with the ReplaceInternetSlang function</remarks>

    Private Shared ChatWords(,) As String = { _
    {"1337", "elite"}, _
    {"A C?", "AH! SI?"}, _
    {"AFCICR", "as far as I can remember"}, _
    {"AFCICS", "as far as I can see"}, _
    {"AFCICT", "as far as I can tell"}, _
    {"AFAIK", "as far as I know"}, _
    {"AFK", "away from keyboard"}, _
    {"ASAP", "as soon as possible"}, _
    {"ASL", "age / sex / location"}, _
    {"ATEOTD", "at the end of the day"}, _
    {"ATM", "at the moment"}, _
    {"AWOL", "absence without official leave"}, _
    {"AYBABTU", "all your base are belong to us"}, _
    {"AYB", "all your base are belong to us"}, _
    {"B2B", "business to business"}, _
    {"BBIAB", "be back in a bit"}, _
    {"BBQ", "barbeque"}, _
    {"BBL", "be back later"}, _
    {"BBS", "be back soon"}, _
    {"BCNU", "be seein' you"}, _
    {"blog", "web log"}, _
    {"BOFH", "bastard operator from hell"}, _
    {"BRB", "be right back"}, _
    {"BSOD", "blue screen of death"}, _
    {"BTDT", "been there done that"}, _
    {"BTW", "by the way"}, _
    {"bump", "bring my post up"}, _
    {"CBF", "can't be fucked"}, _
    {"crapplet", "a poorly written computer application"}, _
    {"CU", "see you"}, _
    {"CYA", "see ya"}, _
    {"chello", "hello"}, _
    {"DFTT", "don't feed the trolls"}, _
    {"DGAF", "don't give a fuck"}, _
    {"DIAF", "die in a fire"}, _
    {"DILLIGAF", "does it look like I give a fuck"}, _
    {"DILLIGAS", "does it look like I give a shit"}, _
    {"DILLIGAD", "does it look like I give a damn"}, _
    {"DND", "do not disturb"}, _
    {"DOA", "dead on arrival"}, _
    {"EOF", "end of file"}, _
    {"EOM", "end of message"}, _
    {"EOL", "end of line"}, _
    {"EQ", "everquest"}, _
    {"ETA", "estimated time of arrival"}, _
    {"FAQ", "frequently asked questions"}, _
    {"FFS", "for fuck's sake"}, _
    {"Flamer", "offencive person"}, _
    {"FMCDH", "from my cold dead hands"}, _
    {"Fro Rly", "for real"}, _
    {"FOAD", "fuck off and die"}, _
    {"FOAF", "friend of a friend"}, _
    {"FTL", "for the loss"}, _
    {"FTW", "for the win"}, _
    {"FU", "fuck you"}, _
    {"FUBAR", "fucked up beyond all recognition"}, _
    {"FUD", "fear, uncertainty and doubt"}, _
    {"FWIW", "for what it's worth"}, _
    {"FYI", "for your information"}, _
    {"GBTW", "get back to work"}, _
    {"GF", "girlfriend"}, _
    {"GFU", "good for you"}, _
    {"GFY", "go fuck yourself"}, _
    {"GG", "good game"}, _
    {"GJ", "good job"}, _
    {"GMTA", "great minds think alike"}, _
    {"GRATS", "congratulations"}, _
    {"GTFO", "get the fuck out"}, _
    {"g2g", "got to go"}, _
    {"gth", "go to hell"}, _
    {"GR", "good race"}, _
    {"HAND", "have a nice day"}, _
    {"HF", "have fun"}, _
    {"HAXOR", "Hacker"}, _
    {"HTH", "hope this helps"}, _
    {"HUD", "heads up display"}, _
    {"IANAL", "I am not a lawyer"}, _
    {"IBTL", "in before the lock"}, _
    {"IDK", "I don't know"}, _
    {"IONO", "I don't know"}, _
    {"IIRC", "if I remember correctly"}, _
    {"IIUC", "if I understand correctly"}, _
    {"IMO", "in my opinion"}, _
    {"IMHO", "in my honest opinion"}, _
    {"IMNSHO", "in my not so humble opinion"}, _
    {"IMAO", "in my arrogant opinion"}, _
    {"IOW", "in other words"}, _
    {"IRC", "internet relay chat"}, _
    {"IRL", "in real life"}, _
    {"ITYM", "I think you mean"}, _
    {"IWSN", "I want sex now"}, _
    {"IYKWIM", "if you know what I mean"}, _
    {"JAS", "just a second"}, _
    {"JK", "just kidding"}, _
    {"JP", "just playin'"}, _
    {"JFGI", "just fucking google it"}, _
    {"K", "ok"}, _
    {"KK", "ok"}, _
    {"KISS", "keep it simple stupid"}, _
    {"KOS", "kill on sight"}, _
    {"KTHX", "ok, thanks"}, _
    {"KTHXBAI", "ok, thanks, goodbye"}, _
    {"KTHXBYE", "ok, thanks, goodbye"}, _
    {"KRPLCKDNKL", "krapplack donkel"}, _
    {"L8R", "later"}, _
    {"lag", "poor latency"}, _
    {"lamer", "you are lame"}, _
    {"leet", "elite"}, _
    {"LSMIC", "laughing so much i'm crying"}, _
    {"LFG", "looking for group"}, _
    {"LFM", "looking for more"}, _
    {"LMAO", "laugh my ass off"}, _
    {"LMAOBUNS", "laugh my ass off"}, _
    {"LMFAO", "laugh my fucking ass off"}, _
    {"LMIRL", "lets meet in real life"}, _
    {"LMK", "let me know"}, _
    {"LOL", "laugh out loud"}, _
    {"LOLLERSKATES", "laugh out loud"}, _
    {"LTNS", "long time no see"}, _
    {"LYLAS", "love you like a sister"}, _
    {"LYLASIS", "love you like a sister"}, _
    {"LIGPOU", "later I go pee on you"}, _
    {"LAS", "lumpy ass shit"}, _
    {"LASS", "lumpy ass shit son"}, _
    {"MMORPG", "massive multi-player online role playing game"}, _
    {"MOTD", "message of the day"}, _
    {"MTFBWY", "may the force be with you"}, _
    {"MUD", "multi-user dungeon"}, _
    {"MUSH", "multi-user shared hallucination"}, _
    {"MYOB", "mind your own business"}, _
    {"M8", "mate"}, _
    {"NE1", "anyone"}, _
    {"NOOB", "newbie"}, _
    {"NIFOC", "naked in front of computer"}, _
    {"NM", "not much"}, _
    {"NP", "no problem"}, _
    {"NSFW", "not safe for work"}, _
    {"NM", "never mind"}, _
    {"NVP", "not very promising"}, _
    {"O RLY", "oh really"}, _
    {"OIC", "oh I see"}, _
    {"OFN", "old freaking news"}, _
    {"OMG", "oh my god"}, _
    {"OMFG", "oh my fucking god"}, _
    {"OMSOBFG", "oh my son of a bitch freaking god"}, _
    {"OMW", "on my way"}, _
    {"ONOZ", "oh no"}, _
    {"OP", "operator"}, _
    {"OS", "operating system"}, _
    {"OT", "off topic"}, _
    {"OTOH", "on the other hand"}, _
    {"OTP", "on the phone"}, _
    {"P2P", "peer to peer"}, _
    {"PAW", "parents are watching"}, _
    {"PEBCAK", "problem exists between chair and keyboard"}, _
    {"PEBKAC", "problem exists between keyboard and chair"}, _
    {"ping", "latency responce"}, _
    {"PITA", "pain in the ass"}, _
    {"PLMK", "please let me know"}, _
    {"PMSL", "pissing myself laughing"}, _
    {"POS", "piece of shit"}, _
    {"POTS", "plain old telephone service"}, _
    {"POV", "point of view"}, _
    {"PL", "power leveling"}, _
    {"PPL", "people"}, _
    {"PTKFGS", "punch the keys for god's sake"}, _
    {"pr0n", "porn"}, _
    {"PW", "persistant world"}, _
    {"pwned", "owned"}, _
    {"QFT", "quoted for truth"}, _
    {"QROFL", "quitely rolling of floor laughing"}, _
    {"Rehi", "Hello again"}, _
    {"RL", "real life"}, _
    {"RMS", "ride me sideways"}, _
    {"ROFL", "rolling on floor laughing"}, _
    {"ROFLMAO", "rolling on floor laughing my ass off"}, _
    {"ROFLMAOWPIMP", "rolling on floor laughing my ass off while peeing in my pants"}, _
    {"ROFLOL", "rolling on floor laughing out loud"}, _
    {"ROFLCOPTER", "rolling on floor laughing"}, _
    {"RSN", "real soon now"}, _
    {"RTFB", "read the fucking binary"}, _
    {"RTFS", "read the fucking source"}, _
    {"RTM", "read the manual"}, _
    {"RTFM", "read the fucking manual"}, _
    {"SCNR", "sorry, could not resist"}, _
    {"sk8", "skate"}, _
    {"sk8r", "skater"}, _
    {"smiley", "emoticons"}, _
    {"SMH", "shaking my head"}, _
    {"SNAFU", "situation normal: all fucked up"}, _
    {"Snail mail", "paper mail"}, _
    {"SOHF", "sence of humor failure"}, _
    {"STFU", "shut the fuck up"}, _
    {"STFW", "search the fucking web"}, _
    {"TANSTAAFL", "there ain't no such thing as a free lunch"}, _
    {"TBF", "time between failures"}, _
    {"TBH", "to be honest"}, _
    {"TG", "that's great"}, _
    {"TGIF", "thank god it's friday"}, _
    {"THX", "thanks"}, _
    {"TIA", "thanks in advance"}, _
    {"TINC", "there is no cabal"}, _
    {"TMI", "too much information"}, _
    {"TOS", "terms of service"}, _
    {"TTBOMK", "to the best of my knowledge"}, _
    {"TTFN", "ta ta for now"}, _
    {"TTYL", "talk to you later"}, _
    {"TY", "thanks"}, _
    {"TYT", "take your time"}, _
    {"TYVM", "thank you very much"}, _
    {"U", "you"}, _
    {"UTFSE", "use the fucking search engine"}, _
    {"WOOT", "we own the other team"}, _
    {"WTFUWMFIKUFA", "what the fuck you want mother fucker I'll kick your fucking ass"}, _
    {"W/", "with"}, _
    {"WB", "welcome back"}, _
    {"WBU", "what about you"}, _
    {"TTFN", "ta ta for now"}, _
    {"TTYL", "talk to you later"}, _
    {"TY", "thanks"}, _
    {"TYT", "take your time"}, _
    {"TYVM", "thank you very much"}, _
    {"WICN", "what in christ's name"}, _
    {"W/E", "whatever"}, _
    {"WRT", "with respect to"}, _
    {"WTB", "want to buy"}, _
    {"WTF", "what the fuck"}, _
    {"WTG", "way to go"}, _
    {"WTH", "what the hell"}, _
    {"WTS", "want to sell"}, _
    {"WTT", "want to trade"}, _
    {"WUG", "what you got"}, _
    {"WoW", "world of warcraft"}, _
    {"WUBU2", "what you been up to"}, _
    {"WUU2", "what you up to"}, _
    {"WYSIWYG", "what you see is what you get"}, _
    {"W8", "wait"}, _
    {"YHBT", "you have been trolled"}, _
    {"YKW", "you know what"}, _
    {"YMMV", "your mileage may vary"}, _
    {"YTMND", "you're the man now, dog"}, _
    {"YW", "you're welcome"}, _
    {"YOYO", "you're on your own"}, _
    {"YAGTOH", "you are going to own him"}, _
    {"ZOMG", "oh my god"} _
    }

    ''' <summary>
    ''' Replaces Internet Slang with it's proper terms
    ''' </summary>
    ''' <param name="str">The string you would like to convert to normal english.</param>
    ''' <returns>The string with the Internet Slang corrected.</returns>
    ''' <remarks>Uses the lengthy ChatWords array.</remarks>

    Public Shared Function ReplaceInternetSlang(ByRef str As String) As String
        ' This is the variable that we will be using to store the new values.
        Dim Result As String = str

        ' Because .Length() gets the total number of elements, and we are using
        ' a multi-dimensional array for the Chat Words, we will need to divide
        ' by two because we want the size of the first element.
        For i As Integer = 0 To ChatWords.Length / 2 - 1

            ' Create a GoTo point to handle multiple instances of the same word
            ' (e.g. "lol lol")
Recheck:

            ' I chose to use an array to store these if conditions as I have
            ' used them quite a bit below, thus it's more efficent to call it once.
            Dim Occurences() As Integer = { _
            InStr(Result, ChatWords(i, 0), vbTextCompare), _
            InStr(Result, ChatWords(i, 0) + " ", vbTextCompare), _
            InStr(Result, " " + ChatWords(i, 0), vbTextCompare), _
            InStr(Result, " " + ChatWords(i, 0) + " ", vbTextCompare) _
            }

            ' This If Block will check if there are no spaces, and no
            ' other words (for example "lol").
            If Occurences(0) = 1 And Len(Result) = Len(ChatWords(i, 0)) Then
                Result = Result.Remove(0, ChatWords(i, 0).Length)
                Result = Result.Insert(0, ChatWords(i, 1))
                GoTo Recheck ' There could be different instances of the same word.
                ' This If Block will check if there are spaces on either
                ' sides of the word (e.g. " lol ")
            ElseIf Occurences(3) Then
                Result = Result.Remove(Occurences(3), ChatWords(i, 0).Length)
                Result = Result.Insert(Occurences(3), ChatWords(i, 1))
                GoTo Recheck ' There could be different instances of the same word.
                ' This If Block will check if there is a word at the start,
                ' with a space to the right of it.
            ElseIf Occurences(1) = 1 Then
                Result = Result.Remove(Occurences(1) - 1, ChatWords(i, 0).Length)
                Result = Result.Insert(Occurences(1) - 1, ChatWords(i, 1))
                GoTo Recheck ' There could be different instances of the same word.
                'This If Block will check if there is a word at the end,
                ' with a space to the left of it.
            ElseIf Occurences(2) And Result.Length - ChatWords(i, 0).Length = Occurences(2) Then
                Result = Result.Remove(Occurences(2), ChatWords(i, 0).Length)
                Result = Result.Insert(Occurences(2), ChatWords(i, 1))
                GoTo Recheck ' There could be different instances of the same word.
            End If
        Next

        Return Result
    End Function
End Class

Examples

To call the function from your main form, or any other class for that manner, you can do so like this:

MsgBox(InternetSlang.ReplaceInternetSlang("rofl lol"))

I used a MsgBox for the purpose of the example, as the function returns the string representation of the edit.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License