tobiasbrugger
commited on
Commit
·
16f6032
1
Parent(s):
58be895
update
Browse files- MultiLegalSBD.py +6 -13
MultiLegalSBD.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
-
import datasets
|
| 2 |
-
from huggingface_hub.file_download import hf_hub_url
|
| 3 |
-
import glob
|
| 4 |
import json
|
|
|
|
|
|
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
|
| 7 |
try:
|
| 8 |
import lzma as xz
|
| 9 |
except ImportError:
|
| 10 |
import pylzma as xz
|
|
|
|
| 11 |
datasets.logging.set_verbosity_info()
|
| 12 |
logger = datasets.logging.get_logger(__name__)
|
| 13 |
|
|
@@ -37,10 +38,6 @@ _SOURCES = [
|
|
| 37 |
"Gesetz", "Constitution", "CivilCode", "CriminalCode",
|
| 38 |
]
|
| 39 |
|
| 40 |
-
|
| 41 |
-
"""
|
| 42 |
-
see https://huggingface.co/datasets/joelito/MultiLegalPile_Wikipedia_Filtered/blob/main/MultiLegalPile_Wikipedia_Filtered.py
|
| 43 |
-
"""
|
| 44 |
_HIGHEST_NUMBER_OF_SHARDS = 4
|
| 45 |
class MultiLegalSBDConfig(datasets.BuilderConfig):
|
| 46 |
|
|
@@ -52,7 +49,6 @@ class MultiLegalSBDConfig(datasets.BuilderConfig):
|
|
| 52 |
|
| 53 |
class MultiLegalSBD(datasets.GeneratorBasedBuilder):
|
| 54 |
|
| 55 |
-
|
| 56 |
BUILDER_CONFIG_CLASS = MultiLegalSBDConfig
|
| 57 |
|
| 58 |
BUILDER_CONFIGS = [
|
|
@@ -71,8 +67,7 @@ class MultiLegalSBD(datasets.GeneratorBasedBuilder):
|
|
| 71 |
"end": datasets.Value("int64"),
|
| 72 |
"label": datasets.Value("string"),
|
| 73 |
"token_start": datasets.Value("int64"),
|
| 74 |
-
"token_end": datasets.Value("int64")
|
| 75 |
-
|
| 76 |
}
|
| 77 |
],
|
| 78 |
"tokens": [
|
|
@@ -82,7 +77,6 @@ class MultiLegalSBD(datasets.GeneratorBasedBuilder):
|
|
| 82 |
"end": datasets.Value("int64"),
|
| 83 |
"id": datasets.Value("int64"),
|
| 84 |
"ws": datasets.Value("bool")
|
| 85 |
-
|
| 86 |
}
|
| 87 |
],
|
| 88 |
"source": datasets.Value("string")
|
|
@@ -103,6 +97,7 @@ class MultiLegalSBD(datasets.GeneratorBasedBuilder):
|
|
| 103 |
repo_type='dataset'
|
| 104 |
)
|
| 105 |
return dl_manager.download(url)
|
|
|
|
| 106 |
languages = _LANGUAGES if self.config.language == "all" else [self.config.language]
|
| 107 |
types = _TYPES if self.config.type == 'all' else [self.config.type]
|
| 108 |
|
|
@@ -134,8 +129,6 @@ class MultiLegalSBD(datasets.GeneratorBasedBuilder):
|
|
| 134 |
|
| 135 |
for json_str in json_list:
|
| 136 |
example = json.loads(json_str)
|
| 137 |
-
if id_ == 0:
|
| 138 |
-
print(example)
|
| 139 |
if example is not None and isinstance(example, dict):
|
| 140 |
yield id_, example
|
| 141 |
id_ +=1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
+
|
| 3 |
+
import datasets
|
| 4 |
import pandas as pd
|
| 5 |
+
from huggingface_hub.file_download import hf_hub_url
|
| 6 |
|
| 7 |
try:
|
| 8 |
import lzma as xz
|
| 9 |
except ImportError:
|
| 10 |
import pylzma as xz
|
| 11 |
+
|
| 12 |
datasets.logging.set_verbosity_info()
|
| 13 |
logger = datasets.logging.get_logger(__name__)
|
| 14 |
|
|
|
|
| 38 |
"Gesetz", "Constitution", "CivilCode", "CriminalCode",
|
| 39 |
]
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
_HIGHEST_NUMBER_OF_SHARDS = 4
|
| 42 |
class MultiLegalSBDConfig(datasets.BuilderConfig):
|
| 43 |
|
|
|
|
| 49 |
|
| 50 |
class MultiLegalSBD(datasets.GeneratorBasedBuilder):
|
| 51 |
|
|
|
|
| 52 |
BUILDER_CONFIG_CLASS = MultiLegalSBDConfig
|
| 53 |
|
| 54 |
BUILDER_CONFIGS = [
|
|
|
|
| 67 |
"end": datasets.Value("int64"),
|
| 68 |
"label": datasets.Value("string"),
|
| 69 |
"token_start": datasets.Value("int64"),
|
| 70 |
+
"token_end": datasets.Value("int64")
|
|
|
|
| 71 |
}
|
| 72 |
],
|
| 73 |
"tokens": [
|
|
|
|
| 77 |
"end": datasets.Value("int64"),
|
| 78 |
"id": datasets.Value("int64"),
|
| 79 |
"ws": datasets.Value("bool")
|
|
|
|
| 80 |
}
|
| 81 |
],
|
| 82 |
"source": datasets.Value("string")
|
|
|
|
| 97 |
repo_type='dataset'
|
| 98 |
)
|
| 99 |
return dl_manager.download(url)
|
| 100 |
+
|
| 101 |
languages = _LANGUAGES if self.config.language == "all" else [self.config.language]
|
| 102 |
types = _TYPES if self.config.type == 'all' else [self.config.type]
|
| 103 |
|
|
|
|
| 129 |
|
| 130 |
for json_str in json_list:
|
| 131 |
example = json.loads(json_str)
|
|
|
|
|
|
|
| 132 |
if example is not None and isinstance(example, dict):
|
| 133 |
yield id_, example
|
| 134 |
id_ +=1
|