hpprc commited on
Commit
12e7591
·
verified ·
1 Parent(s): 237d767

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -1
README.md CHANGED
@@ -30,4 +30,39 @@ size_categories:
30
  ---
31
 
32
 
33
- HF Datasets version of [Tanaka Corpus](http://www.edrdg.org/wiki/index.php/Tanaka_Corpus).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ---
31
 
32
 
33
+ HF Datasets version of [Tanaka Corpus](http://www.edrdg.org/wiki/index.php/Tanaka_Corpus).
34
+
35
+
36
+ ## Preprocess for HF Datasets
37
+
38
+ Download dataset
39
+
40
+ ```bash
41
+ wget ftp://ftp.edrdg.org/pub/Nihongo/examples.utf.gz
42
+ ```
43
+
44
+ then,
45
+
46
+ ```python
47
+ import re
48
+ from pathlib import Path
49
+
50
+ from more_itertools import chunked
51
+
52
+ import datasets as ds
53
+
54
+ data = []
55
+ with Path("examples.utf").open() as f:
56
+ for row, _ in chunked(f, 2):
57
+ ja, en, idx = re.findall(r"A: (.*?)\t(.*?)#ID=(.*$)", row)[0]
58
+ data.append(
59
+ {
60
+ "id": idx,
61
+ "ja": ja.strip(),
62
+ "en": en.strip(),
63
+ }
64
+ )
65
+
66
+ dataset = ds.Dataset.from_list(data)
67
+ dataset.push_to_hub("hpprc/tanaka-corpus")
68
+ ```