FpOliveira's picture
Update bookcorpus.py
e78c445
raw
history blame
No virus
1.31 kB
from datasets import Dataset, DatasetBuilder
import pandas as pd
class YourDataset(DatasetBuilder):
VERSION = "1.0.0"
def _info(self):
features = {
"source": "string",
"id": "string",
"text": "string",
"researcher": "string",
"year": "int",
"aggressive": "float",
"hate": "float",
}
return datasets.DatasetInfo(features=features)
def _split_generators(self, dl_manager):
# You can download and extract data here if needed
return []
def _generate_examples(self, file_path):
df = pd.read_csv(file_path)
for i, row in df.iterrows():
yield i, {
"source": str(row["source"]),
"id": str(row["id"]),
"text": str(row["text"]),
"researcher": str(row["researcher"]),
"year": int(row["year"]),
"aggressive": float(row["aggressive"]),
"hate": float(row["hate"]),
}
# Load your dataset
file_path = "https://raw.githubusercontent.com/Silly-Machine/TuPi-Portuguese-Hate-Speech-Dataset/main/datasets/tupi_binary.csv"
your_dataset = Dataset.load_from_disk(file_path)
# Use the Hugging Face Dataset viewer
your_dataset.view()