Upload TexPrax.py
Browse files- TexPrax.py +4 -3
TexPrax.py
CHANGED
|
@@ -226,13 +226,14 @@ class TexPraxDataset(datasets.GeneratorBasedBuilder):
|
|
| 226 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 227 |
with open(filepath, encoding="utf-8") as f:
|
| 228 |
creader = csv.reader(f, delimiter=';', quotechar='"')
|
|
|
|
| 229 |
for key, row in enumerate(creader):
|
| 230 |
print(key, row)
|
| 231 |
if self.config.name == "sentence_cl":
|
| 232 |
idx, sentence, label = row
|
| 233 |
# Yields examples as (key, example) tuples
|
| 234 |
yield key, {
|
| 235 |
-
"
|
| 236 |
"sentence": sentence,
|
| 237 |
"label": label,
|
| 238 |
}
|
|
@@ -240,9 +241,9 @@ class TexPraxDataset(datasets.GeneratorBasedBuilder):
|
|
| 240 |
idx, sentence, labels = row
|
| 241 |
# Yields examples as (key, example) tuples
|
| 242 |
yield key, {
|
| 243 |
-
"
|
| 244 |
"tokens": [t.strip() for t in ast.literal_eval(sentence)],
|
| 245 |
-
"
|
| 246 |
}
|
| 247 |
|
| 248 |
|
|
|
|
| 226 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 227 |
with open(filepath, encoding="utf-8") as f:
|
| 228 |
creader = csv.reader(f, delimiter=';', quotechar='"')
|
| 229 |
+
next(creader) # skip header
|
| 230 |
for key, row in enumerate(creader):
|
| 231 |
print(key, row)
|
| 232 |
if self.config.name == "sentence_cl":
|
| 233 |
idx, sentence, label = row
|
| 234 |
# Yields examples as (key, example) tuples
|
| 235 |
yield key, {
|
| 236 |
+
"id": idx,
|
| 237 |
"sentence": sentence,
|
| 238 |
"label": label,
|
| 239 |
}
|
|
|
|
| 241 |
idx, sentence, labels = row
|
| 242 |
# Yields examples as (key, example) tuples
|
| 243 |
yield key, {
|
| 244 |
+
"id": idx,
|
| 245 |
"tokens": [t.strip() for t in ast.literal_eval(sentence)],
|
| 246 |
+
"entities": [l.strip() for l in ast.literal_eval(labels)],
|
| 247 |
}
|
| 248 |
|
| 249 |
|