Datasets:
Sebastian Gehrmann
commited on
Commit
•
337c8dc
1
Parent(s):
5e50336
detokenize target
Browse files- RotoWire_English-German.py +19 -2
- dataset_infos.json +1 -1
RotoWire_English-German.py
CHANGED
@@ -56,6 +56,22 @@ player_line = "<PLAYER> %s <TEAM> %s <POS> %s <RANK> %s <MIN> %d <PTS> %d <FG> %
|
|
56 |
team_line = "%s <TEAM> %s <CITY> %s <TEAM-RESULT> %s <TEAM-PTS> %d <WINS-LOSSES> %d %d <QTRS> %d %d %d %d " \
|
57 |
"<TEAM-AST> %d <3PT> %d <TEAM-FG> %d <TEAM-FT> %d <TEAM-REB> %d <TEAM-TO> %d"
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
class RotowireEnglishGerman(datasets.GeneratorBasedBuilder):
|
60 |
"""Dataset for WNGT2019 shared task on Document-level Generation and Translation."""
|
61 |
|
@@ -478,7 +494,8 @@ class RotowireEnglishGerman(datasets.GeneratorBasedBuilder):
|
|
478 |
with open(filepath, encoding="utf-8") as f:
|
479 |
all_data = json.load(f)
|
480 |
for id_, data in enumerate(all_data):
|
|
|
481 |
data['linearized_input'] = self.linearize_input(data)
|
482 |
-
data['target'] =
|
483 |
-
data['references'] =
|
484 |
yield id_, data
|
|
|
56 |
team_line = "%s <TEAM> %s <CITY> %s <TEAM-RESULT> %s <TEAM-PTS> %d <WINS-LOSSES> %d %d <QTRS> %d %d %d %d " \
|
57 |
"<TEAM-AST> %d <3PT> %d <TEAM-FG> %d <TEAM-FT> %d <TEAM-REB> %d <TEAM-TO> %d"
|
58 |
|
59 |
+
def detokenize(text):
|
60 |
+
"""
|
61 |
+
Untokenizing a text undoes the tokenizing operation, restoring
|
62 |
+
punctuation and spaces to the places that people expect them to be.
|
63 |
+
Ideally, `untokenize(tokenize(text))` should be identical to `text`,
|
64 |
+
except for line breaks.
|
65 |
+
"""
|
66 |
+
step1 = text.replace("`` ", '"').replace(" ''", '"').replace('. . .', '...')
|
67 |
+
step2 = step1.replace(" ( ", " (").replace(" ) ", ") ")
|
68 |
+
step3 = re.sub(r' ([.,:;?!%]+)([ \'"`])', r"\1\2", step2)
|
69 |
+
step4 = re.sub(r' ([.,:;?!%]+)$', r"\1", step3)
|
70 |
+
step5 = step4.replace(" '", "'").replace(" n't", "n't").replace(
|
71 |
+
"can not", "cannot").replace(" 've", "'ve")
|
72 |
+
step6 = step5.replace(" ` ", " '")
|
73 |
+
return step6.strip()
|
74 |
+
|
75 |
class RotowireEnglishGerman(datasets.GeneratorBasedBuilder):
|
76 |
"""Dataset for WNGT2019 shared task on Document-level Generation and Translation."""
|
77 |
|
|
|
494 |
with open(filepath, encoding="utf-8") as f:
|
495 |
all_data = json.load(f)
|
496 |
for id_, data in enumerate(all_data):
|
497 |
+
detok_target = detokenize(" ".join(data['summary_de']))
|
498 |
data['linearized_input'] = self.linearize_input(data)
|
499 |
+
data['target'] = detok_target
|
500 |
+
data['references'] = [detok_target]
|
501 |
yield id_, data
|
dataset_infos.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 40690
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f4a8df1f5677f21148d65ab7b5fb40074f3e5c0fb52bffbf3ebcc551ba5d66ad
|
3 |
size 40690
|