Datasets:
File size: 4,110 Bytes
6e80c25 a6cefe1 6e80c25 33c569c e5d3ccb 33c569c 6e80c25 2dbac05 6e80c25 33c569c 6e80c25 33c569c 6e80c25 33c569c 6e80c25 33c569c 6e80c25 a6cefe1 0547960 2dbac05 6e80c25 2dbac05 1341e14 6e80c25 |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
from pathlib import Path
import datasets
import pandas as pd
logger = datasets.logging.get_logger(__name__)
_CITATION = """\
@inproceedings{augustyniak-etal-2020-political,
title = "Political Advertising Dataset: the use case of the Polish 2020 Presidential Elections",
author = "Augustyniak, Lukasz and
Rajda, Krzysztof and
Kajdanowicz, Tomasz and
Bernaczyk, Micha{\l}",
booktitle = "Proceedings of the The Fourth Widening Natural Language Processing Workshop",
month = jul,
year = "2020",
address = "Seattle, USA",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2020.winlp-1.28",
pages = "110--114"
}
"""
_DESCRIPTION = "Polish Political Advertising Dataset"
_HOMEPAGE = "https://github.com/laugustyniak/misinformation"
_URLS = {
"train": "https://huggingface.co/datasets/laugustyniak/political-advertising-pl/resolve/main/train.parquet",
"test": "https://huggingface.co/datasets/laugustyniak/political-advertising-pl/resolve/main/test.parquet",
"validation": "https://huggingface.co/datasets/laugustyniak/political-advertising-pl/resolve/main/dev.parquet",
}
DATA_PATH = Path(".")
class PoliticalAdvertisingConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super(PoliticalAdvertisingConfig, self).__init__(**kwargs)
class PoliticalAdvertisingDataset(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(name="political-advertising-pl", version=VERSION)
]
def _info(self):
features = datasets.Features(
{
"id": datasets.Value("string"),
"tokens": datasets.Sequence(datasets.Value("string")),
"tags": datasets.Sequence(
datasets.features.ClassLabel(
names=[
"O",
"B-DEFENSE_AND_SECURITY",
"I-DEFENSE_AND_SECURITY",
"B-EDUCATION",
"I-EDUCATION",
"B-FOREIGN_POLICY",
"I-FOREIGN_POLICY",
"B-HEALHCARE",
"I-HEALHCARE",
"B-IMMIGRATION",
"I-IMMIGRATION",
"B-INFRASTRUCTURE_AND_ENVIROMENT",
"I-INFRASTRUCTURE_AND_ENVIROMENT",
"B-POLITICAL_AND_LEGAL_SYSTEM",
"I-POLITICAL_AND_LEGAL_SYSTEM",
"B-SOCIETY",
"I-SOCIETY",
"B-WELFARE",
"I-WELFARE",
]
)
),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"filepath": downloaded_files["train"]},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"filepath": downloaded_files["test"]},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={"filepath": downloaded_files["validation"]},
),
]
def _generate_examples(self, filepath: str):
logger.info("⏳ Generating examples from = %s", filepath)
df = pd.read_parquet(filepath)
for row_id, row in df.iterrows():
yield row_id, {
"id": str(row_id),
"tokens": row.tokens,
"tags": row.tags,
}
|