Datasets:
Update divemt.py
Browse files
divemt.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
import
|
| 3 |
import datasets
|
| 4 |
import pandas as pd
|
| 5 |
from pprint import pprint
|
|
@@ -140,15 +140,14 @@ class DivEMT(datasets.GeneratorBasedBuilder):
|
|
| 140 |
)
|
| 141 |
]
|
| 142 |
|
| 143 |
-
def _generate_examples(self, filepath: str
|
| 144 |
"""Yields examples as (key, example) tuples."""
|
| 145 |
data = pd.read_csv(filepath, sep="\t")
|
| 146 |
for id_, row in data.iterrows():
|
| 147 |
row_dic = row.to_dict()
|
| 148 |
for field in _STR_SEQ_FIELDS + _LANG_ANNOTATIONS_FIELDS:
|
| 149 |
-
|
| 150 |
-
row_dic[field] =
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
raise KeyError
|
| 154 |
yield id_, row_dic
|
|
|
|
| 1 |
import os
|
| 2 |
+
import ast
|
| 3 |
import datasets
|
| 4 |
import pandas as pd
|
| 5 |
from pprint import pprint
|
|
|
|
| 140 |
)
|
| 141 |
]
|
| 142 |
|
| 143 |
+
def _generate_examples(self, filepath: str):
|
| 144 |
"""Yields examples as (key, example) tuples."""
|
| 145 |
data = pd.read_csv(filepath, sep="\t")
|
| 146 |
for id_, row in data.iterrows():
|
| 147 |
row_dic = row.to_dict()
|
| 148 |
for field in _STR_SEQ_FIELDS + _LANG_ANNOTATIONS_FIELDS:
|
| 149 |
+
if isinstance(row_dic[field], float) and math.isnan(row_dic[field]):
|
| 150 |
+
row_dic[field] = []
|
| 151 |
+
else:
|
| 152 |
+
row_dic[field] = ast.literal_eval(row_dic[field])
|
|
|
|
| 153 |
yield id_, row_dic
|