Matej Klemen
commited on
Commit
•
c8f8673
1
Parent(s):
89ba707
Copy data to avoid overriding original sentence data
Browse files
solar3.py
CHANGED
@@ -2,6 +2,7 @@ import logging
|
|
2 |
import os
|
3 |
import re
|
4 |
import xml.etree.ElementTree as ET
|
|
|
5 |
from itertools import groupby
|
6 |
from typing import Optional
|
7 |
|
@@ -223,7 +224,8 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
223 |
assert len(involved_src_sents) > 0 or len(involved_tgt_sents) > 0
|
224 |
|
225 |
if len(involved_src_sents) > 0:
|
226 |
-
src_sent_data = source_data[involved_src_sents[0]]
|
|
|
227 |
for src_sent_id in involved_src_sents[1:]:
|
228 |
curr_sent_data = source_data[src_sent_id]
|
229 |
src_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
@@ -241,7 +243,8 @@ class Solar3(datasets.GeneratorBasedBuilder):
|
|
241 |
tok2position[_tok] = _pos
|
242 |
|
243 |
if len(involved_tgt_sents) > 0:
|
244 |
-
tgt_sent_data = target_data[involved_tgt_sents[0]]
|
|
|
245 |
for tgt_sent_id in involved_tgt_sents[1:]:
|
246 |
curr_sent_data = target_data[tgt_sent_id]
|
247 |
tgt_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
|
|
2 |
import os
|
3 |
import re
|
4 |
import xml.etree.ElementTree as ET
|
5 |
+
from copy import deepcopy
|
6 |
from itertools import groupby
|
7 |
from typing import Optional
|
8 |
|
|
|
224 |
assert len(involved_src_sents) > 0 or len(involved_tgt_sents) > 0
|
225 |
|
226 |
if len(involved_src_sents) > 0:
|
227 |
+
src_sent_data = deepcopy(source_data[involved_src_sents[0]])
|
228 |
+
|
229 |
for src_sent_id in involved_src_sents[1:]:
|
230 |
curr_sent_data = source_data[src_sent_id]
|
231 |
src_sent_data["id_token"].extend(curr_sent_data["id_token"])
|
|
|
243 |
tok2position[_tok] = _pos
|
244 |
|
245 |
if len(involved_tgt_sents) > 0:
|
246 |
+
tgt_sent_data = deepcopy(target_data[involved_tgt_sents[0]])
|
247 |
+
|
248 |
for tgt_sent_id in involved_tgt_sents[1:]:
|
249 |
curr_sent_data = target_data[tgt_sent_id]
|
250 |
tgt_sent_data["id_token"].extend(curr_sent_data["id_token"])
|