text_plain_output_1.png
import pandas as pd

import re

train_path = '/kaggle/input/emotion-classification-nlp/emotion-labels-train.csv'
validation_path = '/kaggle/input/emotion-classification-nlp/emotion-labels-val.csv'
test_path = '/kaggle/input/emotion-classification-nlp/emotion-labels-test.csv'

train_pd = pd.read_csv(train_path)
validation_pd = pd.read_csv(validation_path)
test_pd = pd.read_csv(test_path)

all_data_list = [train_pd, validation_pd, test_pd]

emotions_categories = {'joy': ['joy', 'happy', 'laugh', 'excited', 'surprise'], 'sadness': ['sad', 'disappointed', 'regret', 'depressed', 'lonely'], 'anger': ['angry', 'frustrated', 'annoyed', 'irritated', 'mad'], 'fear': ['afraid', 'scared', 'fear', 'terrified', 'nervous']}

def DELETE_EMOJIS(datasetinit):
    lendata = len(datasetinit)
    e_pattern = re.compile('[😀-🙏🌀-🗿🚀-\U0001f6ff\U0001f1e0-🇿✂-➰🤀-🧿🤐-🤿🥀-🥿🦀-🧠]+', flags=re.UNICODE)
    for co_ in range(lendata):
        tt = datasetinit['text'][co_]
        tt = e_pattern.sub('', tt)
        datasetinit['text'][co_] == tt

def MULTI_EMOTION_MAPPING(datasetinit):
    lendata = len(datasetinit)
    for co_ in range(lendata):
        val = datasetinit['label'][co_]
        if val == 'joy':
            datasetinit['label'][co_] = ','.join((str(xc) for xc in emotions_categories['joy']))
        elif val == 'sadness':
            datasetinit['label'][co_] = ','.join((str(xc) for xc in emotions_categories['sadness']))
        elif val == 'anger':
            datasetinit['label'][co_] = ','.join((str(xc) for xc in emotions_categories['anger']))
        elif val == 'fear':
            datasetinit['label'][co_] = ','.join((str(xc) for xc in emotions_categories['fear']))
        else:
            pass

for x_data, x_name in zip(all_data_list, ['TRAIN', 'VALIDATION', 'TEST']):
    MULTI_EMOTION_MAPPING(x_data)
    x_data.reset_index(drop=True, inplace=True)

for x_data, x_name in zip(all_data_list, ['TRAIN', 'VALIDATION', 'TEST']):
    print(f'CONTROL FOR - {x_name}\n\n{x_data.head()}\n\n\n')