Commit
·
4098528
1
Parent(s):
53401ca
Upload indotacos.py with huggingface_hub
Browse files- indotacos.py +141 -0
indotacos.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from typing import List
|
| 3 |
+
|
| 4 |
+
import datasets
|
| 5 |
+
|
| 6 |
+
from nusacrowd.utils.configs import NusantaraConfig
|
| 7 |
+
from nusacrowd.utils.constants import Tasks
|
| 8 |
+
from nusacrowd.utils import schemas
|
| 9 |
+
|
| 10 |
+
import pandas as pd
|
| 11 |
+
|
| 12 |
+
_CITATION = """\
|
| 13 |
+
@misc{wibisono2022indotacos,
|
| 14 |
+
title = {IndoTacos},
|
| 15 |
+
howpublished = {\\url{https://www.kaggle.com/datasets/christianwbsn/indonesia-tax-court-verdict}},
|
| 16 |
+
note = {Accessed: 2022-09-22}
|
| 17 |
+
}
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
_LOCAL = False
|
| 21 |
+
_LANGUAGES = ["ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
|
| 22 |
+
_DATASETNAME = "indotacos"
|
| 23 |
+
|
| 24 |
+
_DESCRIPTION = """\
|
| 25 |
+
Predicting the outcome or the probability of winning a legal case has always been highly attractive in legal sciences and practice.
|
| 26 |
+
Hardly any dataset has been developed to analyze and accelerate the research of court verdict analysis.
|
| 27 |
+
Find out what factor affects the outcome of tax court verdict using Natural Language Processing.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
_HOMEPAGE = "https://www.kaggle.com/datasets/christianwbsn/indonesia-tax-court-verdict"
|
| 31 |
+
|
| 32 |
+
_LICENSE = "Creative Common Attribution Share-Alike 4.0 International"
|
| 33 |
+
|
| 34 |
+
# For publicly available datasets you will most likely end up passing these URLs to dl_manager in _split_generators.
|
| 35 |
+
# In most cases the URLs will be the same for the source and nusantara config.
|
| 36 |
+
# However, if you need to access different files for each config you can have multiple entries in this dict.
|
| 37 |
+
# This can be an arbitrarily nested dict/list of URLs (see below in `_split_generators` method)
|
| 38 |
+
_URLS = {_DATASETNAME: {"indotacos": "https://huggingface.co/datasets/christianwbsn/indotacos/resolve/main/indonesia_tax_court_verdict.csv"}}
|
| 39 |
+
|
| 40 |
+
_SUPPORTED_TASKS = [Tasks.TAX_COURT_VERDICT]
|
| 41 |
+
|
| 42 |
+
_SOURCE_VERSION = "1.0.0"
|
| 43 |
+
|
| 44 |
+
_NUSANTARA_VERSION = "1.0.0"
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class IndoTacos(datasets.GeneratorBasedBuilder):
|
| 48 |
+
"""IndoTacos, an Indonesian Tax Court verdict summary containing 12283 tax court cases provided by perpajakan.ddtc.co.id."""
|
| 49 |
+
|
| 50 |
+
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
| 51 |
+
NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
|
| 52 |
+
|
| 53 |
+
BUILDER_CONFIGS = [
|
| 54 |
+
NusantaraConfig(
|
| 55 |
+
name="indotacos_source",
|
| 56 |
+
version=SOURCE_VERSION,
|
| 57 |
+
description="indotacos source schema",
|
| 58 |
+
schema="source",
|
| 59 |
+
subset_id="indotacos",
|
| 60 |
+
),
|
| 61 |
+
NusantaraConfig(
|
| 62 |
+
name="indotacos_nusantara_text",
|
| 63 |
+
version=NUSANTARA_VERSION,
|
| 64 |
+
description="IndoTacos Nusantara schema",
|
| 65 |
+
schema="nusantara_text",
|
| 66 |
+
subset_id="indotacos",
|
| 67 |
+
),
|
| 68 |
+
]
|
| 69 |
+
|
| 70 |
+
DEFAULT_CONFIG_NAME = "indotacos_source"
|
| 71 |
+
labels = ["mengabulkan sebagian", "mengabulkan seluruhnya", "menolak", "lain-lain", "menambah pajak", "mengabulkan", "membetulkan"]
|
| 72 |
+
|
| 73 |
+
def _info(self) -> datasets.DatasetInfo:
|
| 74 |
+
|
| 75 |
+
if self.config.schema == "source":
|
| 76 |
+
features = datasets.Features(
|
| 77 |
+
{
|
| 78 |
+
"id": datasets.Value("int32"),
|
| 79 |
+
"text": datasets.Value("string"),
|
| 80 |
+
"nomor_putusan": datasets.Value("string"),
|
| 81 |
+
"tahun_pajak": datasets.Value("int32"),
|
| 82 |
+
"jenis_pajak": datasets.Value("string"),
|
| 83 |
+
"tahun_putusan": datasets.Value("int32"),
|
| 84 |
+
"pokok_sengketa": datasets.Value("string"),
|
| 85 |
+
"jenis_putusan": datasets.Value("string"),
|
| 86 |
+
}
|
| 87 |
+
)
|
| 88 |
+
elif self.config.schema == "nusantara_text":
|
| 89 |
+
features = schemas.text_features(self.labels)
|
| 90 |
+
|
| 91 |
+
return datasets.DatasetInfo(
|
| 92 |
+
description=_DESCRIPTION,
|
| 93 |
+
features=features,
|
| 94 |
+
homepage=_HOMEPAGE,
|
| 95 |
+
license=_LICENSE,
|
| 96 |
+
citation=_CITATION,
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 100 |
+
url = _URLS["indotacos"]
|
| 101 |
+
path = dl_manager.download(url)["indotacos"]
|
| 102 |
+
data_files = {"train": path}
|
| 103 |
+
|
| 104 |
+
return [
|
| 105 |
+
datasets.SplitGenerator(
|
| 106 |
+
name=datasets.Split.TRAIN,
|
| 107 |
+
gen_kwargs={
|
| 108 |
+
"filepath": data_files["train"],
|
| 109 |
+
},
|
| 110 |
+
)
|
| 111 |
+
]
|
| 112 |
+
|
| 113 |
+
def _generate_examples(self, filepath: Path):
|
| 114 |
+
df = pd.read_csv(filepath)
|
| 115 |
+
if self.config.schema == "source":
|
| 116 |
+
row_id = 1
|
| 117 |
+
for row in df.itertuples():
|
| 118 |
+
ex = {
|
| 119 |
+
"id": str(row_id),
|
| 120 |
+
"text": row.text,
|
| 121 |
+
"nomor_putusan": row.nomor_putusan,
|
| 122 |
+
"tahun_pajak": row.tahun_pajak,
|
| 123 |
+
"jenis_pajak": row.jenis_pajak,
|
| 124 |
+
"tahun_putusan": row.tahun_putusan,
|
| 125 |
+
"pokok_sengketa": row.pokok_sengketa,
|
| 126 |
+
"jenis_putusan": row.jenis_putusan,
|
| 127 |
+
}
|
| 128 |
+
yield row_id, ex
|
| 129 |
+
row_id += 1
|
| 130 |
+
elif self.config.schema == "nusantara_text":
|
| 131 |
+
row_id = 1
|
| 132 |
+
for row in df.itertuples():
|
| 133 |
+
ex = {
|
| 134 |
+
"id": str(row_id),
|
| 135 |
+
"text": {"text": row.text, "nomor_putusan": row.nomor_putusan, "tahun_pajak": row.tahun_pajak, "jenis_pajak": row.jenis_pajak, "tahun_putusan": row.tahun_putusan, "pokok_sengketa": row.pokok_sengketa},
|
| 136 |
+
"label": row.jenis_putusan,
|
| 137 |
+
}
|
| 138 |
+
yield row_id, ex
|
| 139 |
+
row_id += 1
|
| 140 |
+
else:
|
| 141 |
+
raise ValueError(f"Invalid config: {self.config.name}")
|