Duplicate from ai4bharat/IndicSentiment
Browse filesCo-authored-by: Sumanth Doddapaneni <sumanthd@users.noreply.huggingface.co>
- .gitattributes +54 -0
- .gitignore +3 -0
- IndicSentiment.py +79 -0
- README.md +33 -0
- data/compile.py +25 -0
- data/metadata.tsv +0 -0
- data/test/as.json +0 -0
- data/test/bd.json +0 -0
- data/test/bn.json +0 -0
- data/test/gu.json +0 -0
- data/test/hi.json +0 -0
- data/test/kn.json +0 -0
- data/test/ml.json +0 -0
- data/test/mr.json +0 -0
- data/test/or.json +0 -0
- data/test/pa.json +0 -0
- data/test/ta.json +0 -0
- data/test/te.json +0 -0
- data/test/ur.json +0 -0
- data/validation/as.json +0 -0
- data/validation/bd.json +0 -0
- data/validation/bn.json +0 -0
- data/validation/gu.json +0 -0
- data/validation/hi.json +0 -0
- data/validation/kn.json +0 -0
- data/validation/ml.json +0 -0
- data/validation/mr.json +0 -0
- data/validation/or.json +0 -0
- data/validation/pa.json +0 -0
- data/validation/ta.json +0 -0
- data/validation/te.json +0 -0
- data/validation/ur.json +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
# Audio files - uncompressed
|
| 37 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
# Audio files - compressed
|
| 41 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
# Image files - uncompressed
|
| 47 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
# Image files - compressed
|
| 52 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
data/*.txt
|
| 2 |
+
.DS_Store
|
| 3 |
+
data/*.tsv
|
IndicSentiment.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""TODO(IndicSentiment): Add a description here."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
import datasets
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_HOMEPAGE = ""
|
| 10 |
+
|
| 11 |
+
_CITATION = """\
|
| 12 |
+
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
_DESCRIPTION = """\
|
| 16 |
+
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
_LANG = ["as", "bn", "bd", "gu", "hi", "kn", "ml", "mr", "or", "pa", "ta", "te", "ur"]
|
| 20 |
+
_URL = "https://huggingface.co/datasets/ai4bharat/IndicSentiment/resolve/main/data/{split}/{language}.json"
|
| 21 |
+
_VERSION = datasets.Version("1.0.0", "First version of IndicSentiment")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class HAIndicSentiment(datasets.GeneratorBasedBuilder):
|
| 25 |
+
"""TODO(IndicSentiment): Short description of my dataset."""
|
| 26 |
+
BUILDER_CONFIGS = [
|
| 27 |
+
datasets.BuilderConfig(
|
| 28 |
+
name=f"translation-{lang}",
|
| 29 |
+
description=f"translated sentiment data for {lang}",
|
| 30 |
+
version=_VERSION,
|
| 31 |
+
)
|
| 32 |
+
for lang in _LANG
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
def _info(self):
|
| 36 |
+
return datasets.DatasetInfo(
|
| 37 |
+
description=_DESCRIPTION + self.config.description,
|
| 38 |
+
features=datasets.Features(
|
| 39 |
+
{
|
| 40 |
+
"GENERIC CATEGORIES": datasets.Value("string"),
|
| 41 |
+
"CATEGORY": datasets.Value("string"),
|
| 42 |
+
"SUB-CATEGORY": datasets.Value("string"),
|
| 43 |
+
"PRODUCT": datasets.Value("string"),
|
| 44 |
+
"BRAND": datasets.Value("string"),
|
| 45 |
+
"ASPECTS": datasets.Value("string"),
|
| 46 |
+
"ASPECT COMBO": datasets.Value("string"),
|
| 47 |
+
"ENGLISH REVIEW": datasets.Value("string"),
|
| 48 |
+
"LABEL": datasets.Value("string"),
|
| 49 |
+
"INDIC REVIEW": datasets.Value("string"),
|
| 50 |
+
}
|
| 51 |
+
),
|
| 52 |
+
homepage=_HOMEPAGE,
|
| 53 |
+
citation=_CITATION,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
def _split_generators(self, dl_manager):
|
| 57 |
+
"""Returns SplitGenerators."""
|
| 58 |
+
*translation_prefix, language = self.config.name.split("-")
|
| 59 |
+
splits = {datasets.Split.VALIDATION: "validation", datasets.Split.TEST: "test"}
|
| 60 |
+
|
| 61 |
+
data_urls = {
|
| 62 |
+
split: _URL.format(language=language, split=splits[split]) for split in splits
|
| 63 |
+
}
|
| 64 |
+
dl_paths = dl_manager.download(data_urls)
|
| 65 |
+
return [
|
| 66 |
+
datasets.SplitGenerator(
|
| 67 |
+
name=split,
|
| 68 |
+
gen_kwargs={"filepath": dl_paths[split]},
|
| 69 |
+
)
|
| 70 |
+
for split in splits
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
def _generate_examples(self, filepath):
|
| 74 |
+
"""Yields examples."""
|
| 75 |
+
|
| 76 |
+
with open(filepath, encoding="utf-8") as f:
|
| 77 |
+
for idx, row in enumerate(f):
|
| 78 |
+
data = json.loads(row)
|
| 79 |
+
yield idx, data
|
README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- as
|
| 4 |
+
- bn
|
| 5 |
+
- hi
|
| 6 |
+
- kn
|
| 7 |
+
- mr
|
| 8 |
+
- ml
|
| 9 |
+
- or
|
| 10 |
+
- ta
|
| 11 |
+
- te
|
| 12 |
+
- ur
|
| 13 |
+
---
|
| 14 |
+
## Indic Sentiment Analysis
|
| 15 |
+
|
| 16 |
+
## Description
|
| 17 |
+
The Indic Sentiment Analysis dataset contains reviews from various categories and sub-categories in multiple Indic languages. Each review is labeled with sentiment polarity (positive, negative, or neutral).
|
| 18 |
+
|
| 19 |
+
### Dataset Structure
|
| 20 |
+
|
| 21 |
+
## Data Fields
|
| 22 |
+
|
| 23 |
+
- CATEGORY: The broad category to which the review belongs.
|
| 24 |
+
- SUB-CATEGORY: The sub-category within the main category.
|
| 25 |
+
- PRODUCT: The specific product or service being reviewed.
|
| 26 |
+
- BRAND: The brand associated with the product or service.
|
| 27 |
+
- ASPECTS: Different aspects or features of the product or service being reviewed.
|
| 28 |
+
- ASPECT COMBO: Combinations of aspects that are discussed in the review.
|
| 29 |
+
- ENGLISH REVIEW: The review text in English.
|
| 30 |
+
- LABEL: The sentiment label assigned to the review (positive, negative, or neutral).
|
| 31 |
+
- INDIC REVIEW: The review text translated into various Indic languages.
|
| 32 |
+
|
| 33 |
+
|
data/compile.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
langs = ['Hindi', 'Punjabi', 'Assamese', 'Bengali', 'Gujarati', 'Kannada', 'Marathi', 'Tamil', 'Malayalam', 'Odia', 'Telugu', 'Bodo', 'Urdu']
|
| 4 |
+
|
| 5 |
+
codes = ['hi', 'pa', 'as', 'bn', 'gu', 'kn', 'mr', 'ta', 'ml', 'or', 'te', 'bd', 'ur']
|
| 6 |
+
|
| 7 |
+
metadata = pd.read_csv('metadata.tsv', sep='\t')
|
| 8 |
+
idx = np.random.permutation(metadata.index)
|
| 9 |
+
|
| 10 |
+
# for lang, code in zip(langs, codes):
|
| 11 |
+
for lang in codes:
|
| 12 |
+
with open(f"{lang}.txt", "r") as f:
|
| 13 |
+
lines = f.readlines()
|
| 14 |
+
lines = [line.strip() for line in lines]
|
| 15 |
+
|
| 16 |
+
metadata = pd.read_csv('metadata.tsv', sep='\t')
|
| 17 |
+
metadata.columns = ['GENERIC CATEGORIES', 'CATEGORY', 'SUB-CATEGORY', 'PRODUCT', 'BRAND', 'ASPECTS', 'ASPECT COMBO', 'ENGLISH REVIEW', 'LABEL']
|
| 18 |
+
metadata['INDIC REVIEW'] = lines
|
| 19 |
+
|
| 20 |
+
metadata = metadata.reindex(idx)
|
| 21 |
+
|
| 22 |
+
metadata[:1000].to_json(f"test/{lang}.json", orient='records', lines=True)
|
| 23 |
+
metadata[1000:].to_json(f"dev/{lang}.json", orient='records', lines=True)
|
| 24 |
+
|
| 25 |
+
# metadata.to_json(f"dataset/{code}.json", orient='records', lines=True)
|
data/metadata.tsv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/as.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/bd.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/bn.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/gu.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/hi.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/kn.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/ml.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/mr.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/or.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/pa.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/ta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/te.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test/ur.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/as.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/bd.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/bn.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/gu.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/hi.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/kn.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/ml.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/mr.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/or.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/pa.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/ta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/te.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/validation/ur.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|