Update WikiConvert.py
Browse files- WikiConvert.py +19 -19
WikiConvert.py
CHANGED
|
@@ -48,7 +48,7 @@ Language Modelling with Cardinal Number Annotations.
|
|
| 48 |
"""
|
| 49 |
|
| 50 |
#_URL = "https://github.com/avi-jit/numeracy-literacy/"
|
| 51 |
-
_URL = "https://huggingface.co/datasets/usc-isi/WikiConvert/
|
| 52 |
_URLS = {
|
| 53 |
"train": _URL + "train_wiki.json",
|
| 54 |
"dev": _URL + "dev_wiki.json",
|
|
@@ -113,21 +113,21 @@ class WikiConvert(datasets.GeneratorBasedBuilder):
|
|
| 113 |
logger.info("generating examples from = %s", filepath)
|
| 114 |
key = 0
|
| 115 |
with open(filepath, encoding="utf-8") as f:
|
| 116 |
-
|
| 117 |
-
for row in f:
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
ds = json.loads(row)
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
| 48 |
"""
|
| 49 |
|
| 50 |
#_URL = "https://github.com/avi-jit/numeracy-literacy/"
|
| 51 |
+
_URL = "https://huggingface.co/datasets/usc-isi/WikiConvert/resolve/main/"
|
| 52 |
_URLS = {
|
| 53 |
"train": _URL + "train_wiki.json",
|
| 54 |
"dev": _URL + "dev_wiki.json",
|
|
|
|
| 113 |
logger.info("generating examples from = %s", filepath)
|
| 114 |
key = 0
|
| 115 |
with open(filepath, encoding="utf-8") as f:
|
| 116 |
+
ds = json.load(f)
|
| 117 |
+
#for row in f:
|
| 118 |
+
# yield key, {"comment": row[:100], "id": 1, "offset": 2, "length": 3, "magnitude": 4, "number": 5, "UNIQUE_STORY_INDEX": "6"}
|
| 119 |
+
# key += 1
|
| 120 |
+
#print(row[:100])
|
| 121 |
+
#ds = json.loads(row)
|
| 122 |
+
# print(len(ds))
|
| 123 |
+
for row in ds:
|
| 124 |
+
yield key, {
|
| 125 |
+
"id": row["id"],
|
| 126 |
+
"UNIQUE_STORY_INDEX": row["UNIQUE_STORY_INDEX"],
|
| 127 |
+
"offset": row["offset"],
|
| 128 |
+
"length": row["length"],
|
| 129 |
+
"magnitude": row["magnitude"],
|
| 130 |
+
"comment": row["comment"],
|
| 131 |
+
"number": row["number"],
|
| 132 |
+
}
|
| 133 |
+
key += 1
|