|
|
| import os |
| import textwrap |
| from textwrap import TextWrapper |
| import datasets |
| import pyarrow.parquet as pq |
|
|
| _URLS = { |
| "original_text": "./original_text", |
| "unlabeled_sentences": "./unlabeled_sentences" |
| } |
|
|
| _metadata = { |
| "citation": """\ |
| @InProceedings{ |
| huggingface:dataset, |
| title = {Paraguay Legislation Dataset}, |
| author={Peres, Fernando; Costa, Victor}, |
| year={2023} |
| } |
| """, |
|
|
| "description": "Dataset for researching.", |
|
|
| "homepage": "https://www.leyes.com.py/", |
|
|
| "license": "apache-2.0", |
| } |
|
|
|
|
| class TestBuilder(datasets.GeneratorBasedBuilder): |
| VERSION = datasets.Version("1.0.0") |
|
|
| BUILDER_CONFIGS = [ |
| datasets.BuilderConfig( |
| name="raw_text", |
| version=VERSION, |
| description="desc raw text", |
| ), |
|
|
| datasets.BuilderConfig( |
| name="unlabeled_sentences", |
| version=VERSION, |
| description="desc unlabeled", |
| ), |
| ] |
|
|
| def _info(self): |
|
|
| features = None |
| if self.config.name == "raw_text": |
|
|
| features = datasets.Features( |
| { |
| "id": datasets.Value(dtype="int64"), |
| "text": datasets.Value(dtype="string"), |
| } |
| ) |
|
|
| if self.config.name == "unlabeled_sentences": |
| features = features = datasets.Features( |
| { |
| "id": datasets.Value(dtype="int64"), |
| "text_2": datasets.Value(dtype="string"), |
| "note": datasets.Value(dtype="string"), |
| } |
| ) |
|
|
| return datasets.DatasetInfo( |
| builder_name=self.config.name, |
| description="description xxxxxxxxxxxxxxx", |
| features=features, |
| homepage=_metadata["homepage"], |
| license=_metadata["license"], |
| citation=_metadata["citation"], |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| urls_to_download = _URLS[self.config.name] |
|
|
| filepaths = dl_manager.download_and_extract(urls_to_download) |
|
|
| return datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={"filepath": filepaths}, |
| ) |
|
|
| def _generate_examples(self, filepath): |
| pq_table = pq.read_table(filepath) |
| for i in range(len(pq_table)): |
| yield i, { |
| col_name: pq_table[col_name][i].as_py() |
| for col_name in pq_table.column_names |
| } |
|
|