Datasets:
Tasks:
Text Classification
Languages:
Persian
File size: 2,137 Bytes
331f4c7 57fa245 331f4c7 57fa245 325e07d 331f4c7 57fa245 331f4c7 325e07d 331f4c7 57fa245 325e07d 57fa245 331f4c7 57fa245 331f4c7 57fa245 331f4c7 325e07d 331f4c7 57fa245 325e07d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import csv
import datasets
from datasets.tasks import TextClassification
_DESCRIPTION = """\
IUT Ticket Classification
"""
_DOWNLOAD_URLS = {
"train": "https://huggingface.co/datasets/mahdiyehebrahimi/University_Ticket_Classification/raw/main/Tc_train.csv",
"test": "https://huggingface.co/datasets/mahdiyehebrahimi/University_Ticket_Classification/raw/main/Tc_test.csv"
}
class SentimentDKSF(datasets.GeneratorBasedBuilder):
"""IUT Tickets"""
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{"text": datasets.Value("string"), "label": datasets.features.ClassLabel(names=["drop_withdraw", "centralauthentication_email","supervisor_seminar_proposal_defense", "registration"])}
),
supervised_keys=None,
homepage="https://huggingface.co/datasets/hezarai/sentiment-dksf",
task_templates=[TextClassification(text_column="text", label_column="label")],
)
def _split_generators(self, dl_manager):
train_path = dl_manager.download_and_extract(_DOWNLOAD_URLS["train"])
test_path = dl_manager.download_and_extract(_DOWNLOAD_URLS["test"])
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
]
def _generate_examples(self, filepath):
"""Generate examples."""
label2id = self.info.features[self.info.task_templates[0].label_column].str2int
with open(filepath, encoding="utf-8") as csv_file:
csv_reader = csv.reader(
csv_file, quotechar='"', skipinitialspace=True
)
# skip the first row if your csv file has a header row
next(csv_reader, None)
for id_, row in enumerate(csv_reader):
text, label = row
label = label2id(label)
yield id_, {"text": text, "label": label}
yield id_, {"text": text, "label": label}
|