lt_twitter_emotions / README.md
SkyWater21's picture
Update README.md
ddcf938
metadata
language:
  - en
  - lt
license: mit
task_categories:
  - text-classification
dataset_info:
  config_name: simplified_ekman
  features:
    - name: lt_text
      dtype: string
    - name: text
      dtype: string
    - name: labels
      dtype:
        class_label:
          names:
            '0': sadness
            '1': joy
            '2': love
            '3': anger
            '4': fear
            '5': surprise
    - name: labels_ekman
      dtype:
        class_label:
          names:
            '0': anger
            '1': disgust
            '2': fear
            '3': joy
            '4': sadness
            '5': surprise
            '6': neutral
  splits:
    - name: train
      num_bytes: 71995184.8176143
      num_examples: 333447
    - name: validation
      num_bytes: 8999425.091192849
      num_examples: 41681
    - name: test
      num_bytes: 8999425.091192849
      num_examples: 41681
  download_size: 55584192
  dataset_size: 89994035
configs:
  - config_name: simplified_ekman
    data_files:
      - split: train
        path: simplified_ekman/train-*
      - split: validation
        path: simplified_ekman/validation-*
      - split: test
        path: simplified_ekman/test-*

The original dataset: https://www.kaggle.com/datasets/nelgiriyewithana/emotions

The derived dataset was machine translated from English into Lithuanian using the free Google Translate API (with deep-translator). The translation script:

import pandas as pd
from deep_translator import GoogleTranslator
from deep_translator.exceptions import TranslationNotFound

# Load dataset and drop the ID column
df = pd.read_csv("path_to_your_downloaded_file/text.csv").iloc[:, 1:]

translator = GoogleTranslator(source="en", target="lt")

def translate_samples(samples):
    texts = samples["text"].tolist()

    while True:
        try:
            translated = translator.translate_batch(texts)
            break
        except TranslationNotFound:
            print(f"Translation failed for '{texts}', retrying...")

    # Replace None with original text if translation is not applicable
    translated = [
        t if t is not None else orig
        for t, orig in zip(translated, texts)
    ]

    # Print replacements
    for t, orig in zip(translated, texts):
        if t == orig:
            print(f"Replaced {orig} with {t}")

    samples["lt_text"] = translated
    return samples

# Apply batch translation
batch_size = 500
translated_dataset = df.groupby(df.index // batch_size, group_keys=False).apply(translate_samples)

Column labels contain the following classes:

0: sadness
1: joy
2: love
3: anger
4: fear
5: surprise

Column labels_ekman contains the Ekman emotion classes:

0: anger
1: disgust - omitted in this dataset
2: fear
3: joy
4: sadness
5: surprise
6: neutral - omitted in this dataset

which were mapped from the original classes as follows:

Original -> Ekman
sadness (0) -> sadness (4)
joy (1) -> joy (3)
love (2) -> joy (3)
anger (3) -> anger (0)
fear (4) -> fear (2)
surprise (5) -> surprise (5)