init
Browse files- download_audio.py +6 -2
- download_text.py +32 -0
- main.sh +36 -134
download_audio.py
CHANGED
@@ -96,14 +96,18 @@ def get_audio(dataframe: pd.DataFrame):
|
|
96 |
def process_dataset():
|
97 |
df_metadata = get_metadata()
|
98 |
print(f"metadata: {len(df_metadata)}, {line_no_start} --> {line_no_end}")
|
99 |
-
inputs = [
|
|
|
|
|
|
|
100 |
print(f"filtered unique lines: {len(inputs)}")
|
101 |
if direction == "enA-jaA":
|
102 |
inputs = [g for g in inputs if len(g["side"].unique()) == 2 and set(g["side"].unique()) == sides]
|
103 |
print(f"removed side != 2: {len(inputs)}")
|
104 |
if n_pool == 1:
|
105 |
for g in tqdm(inputs, total=len(inputs)):
|
106 |
-
|
|
|
107 |
print(f"failed:\n{g['url']}")
|
108 |
else:
|
109 |
with Pool(n_pool) as pool:
|
|
|
96 |
def process_dataset():
|
97 |
df_metadata = get_metadata()
|
98 |
print(f"metadata: {len(df_metadata)}, {line_no_start} --> {line_no_end}")
|
99 |
+
inputs = [
|
100 |
+
g for line_no, g in df_metadata.groupby("line_no")
|
101 |
+
if line_no_start <= line_no < line_no_end and not os.path.exists(p_join(cache_dir_feature, f'{line_no}.json'))
|
102 |
+
]
|
103 |
print(f"filtered unique lines: {len(inputs)}")
|
104 |
if direction == "enA-jaA":
|
105 |
inputs = [g for g in inputs if len(g["side"].unique()) == 2 and set(g["side"].unique()) == sides]
|
106 |
print(f"removed side != 2: {len(inputs)}")
|
107 |
if n_pool == 1:
|
108 |
for g in tqdm(inputs, total=len(inputs)):
|
109 |
+
flag = get_audio(g)
|
110 |
+
if not flag:
|
111 |
print(f"failed:\n{g['url']}")
|
112 |
else:
|
113 |
with Pool(n_pool) as pool:
|
download_text.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import tarfile
|
4 |
+
import zipfile
|
5 |
+
import gzip
|
6 |
+
import subprocess
|
7 |
+
from os.path import join as p_join
|
8 |
+
from tqdm import tqdm
|
9 |
+
from multiprocessing import Pool
|
10 |
+
from typing import Optional
|
11 |
+
|
12 |
+
import pandas as pd
|
13 |
+
|
14 |
+
chunk_size = 10
|
15 |
+
url = "https://dl.fbaipublicfiles.com/seamless/data/seamless.dataset.metadata.public.enA-jpn.withduration.tsv.gz"
|
16 |
+
filename = os.path.basename(url)
|
17 |
+
subprocess.run(["wget", url, "-O", filename])
|
18 |
+
df = pd.read_csv(filename, sep='\t', header=None, dtype=str)
|
19 |
+
df.columns = ["cc_warc", "cc_sha", "cc_document_url", "cc_lineno", "paragraph_digest", "sentence_digest", "text_lid_score", "laser_score", "direction", "side", "line_no"]
|
20 |
+
df = df[df.side == "jpn"]
|
21 |
+
df["cc_lineno"] = df["cc_lineno"].astype(int)
|
22 |
+
df.sort_values(by=["cc_warc", "cc_sha", "cc_document_url", "cc_lineno"], inplace=True)
|
23 |
+
batch_size = int(len(df)/chunk_size)
|
24 |
+
start = 0
|
25 |
+
end = batch_size
|
26 |
+
index = 1
|
27 |
+
while start != end:
|
28 |
+
df.iloc[start:end].to_csv(f"seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_{index}.tsv", sep="\t", index=False, header=False)
|
29 |
+
index += 1
|
30 |
+
start = end
|
31 |
+
end += batch_size
|
32 |
+
end = min(len(df), end)
|
main.sh
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# enA-jaA: 718_606 #
|
3 |
####################
|
4 |
export DIRECTION="enA-jaA"
|
5 |
-
|
6 |
export LINE_NO_START=0
|
7 |
export LINE_NO_END=50000
|
8 |
python download_audio.py
|
@@ -23,43 +23,33 @@ export LINE_NO_START=300000
|
|
23 |
export LINE_NO_END=360000
|
24 |
python download_audio.py
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
export LINE_NO_START=150000
|
30 |
-
export LINE_NO_END=180000
|
31 |
-
python download_audio.py
|
32 |
-
|
33 |
-
export LINE_NO_START=180000
|
34 |
-
export LINE_NO_END=210000
|
35 |
python download_audio.py
|
36 |
|
37 |
-
export LINE_NO_START=
|
38 |
-
export LINE_NO_END=
|
39 |
python download_audio.py
|
40 |
|
41 |
-
export LINE_NO_START=
|
42 |
-
export LINE_NO_END=
|
43 |
python download_audio.py
|
44 |
|
45 |
-
export LINE_NO_START=
|
46 |
export LINE_NO_END=300000
|
47 |
python download_audio.py
|
48 |
|
49 |
-
# server 3
|
50 |
export LINE_NO_START=300000
|
51 |
-
export LINE_NO_END=330000
|
52 |
-
python download_audio.py
|
53 |
-
|
54 |
-
export LINE_NO_START=330000
|
55 |
export LINE_NO_END=360000
|
56 |
python download_audio.py
|
57 |
|
58 |
-
|
59 |
-
####################
|
60 |
-
# enA-jpn: 718_606 #
|
61 |
-
####################
|
62 |
-
|
63 |
git clone https://github.com/kpu/preprocess
|
64 |
cd preprocess
|
65 |
git checkout wet
|
@@ -68,115 +58,27 @@ mkdir build
|
|
68 |
cd build
|
69 |
cmake ..
|
70 |
make -j4
|
71 |
-
alias wet_lines="${PWD}/
|
|
|
72 |
wget https://dl.fbaipublicfiles.com/seamless/data/seamless.dataset.metadata.public.enA-jpn.withduration.tsv.gz
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
python
|
93 |
-
|
94 |
-
export LINE_NO_START=120000
|
95 |
-
export LINE_NO_END=150000
|
96 |
-
python download_audio.py
|
97 |
-
|
98 |
-
# server 2
|
99 |
-
export LINE_NO_START=150000
|
100 |
-
export LINE_NO_END=180000
|
101 |
-
python download_audio.py
|
102 |
-
|
103 |
-
export LINE_NO_START=180000
|
104 |
-
export LINE_NO_END=210000
|
105 |
-
python download_audio.py
|
106 |
-
|
107 |
-
export LINE_NO_START=210000
|
108 |
-
export LINE_NO_END=240000
|
109 |
-
python download_audio.py
|
110 |
-
|
111 |
-
export LINE_NO_START=240000
|
112 |
-
export LINE_NO_END=270000
|
113 |
-
python download_audio.py
|
114 |
-
|
115 |
-
export LINE_NO_START=270000
|
116 |
-
export LINE_NO_END=300000
|
117 |
-
python download_audio.py
|
118 |
-
|
119 |
-
# server 3
|
120 |
-
export LINE_NO_START=300000
|
121 |
-
export LINE_NO_END=330000
|
122 |
-
python download_audio.py
|
123 |
-
|
124 |
-
export LINE_NO_START=330000
|
125 |
-
export LINE_NO_END=360000
|
126 |
-
python download_audio.py
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
export LINE_NO_START=360000
|
132 |
-
export LINE_NO_END=390000
|
133 |
-
python download_audio.py
|
134 |
-
|
135 |
-
export LINE_NO_START=390000
|
136 |
-
export LINE_NO_END=420000
|
137 |
-
python download_audio.py
|
138 |
-
|
139 |
-
export LINE_NO_START=420000
|
140 |
-
export LINE_NO_END=450000
|
141 |
-
python download_audio.py
|
142 |
-
|
143 |
-
# server 4
|
144 |
-
export LINE_NO_START=450000
|
145 |
-
export LINE_NO_END=480000
|
146 |
-
python download_audio.py
|
147 |
-
|
148 |
-
export LINE_NO_START=480000
|
149 |
-
export LINE_NO_END=510000
|
150 |
-
python download_audio.py
|
151 |
-
|
152 |
-
export LINE_NO_START=510000
|
153 |
-
export LINE_NO_END=540000
|
154 |
-
python download_audio.py
|
155 |
-
|
156 |
-
export LINE_NO_START=540000
|
157 |
-
export LINE_NO_END=570000
|
158 |
-
python download_audio.py
|
159 |
-
|
160 |
-
export LINE_NO_START=570000
|
161 |
-
export LINE_NO_END=600000
|
162 |
-
python download_audio.py
|
163 |
-
|
164 |
-
|
165 |
-
# server 5
|
166 |
-
export LINE_NO_START=600000
|
167 |
-
export LINE_NO_END=630000
|
168 |
-
python download_audio.py
|
169 |
-
|
170 |
-
export LINE_NO_START=630000
|
171 |
-
export LINE_NO_END=660000
|
172 |
-
python download_audio.py
|
173 |
-
|
174 |
-
export LINE_NO_START=660000
|
175 |
-
export LINE_NO_END=690000
|
176 |
-
python download_audio.py
|
177 |
-
|
178 |
-
export LINE_NO_START=690000
|
179 |
-
export LINE_NO_END=720000
|
180 |
-
python download_audio.py
|
181 |
-
|
182 |
|
|
|
2 |
# enA-jaA: 718_606 #
|
3 |
####################
|
4 |
export DIRECTION="enA-jaA"
|
5 |
+
export MAX_RETRY=10
|
6 |
export LINE_NO_START=0
|
7 |
export LINE_NO_END=50000
|
8 |
python download_audio.py
|
|
|
23 |
export LINE_NO_END=360000
|
24 |
python download_audio.py
|
25 |
|
26 |
+
######################
|
27 |
+
# enA-jpn: 1_468_292 #
|
28 |
+
######################
|
29 |
+
# AUDIO
|
30 |
+
export DIRECTION="enA-jpn"
|
31 |
|
32 |
+
export LINE_NO_START=0
|
33 |
+
export LINE_NO_END=50000
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
python download_audio.py
|
35 |
|
36 |
+
export LINE_NO_START=50000
|
37 |
+
export LINE_NO_END=100000
|
38 |
python download_audio.py
|
39 |
|
40 |
+
export LINE_NO_START=100000
|
41 |
+
export LINE_NO_END=150000
|
42 |
python download_audio.py
|
43 |
|
44 |
+
export LINE_NO_START=150000
|
45 |
export LINE_NO_END=300000
|
46 |
python download_audio.py
|
47 |
|
|
|
48 |
export LINE_NO_START=300000
|
|
|
|
|
|
|
|
|
49 |
export LINE_NO_END=360000
|
50 |
python download_audio.py
|
51 |
|
52 |
+
# TEXT
|
|
|
|
|
|
|
|
|
53 |
git clone https://github.com/kpu/preprocess
|
54 |
cd preprocess
|
55 |
git checkout wet
|
|
|
58 |
cd build
|
59 |
cmake ..
|
60 |
make -j4
|
61 |
+
alias wet_lines="${PWD}/build/bin/wet_lines"
|
62 |
+
cd ../
|
63 |
wget https://dl.fbaipublicfiles.com/seamless/data/seamless.dataset.metadata.public.enA-jpn.withduration.tsv.gz
|
64 |
+
cp ../download_text.py ./
|
65 |
+
python download_text.py
|
66 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_1.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_1.tsv
|
67 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_2.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_2.tsv
|
68 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_3.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_3.tsv
|
69 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_4.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_4.tsv
|
70 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_5.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_5.tsv
|
71 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_6.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_6.tsv
|
72 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_7.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_7.tsv
|
73 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_8.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_8.tsv
|
74 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_9.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_9.tsv
|
75 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_10.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_10.tsv
|
76 |
+
cat seamless.dataset.metadata.public.enA-jpn.withduration.reordered.batch_11.tsv | egrep ^crawl-data | tr '\t' ' ' | wet_lines | tee seamless.dataset.metadata.public.jpn.batch_11.tsv
|
77 |
+
|
78 |
+
|
79 |
+
########
|
80 |
+
# NLLB #
|
81 |
+
########
|
82 |
+
# https://www.kecl.ntt.co.jp/icl/lirg/jparacrawl/
|
83 |
+
python -c "from datasets import load_dataset; load_dataset('allenai/nllb', 'eng_Latn-jpn_Jpan')"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|