Datasets:
Refactor: update README with dataset configuration and remove unused files
Browse files- README.md +15 -0
- __init__.py +0 -1
- eu_Law.py +0 -56
README.md
CHANGED
|
@@ -38,6 +38,21 @@ source_datasets:
|
|
| 38 |
task_categories:
|
| 39 |
- other
|
| 40 |
pretty_name: EU Law Dataset - Category 15.10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
---
|
| 42 |
|
| 43 |
# EU Law Dataset – Category 15.10: Environment
|
|
|
|
| 38 |
task_categories:
|
| 39 |
- other
|
| 40 |
pretty_name: EU Law Dataset - Category 15.10
|
| 41 |
+
|
| 42 |
+
configs:
|
| 43 |
+
- config_name: EU_Law
|
| 44 |
+
data_files:
|
| 45 |
+
- split: ground_truth
|
| 46 |
+
path: "subsets/ground_truth/*"
|
| 47 |
+
- split: json
|
| 48 |
+
path: "subsets/json/*"
|
| 49 |
+
- split: pymupdf
|
| 50 |
+
path: "subsets/pymupdf/*"
|
| 51 |
+
- split: unstructured
|
| 52 |
+
path: "subsets/unstructured/*"
|
| 53 |
+
- split: nougat
|
| 54 |
+
path: "subsets/nougat/*"
|
| 55 |
+
|
| 56 |
---
|
| 57 |
|
| 58 |
# EU Law Dataset – Category 15.10: Environment
|
__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
from .eu_law import EULawDataset
|
|
|
|
|
|
eu_Law.py
DELETED
|
@@ -1,56 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import csv
|
| 3 |
-
import datasets
|
| 4 |
-
import sys
|
| 5 |
-
_DESCRIPTION = "EU Law dataset with multiple subsets, each corresponding to a different document conversion method."
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
# Configuration for each subset (conversion format)
|
| 9 |
-
class EuLawConfig(datasets.BuilderConfig):
|
| 10 |
-
def __init__(self, **kwargs):
|
| 11 |
-
super().__init__(**kwargs)
|
| 12 |
-
|
| 13 |
-
# Dataset class
|
| 14 |
-
class EuLaw(datasets.GeneratorBasedBuilder):
|
| 15 |
-
BUILDER_CONFIGS = [
|
| 16 |
-
EuLawConfig(name="json", version=datasets.Version("1.0.0"), description="Subset in JSON format"),
|
| 17 |
-
EuLawConfig(name="pymupdf", version=datasets.Version("1.0.0"), description="Subset from PyMuPDF"),
|
| 18 |
-
EuLawConfig(name="unstructured", version=datasets.Version("1.0.0"), description="Unstructured output"),
|
| 19 |
-
EuLawConfig(name="nougat", version=datasets.Version("1.0.0"), description="Subset using Nougat .mmd"),
|
| 20 |
-
EuLawConfig(name="ground_truth", version=datasets.Version("1.0.0"), description="Ground truth data"),
|
| 21 |
-
]
|
| 22 |
-
|
| 23 |
-
def _info(self):
|
| 24 |
-
return datasets.DatasetInfo(
|
| 25 |
-
description=_DESCRIPTION,
|
| 26 |
-
features=datasets.Features({
|
| 27 |
-
"pdf_path": datasets.Value("string"),
|
| 28 |
-
"conversion": datasets.Value("string"),
|
| 29 |
-
}),
|
| 30 |
-
supervised_keys=None,
|
| 31 |
-
homepage="https://huggingface.co/datasets/nargesbh/eu_Law",
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
def _split_generators(self, dl_manager):
|
| 35 |
-
subset = self.config.name
|
| 36 |
-
csv_path = f"subsets/{subset}/conversion_{subset}.csv"
|
| 37 |
-
downloaded_path = dl_manager.download(csv_path)
|
| 38 |
-
|
| 39 |
-
return [
|
| 40 |
-
datasets.SplitGenerator(
|
| 41 |
-
name=datasets.Split.TRAIN,
|
| 42 |
-
gen_kwargs={"filepath": downloaded_path}
|
| 43 |
-
)
|
| 44 |
-
]
|
| 45 |
-
|
| 46 |
-
def _generate_examples(self, filepath):
|
| 47 |
-
csv.field_size_limit(sys.maxsize)
|
| 48 |
-
with open(filepath, encoding="utf-8") as f:
|
| 49 |
-
reader = csv.DictReader(f)
|
| 50 |
-
for idx, row in enumerate(reader):
|
| 51 |
-
if "pdf_path" not in row or "conversion" not in row:
|
| 52 |
-
continue
|
| 53 |
-
yield idx, {
|
| 54 |
-
"pdf_path": row["pdf_path"].strip(),
|
| 55 |
-
"conversion": row["conversion"].strip()
|
| 56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|