Datasets:
Update divemt.py
Browse files
divemt.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
|
| 3 |
import datasets
|
| 4 |
import pandas as pd
|
| 5 |
|
|
@@ -22,11 +22,11 @@ _HOMEPAGE = "https://github.com/gsarti/divemt"
|
|
| 22 |
|
| 23 |
_LICENSE = "GNU General Public License v3.0"
|
| 24 |
|
| 25 |
-
_ROOT_PATH = "https://
|
| 26 |
|
| 27 |
_PATHS = {
|
| 28 |
-
"main": os.path.join(_ROOT_PATH, "main.tsv
|
| 29 |
-
"warmup": os.path.join(_ROOT_PATH, "warmup.tsv
|
| 30 |
}
|
| 31 |
|
| 32 |
_ALL_FIELDS = ['unit_id', 'flores_id', 'item_id', 'subject_id', 'lang_id', 'doc_id',
|
|
@@ -128,7 +128,7 @@ class DivEMT(datasets.GeneratorBasedBuilder):
|
|
| 128 |
|
| 129 |
def _split_generators(self, dl_manager):
|
| 130 |
"""Returns SplitGenerators."""
|
| 131 |
-
dl_dir = dl_manager.
|
| 132 |
return [
|
| 133 |
datasets.SplitGenerator(
|
| 134 |
name=datasets.Split.TRAIN,
|
|
@@ -141,7 +141,10 @@ class DivEMT(datasets.GeneratorBasedBuilder):
|
|
| 141 |
|
| 142 |
def _generate_examples(self, filepath: str, features):
|
| 143 |
"""Yields examples as (key, example) tuples."""
|
| 144 |
-
data = pd.read_csv(filepath, sep="\t"
|
| 145 |
data = data[features]
|
| 146 |
for id_, row in data.iterrows():
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import json
|
| 3 |
import datasets
|
| 4 |
import pandas as pd
|
| 5 |
|
|
|
|
| 22 |
|
| 23 |
_LICENSE = "GNU General Public License v3.0"
|
| 24 |
|
| 25 |
+
_ROOT_PATH = "https://huggingface.co/datasets/GroNLP/divemt/raw/main"
|
| 26 |
|
| 27 |
_PATHS = {
|
| 28 |
+
"main": os.path.join(_ROOT_PATH, "main.tsv"),
|
| 29 |
+
"warmup": os.path.join(_ROOT_PATH, "warmup.tsv"),
|
| 30 |
}
|
| 31 |
|
| 32 |
_ALL_FIELDS = ['unit_id', 'flores_id', 'item_id', 'subject_id', 'lang_id', 'doc_id',
|
|
|
|
| 128 |
|
| 129 |
def _split_generators(self, dl_manager):
|
| 130 |
"""Returns SplitGenerators."""
|
| 131 |
+
dl_dir = dl_manager.download_and_extract(_PATHS[self.config.name])
|
| 132 |
return [
|
| 133 |
datasets.SplitGenerator(
|
| 134 |
name=datasets.Split.TRAIN,
|
|
|
|
| 141 |
|
| 142 |
def _generate_examples(self, filepath: str, features):
|
| 143 |
"""Yields examples as (key, example) tuples."""
|
| 144 |
+
data = pd.read_csv(filepath, sep="\t")
|
| 145 |
data = data[features]
|
| 146 |
for id_, row in data.iterrows():
|
| 147 |
+
row_dic = row.to_dict()
|
| 148 |
+
for field in _STR_SEQ_FIELDS + _LANG_ANNOTATIONS_FIELDS:
|
| 149 |
+
row_dic[field] = json.loads(row_dic[field])
|
| 150 |
+
yield id_, row_dic
|