"""
This module implements the main functionality of internet words.

Author: Qadeer Ahmad
LinkedIn: https://www.linkedin.com/in/mr-qadeer-3499a4205/
"""

__author__ = "Qadeer Ahmad"
__email__ = "mrqadeer1231122@gmail.com"
__status__ = "developing"


import re

class CustomErrorHandling(Exception):
    def __init__(self, error_message) -> None:
        print(f"{error_message}")

def words_remover(text:str,is_token:bool=False):
    """_summary_
        This module will help to remove the internet words from any given string. Helpful for NLP tasks

    Args:
        text (str): input string of any to work with
        is_token (bool, optional): for tokenization the string after replacing  Defaults to False.

    Raises:
        CustomErrorHandling: This class helps to raise only type error 

    Returns:
        _type_: This function returns a string if is_token is False else returns list of tokens words.
    """
        
        
    internet_words_dict = {'2NITE': 'tonight',
        'ABT': 'about',
        'ABT2': 'about to',
        'ACC': 'actually',
        'ADD': 'address',
        'AF': 'as ****',
        'AFAIK': 'as far as I know',
        'AFK': 'away from keyboard',
        'AGM': 'annual general meeting',
        'AH': 'ar*ehole (or, less commonly, at home)',
        'AKA': 'also known as',
        'AKF': 'away from keyboard',
        'AMA': 'ask me anything',
        'AOB': 'any other business',
        'AR': 'action required',
        'AS': 'as sh*t (e.g., the new episode is cool AS)',
        'ASAP': 'as soon as posible',
        'ASF': 'as **** (e.g., the new episode is cool AF)',
        'ASL': 'age,sex,location',
        'ATM': 'at the moment',
        'ATP': 'at this point',
        'AWOL': 'absent without leave',
        'AYT': 'are you there (or alright)',
        'B': 'babe',
        'B2B': 'business-to-business',
        'B2C': 'business-to-consumer',
        'B4': 'before',
        'B4N': 'bye for now',
        'BAE': 'before anyone else',
        'BAK': 'back at keyboard',
        'BBIAB': 'be back in a bit',
        'BBIAM': 'be back in a minute',
        'BBL': 'be back later',
        'BC': 'because',
        'BD': 'big deal',
        'BDAY': 'birthday',
        'BF': 'boyfriend',
        'BF4L': 'best friends for life',
        'BFF': 'best friends forever',
        'BFFL': 'best friends for life',
        'BFFR': 'be for f****** real',
        'BFN': 'bye for now',
        'BFR': 'be for real',
        'BOGOF': 'buy one get one free',
        'BOYF': 'boyfriend',
        'BR': 'be real',
        'BRB': 'be right back',
        'BRT': 'be right there',
        'BRUH': 'bro',
        'BTW': 'by the way',
        'BYOB': 'bring your own beer',
        'Bae': 'before anyone else',
        'CBA': "can't be bothered",
        'CMB': 'call me back',
        'CMON': 'come on',
        'COB': 'close of business',
        'CTA': 'call to action',
        'CTN': "can't talk now",
        'CTR': 'click-through rate',
        'CU': 'see you',
        'CUA': 'see you around',
        'CUL': 'see you letter',
        'CWOT': 'complete waste of time',
        'CYA': 'see ya',
        'Cuz': 'because (or cousin)',
        'Cya': 'see ya',
        'DAE': 'does anyone else',
        'DAM': "don't ask me",
        'DISS': 'disrespect',
        'DIY': 'do it yourself',
        'DKDC': "don't know,don't care",
        'DL': 'download',
        'DM': 'direct message',
        'DNC': 'do not care',
        'DND': 'do not disturb',
        'DTM': 'dead to me (or doing too much)',
        'DW': "don't worry",
        'ELI5': "explain like I'm 5",
        'EMA': 'email address',
        'EMBM': 'early morning business meeting',
        'EOD': 'end of day',
        'EOM': 'end of message',
        'ETA': 'estimated time of arrival',
        'EZ': 'easy',
        'F2T': 'free to talk?',
        'FAM': 'short for family',
        'FAQ': 'Frequently Asked Questions',
        'FB': 'Facebook',
        'FF': 'follow Friday',
        'FFS': "for ****'s sake",
        'FGS': "for god's sake",
        'FINNA': 'I am going to',
        'FOMO': 'fear of missing out',
        'FR': 'for real',
        'FS': 'for sure',
        'FTT': 'free to talk?',
        'FTW': 'for the win',
        'FWB': 'friends with benefits',
        'FWD': 'forward',
        'FWIW': "for what it's worth",
        'FYA': 'for your action',
        'FYI': 'for your information',
        'FYR': 'for your reference',
        'G2CU': 'good to see you',
        'G2G': 'got to go',
        'G2R': 'got to run',
        'GAMER': 'video game player',
        'GBU': 'god bless you',
        'GF': 'girlfriend',
        'GG': 'good game',
        'GJ': 'good job',
        'GL': 'good luck',
        'GLHF': 'good luck have fun',
        'GM': 'good morning',
        'GN': 'good night',
        'GNITE': 'good night',
        'GOAT': 'greatest of all time',
        'GR8': 'great',
        'GRATZ': 'congratuations',
        'GTFO': 'get the **** out (or get the **** off)',
        'GTFOH': 'get the f*** outta here',
        'GTG': 'got to go',
        'GUD': 'good',
        'H8': 'hate',
        'HBD': 'happy birthday',
        'HBU': 'how about you?',
        'HELLA': 'really',
        'HF': 'have fun',
        'HIFW': 'how I felt when',
        'HMU': 'hit me up',
        'HRU': 'how are you?',
        'HTH': 'hope this helps',
        'HV': 'have',
        'HW': 'homework',
        'IAM': 'in a meeting',
        'IB': "I'am back",
        'IC': 'I see',
        'ICYMI': 'in case you missed it',
        'IDC': "I don't care",
        'IDGAF': "I don't give a ****",
        'IDGI': "I don't get it",
        'IDK': "I don't know",
        'IDTS': "I don't think so",
        'IFHT': 'I f****** hate that',
        'IG': 'I guess',
        'IIRC': 'if I remember correctly',
        'IK': 'I know',
        'IKR': 'I know, right?',
        'ILU': 'I love you',
        'ILY': 'I love you',
        'ILYSM': 'I love you so much',
        'IM': 'instant message',
        'IMHO': 'in my humble opinion',
        'IMK': 'in my knowledge',
        'IMNSHO': 'in my not-so-humble opinion',
        'IMO': 'in my opinion',
        'IMS': 'I am sorry',
        'IMU': 'I miss you',
        'IMY': 'I miss you',
        'IRL': 'in real life',
        'ISO': 'in search of',
        'ISTG': 'I swear to god',
        'IYKWIM': 'if you know what I mean',
        'IYKYK': 'if you know, you know',
        'IYSWIM': 'if you see what I mean',
        'JIC': 'just in case',
        'JK': 'just kidding',
        'JMO': 'just my opinion',
        'JOMO': 'joy of missing out',
        'JSYK': 'just so you know',
        'K': 'Okay',
        'KEWL': 'cool',
        'KPI': 'key performance indicator',
        'KTHNX': 'Ok,thanks',
        'L8': 'late',
        'L8R': 'later',
        'LDR': 'long-distance relationship',
        'LIT': 'it describes something as positive',
        'LMAO': 'laughing my a** off',
        'LMFAO': 'laughing my f****** a** off',
        'LMK': 'let me know',
        'LOI': 'letter of intent',
        'LOL': 'laugh out loud',
        'LOLLL': 'laugh out loud a lot',
        'LUV YA': 'love you',
        'LYS': 'love yourself',
        'M.I.R.L': 'meet in real life',
        'M8': 'mate',
        'MB': 'my bad',
        'MBN': 'must be nice',
        'MFW': 'my face when',
        'MIA': 'missing in action',
        'MIRL': 'meet in real life',
        'MKAY': 'Mmm,okay',
        'MMS': 'multimedia messaging service',
        'MN': 'me neither',
        'MOU': 'memorandum of understanding',
        'MSG': 'message',
        'MU': 'miss you',
        'N/A': 'not applicable',
        'NBD': 'no big deal',
        'NDA': 'non-disclosure agreement',
        'NE1': 'anyone',
        'NFS': 'no funny stuff (or no funny sh*t)',
        'NFW': 'no f****** way',
        'NGL': 'not going to lie',
        'NIMBY': 'not in my backyard',
        'NM': 'not much',
        'NMU': 'not much, you?',
        'NOYB': 'none of your business',
        'NP': 'no problem',
        'NRN': 'no reply necessary',
        'NSFL': 'not safe for life',
        'NSFW': 'not safe for work',
        'NTM': 'nothing much',
        'NVM': 'never mind',
        'NW': 'no worries',
        'OATUS': 'on a totally unrelated subject',
        'OBV': 'obviously',
        'OFC': 'of course',
        'OIC': 'oh I see',
        'OM': 'oh my!',
        'OMG': 'oh my god',
        'OMG!': 'oh my god',
        'OMH': 'oh my heart',
        'OMH!': 'oh my heart',
        'OML': 'oh my lord',
        'OMW': 'on my way',
        'OOMF': 'one of my friends',
        'OOO': 'out of office',
        'OOTD': 'outfit of the day',
        'OSM': 'awesome',
        'OTJ': 'on-the-job',
        'OTP': 'on the phone',
        'OTT': 'over the top',
        'OTW': 'on the way',
        'PDA': 'public display of affection',
        'PFA': 'please find attached',
        'PL': 'please',
        'PLS': 'please',
        'PLZ': 'please',
        'PM': 'private message',
        'PMO': 'project management office',
        'PO': 'peace out',
        'POC': 'point of contact',
        'POV': 'point of view',
        'PPL': 'people',
        'PQRT': 'private quote retweet',
        'PRB': 'please reply by',
        'PS': 'post scriptum',
        'PTL': 'praise the lord',
        'QOTD': 'quote of the day',
        'QQ': 'cry more',
        'QRT': 'quote retweet',
        'QT': 'cutie',
        'R&D': 'research and development',
        'RD': 'real deal',
        'RFI': 'request for information',
        'RFN': 'right ******* now!',
        'RFP': 'request for proposal',
        'RFQ': 'request for quotation',
        'RLY': 'really',
        'RN': 'right now',
        'ROFL': 'rolling on the floor laughing',
        'ROFLMAO': 'rolling on the floor laughing my a** off',
        'ROI': 'return on investment',
        'RT': 'retweet',
        'RUOK': 'are you okay?',
        'SFW': 'safe for work',
        'SMDH': 'shaking my damn head',
        'SME': 'subject matter expert',
        'SMH': 'shaking my head',
        'SMS': 'short message service',
        'SMT': 'sucking my teeth',
        'SO': 'significant other',
        'SOP': 'standard operating procedure',
        'SPK': 'speak',
        'SRS': 'serious',
        'SRSLY': 'seriously',
        'SRY': 'sorry',
        'SSDD': 'same stuff, different day',
        'STFU': 'shut the **** up',
        'STG': 'swear to god',
        'SU': 'shut up',
        'SUP': "what's up?",
        'SYL': 'see you later',
        'Sus': 'suspicious',
        'T&C': 'terms and conditions',
        'TBA': 'to be announced',
        'TBC': 'to be confirmed',
        'TBD': 'to be determined',
        'TBF': 'to be fair',
        'TBH': 'to be honest',
        'TBT': 'throwback Thursday',
        'TBVH': 'to be very honest',
        'TC': 'take care',
        'TFTI': 'thanks for the invite',
        'TFW': 'that feel when',
        'TGIF': "thank god it's Friday",
        'THX': 'thanks',
        'TIA': 'thanks in advance',
        'TIL': 'today I learned',
        'TL;DR': "too long; didn't read",
        'TLDR': "too long; didn't read",
        'TMB': 'text me back (or text me b**ch)',
        'TMI': 'too much information',
        'TMRW': 'tomorrow',
        'TTFN': 'ta ta for now',
        'TTYL': 'talk to you later',
        'TWT': 'Twitter',
        'TY': 'thank you',
        'TYSM': 'thank you so much',
        'TYT': 'take your time',
        'U2': 'you too',
        'UOK': 'you okay?',
        'UR': 'you are',
        'V': 'very',
        'VFM': 'value for money',
        'VIP': 'very important person',
        'VM': 'voice message',
        'VN': 'very nice (or voice note)',
        'W/E': 'whatever',
        'W/O': 'without',
        'WA': 'WhatsApp',
        'WB': 'welcome back',
        'WBK': 'we been knew',
        'WBU': 'what about you?',
        'WDYS': 'what do you say?',
        'WDYT': 'what do you think?',
        'WTF': 'what the ****',
        'WTG': 'way to go!',
        'WTH': 'what the heck',
        'WTM': "what's the matter?",
        'WTV': 'whatever',
        'WTW': "what's the word?",
        'WYA': 'where you at?',
        'WYD': 'what you doing?',
        'WYS': "whatever you say",
        'WYWH': 'wish you were here',
        'XOXO': 'hugs and kisses',
        'Y/N': 'yes or no',
        'Y?': 'why?',
        'YGTI': 'you get the idea',
        'YK': 'you know',
        'YKTV': 'you know the vibe',
        'YMMV': 'your mileage may vary',
        'YOLO': 'you only live once',
        'YT': 'YouTube',
        'YW': "you're welcome",
        'ZOMG': 'oh my god',
        'DNT': "don't",
        'INSTA': 'Instagram'}
        # checking if the input is string or not
    if isinstance(text, str):
        # Split text into words, replace them, and join back
        replaced_string = ' '.join(replace_word(word, internet_words_dict) for word in text.split())

        # If tokens are needed
        if is_token:
            return replaced_string.split()
        return replaced_string
    else:
        raise CustomErrorHandling("Type Error! Accept only string")
def replace_word(word:str, internet_words_dict:dict):
    
    # Match word with optional trailing punctuation
    match = re.match(r'(\b\w+\b)([\W]*)', word)
    if match:
        word, punctuation = match.groups()
        # Replace word and reattach punctuation
        return internet_words_dict.get(word.upper(), word) + punctuation
    return word
if __name__=='__main__':
    text="I've hv and Hv HVV"
    print(words_remover(text))