Update jparacrawl.py
Browse files- jparacrawl.py +4 -4
jparacrawl.py
CHANGED
@@ -158,7 +158,7 @@ class JParaCrawl(datasets.GeneratorBasedBuilder):
|
|
158 |
break
|
159 |
assert df is not None, extracted_path
|
160 |
|
161 |
-
def _split(line: str, col: int):
|
162 |
return line.split('\t', 4)[col].strip()
|
163 |
|
164 |
df['domain'] = df[0].apply(partial(_split, col=0))
|
@@ -168,7 +168,7 @@ class JParaCrawl(datasets.GeneratorBasedBuilder):
|
|
168 |
df['ja'] = df[0].apply(partial(_split, col=4))
|
169 |
df = df.drop_duplicates(subset=[non_ja, 'ja'])
|
170 |
|
171 |
-
def _normalize(s: str):
|
172 |
return unicodedata.normalize("NFKC", s).replace('\t', ' ').strip()
|
173 |
|
174 |
_id = 0
|
@@ -178,8 +178,8 @@ class JParaCrawl(datasets.GeneratorBasedBuilder):
|
|
178 |
"url": row["url"],
|
179 |
"probability": float(row["probability"]),
|
180 |
"translation": {
|
181 |
-
non_ja: _normalize(row[non_ja]
|
182 |
-
"ja": _normalize(row["ja"]
|
183 |
},
|
184 |
}
|
185 |
# Make sure that both translations are non-empty.
|
|
|
158 |
break
|
159 |
assert df is not None, extracted_path
|
160 |
|
161 |
+
def _split(line: str, col: int) -> str:
|
162 |
return line.split('\t', 4)[col].strip()
|
163 |
|
164 |
df['domain'] = df[0].apply(partial(_split, col=0))
|
|
|
168 |
df['ja'] = df[0].apply(partial(_split, col=4))
|
169 |
df = df.drop_duplicates(subset=[non_ja, 'ja'])
|
170 |
|
171 |
+
def _normalize(s: str) -> str:
|
172 |
return unicodedata.normalize("NFKC", s).replace('\t', ' ').strip()
|
173 |
|
174 |
_id = 0
|
|
|
178 |
"url": row["url"],
|
179 |
"probability": float(row["probability"]),
|
180 |
"translation": {
|
181 |
+
non_ja: _normalize(row[non_ja]),
|
182 |
+
"ja": _normalize(row["ja"]),
|
183 |
},
|
184 |
}
|
185 |
# Make sure that both translations are non-empty.
|