Upload TexPrax.py
Browse files- TexPrax.py +9 -7
TexPrax.py
CHANGED
|
@@ -94,6 +94,7 @@ class TexPraxDataset(datasets.GeneratorBasedBuilder):
|
|
| 94 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 95 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 96 |
BUILDER_CONFIGS = [
|
|
|
|
| 97 |
TexPraxConfig(
|
| 98 |
name="sentence_classification",
|
| 99 |
description="Sentence level annotations of the TexPrax dataset.",
|
|
@@ -110,14 +111,15 @@ class TexPraxDataset(datasets.GeneratorBasedBuilder):
|
|
| 110 |
citation=_CITATION,
|
| 111 |
url=_ENTITY_URL
|
| 112 |
),
|
| 113 |
-
|
| 114 |
-
|
|
|
|
| 115 |
]
|
| 116 |
|
| 117 |
-
DEFAULT_CONFIG_NAME = "
|
| 118 |
|
| 119 |
def _info(self):
|
| 120 |
-
if self.config.name == "
|
| 121 |
features = datasets.Features(
|
| 122 |
{
|
| 123 |
# Note: ID consists of <dialog-id_sentence-id_turn-id>
|
|
@@ -189,13 +191,12 @@ class TexPraxDataset(datasets.GeneratorBasedBuilder):
|
|
| 189 |
)
|
| 190 |
|
| 191 |
def _split_generators(self, dl_manager):
|
| 192 |
-
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
| 193 |
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 194 |
|
| 195 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 196 |
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
| 197 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 198 |
-
if self.config.name == "
|
| 199 |
urls = _SENTENCE_URL
|
| 200 |
data_dir = dl_manager.download_and_extract(urls)
|
| 201 |
return [
|
|
@@ -278,7 +279,8 @@ class TexPraxDataset(datasets.GeneratorBasedBuilder):
|
|
| 278 |
with open(filepath, encoding="utf-8") as f:
|
| 279 |
creader = csv.reader(f, delimiter=';', quotechar='"')
|
| 280 |
for key, row in enumerate(creader):
|
| 281 |
-
|
|
|
|
| 282 |
idx, sentence, label = row
|
| 283 |
# Yields examples as (key, example) tuples
|
| 284 |
yield key, {
|
|
|
|
| 94 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 95 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 96 |
BUILDER_CONFIGS = [
|
| 97 |
+
"""
|
| 98 |
TexPraxConfig(
|
| 99 |
name="sentence_classification",
|
| 100 |
description="Sentence level annotations of the TexPrax dataset.",
|
|
|
|
| 111 |
citation=_CITATION,
|
| 112 |
url=_ENTITY_URL
|
| 113 |
),
|
| 114 |
+
"""
|
| 115 |
+
datasets.BuilderConfig(name="sentence_cl", version=VERSION, description="Sentence level annotations of the TexPrax dataset."),
|
| 116 |
+
datasets.BuilderConfig(name="ner", version=VERSION, description="BIO-tagged named entites of the TexPrax dataset."),
|
| 117 |
]
|
| 118 |
|
| 119 |
+
DEFAULT_CONFIG_NAME = "sentence_cl" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 120 |
|
| 121 |
def _info(self):
|
| 122 |
+
if self.config.name == "sentence_cl": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 123 |
features = datasets.Features(
|
| 124 |
{
|
| 125 |
# Note: ID consists of <dialog-id_sentence-id_turn-id>
|
|
|
|
| 191 |
)
|
| 192 |
|
| 193 |
def _split_generators(self, dl_manager):
|
|
|
|
| 194 |
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 195 |
|
| 196 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 197 |
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
| 198 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 199 |
+
if self.config.name == "sentence_cl":
|
| 200 |
urls = _SENTENCE_URL
|
| 201 |
data_dir = dl_manager.download_and_extract(urls)
|
| 202 |
return [
|
|
|
|
| 279 |
with open(filepath, encoding="utf-8") as f:
|
| 280 |
creader = csv.reader(f, delimiter=';', quotechar='"')
|
| 281 |
for key, row in enumerate(creader):
|
| 282 |
+
print(key, row)
|
| 283 |
+
if self.config.name == "sentence_cl":
|
| 284 |
idx, sentence, label = row
|
| 285 |
# Yields examples as (key, example) tuples
|
| 286 |
yield key, {
|