Abinaya Mahendiran
commited on
Commit
•
a985f6d
1
Parent(s):
85ec538
Minor fix to data loader script
Browse files
xsum.py
CHANGED
@@ -117,3 +117,20 @@ class Xsum(datasets.GeneratorBasedBuilder):
|
|
117 |
exple["gem_parent_id"] = exple["gem_id"]
|
118 |
exple["gem_id"] = f"{self.config.name}-{split}-{id_}"
|
119 |
yield id_, exple
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
exple["gem_parent_id"] = exple["gem_id"]
|
118 |
exple["gem_id"] = f"{self.config.name}-{split}-{id_}"
|
119 |
yield id_, exple
|
120 |
+
else:
|
121 |
+
with open(filepath, "r", encoding="utf-8") as f:
|
122 |
+
split_ids = json.load(f)
|
123 |
+
for id_, i in enumerate(split_ids[split]):
|
124 |
+
with open(os.path.join(filepaths, i + ".summary"), "r", encoding="utf-8") as f:
|
125 |
+
text = "".join(
|
126 |
+
[line for line in f.readlines() if line not in _XSUM_REMOVE_LINES and line.strip()]
|
127 |
+
)
|
128 |
+
segs = text.split("[SN]")
|
129 |
+
yield id_, {
|
130 |
+
"gem_id": f"{self.config.name}-{split}-{id_}",
|
131 |
+
"gem_parent_id": f"{self.config.name}-{split}-{id_}",
|
132 |
+
"xsum_id": i,
|
133 |
+
"document": segs[8].strip(),
|
134 |
+
"target": segs[6].strip(),
|
135 |
+
"references": [] if split == "train" else [segs[6].strip()],
|
136 |
+
}
|