up
Browse files- da.jsonl.gz +3 -0
- de.jsonl.gz +3 -0
- el.jsonl.gz +3 -0
- en00.jsonl.gz +3 -0
- en01.jsonl.gz +3 -0
- es.jsonl.gz +3 -0
- fi.jsonl.gz +3 -0
- fr.jsonl.gz +3 -0
- hr.jsonl.gz +3 -0
- hu.jsonl.gz +3 -0
- it.jsonl.gz +3 -0
- ja.jsonl.gz +3 -0
- lang_detect.py +66 -0
- nl.jsonl.gz +3 -0
- pl.jsonl.gz +3 -0
- pt.jsonl.gz +3 -0
- ro.jsonl.gz +3 -0
- ru.jsonl.gz +3 -0
- sr.jsonl.gz +3 -0
- sv.jsonl.gz +3 -0
- tr.jsonl.gz +3 -0
- zh.jsonl.gz +3 -0
da.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b28a91a0923194efe62bcf1400d80664a780d4a1a82bdae2e8dbeed2437982c1
|
3 |
+
size 15563415
|
de.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2876ead94ab7e7c76f4af8fd459dacd61bdf494e6a06e2d90d6627ec9ac04eae
|
3 |
+
size 154819990
|
el.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d29df328888f6d3fc573d62c7770c6b41a503a54c586ba48aa84b9c58b8e4fd
|
3 |
+
size 16445708
|
en00.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3073901f8d55086adfd8b32a1a556dbeac0a412c1f9bc10207a86352f2cc5df9
|
3 |
+
size 26907588740
|
en01.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b4b0ea62d475cdd21f604cd9a1292d2ef9717e05a6ea81b1f4d5c07396a61bbe
|
3 |
+
size 31229225629
|
es.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:523f8295fe828e262882712952d57cd608d7fee6fb4c0d323705a6f452199225
|
3 |
+
size 166505948
|
fi.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:12138b90b49e0fc8ad323fc15ebb3aba6243fab47f06a5a3e3258b5fbec1b3c8
|
3 |
+
size 18806311
|
fr.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a0f450cecdc0a8a14538f10232c68303a39474e870b9594d737ec696bea16fd
|
3 |
+
size 85901241
|
hr.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c2e7c888345477dade0df8cbcc9f1cead684bc1e5ec26c4768d262caea52e882
|
3 |
+
size 14930738
|
hu.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dbe83aa01e8e069bc0946a60e94625fff0d9e51f1b41f9722236853c1628e902
|
3 |
+
size 10803651
|
it.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a9e4ff3dfcb7bb72db0da753e2076d951953d6d550c2e766b91f41fae82c4155
|
3 |
+
size 56179299
|
ja.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:afed659cd059258c52064adddadc53aac665f3f6f6829c5df6ca1fbd0f72dc98
|
3 |
+
size 22836998
|
lang_detect.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gzip
|
2 |
+
import sys
|
3 |
+
import os
|
4 |
+
import tqdm
|
5 |
+
import requests
|
6 |
+
import json
|
7 |
+
|
8 |
+
import fasttext
|
9 |
+
fasttext.FastText.eprint = lambda x: None #Silence useless warning: https://github.com/facebookresearch/fastText/issues/1067
|
10 |
+
|
11 |
+
def http_get(url, path):
|
12 |
+
"""
|
13 |
+
Downloads a URL to a given path on disc
|
14 |
+
"""
|
15 |
+
if os.path.dirname(path) != '':
|
16 |
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
17 |
+
|
18 |
+
req = requests.get(url, stream=True)
|
19 |
+
if req.status_code != 200:
|
20 |
+
print("Exception when trying to download {}. Response {}".format(url, req.status_code), file=sys.stderr)
|
21 |
+
req.raise_for_status()
|
22 |
+
return
|
23 |
+
|
24 |
+
download_filepath = path+"_part"
|
25 |
+
with open(download_filepath, "wb") as file_binary:
|
26 |
+
content_length = req.headers.get('Content-Length')
|
27 |
+
total = int(content_length) if content_length is not None else None
|
28 |
+
progress = tqdm.tqdm(unit="B", total=total, unit_scale=True)
|
29 |
+
for chunk in req.iter_content(chunk_size=1024):
|
30 |
+
if chunk: # filter out keep-alive new chunks
|
31 |
+
progress.update(len(chunk))
|
32 |
+
file_binary.write(chunk)
|
33 |
+
|
34 |
+
os.rename(download_filepath, path)
|
35 |
+
progress.close()
|
36 |
+
|
37 |
+
|
38 |
+
model_path = 'lid.176.bin'
|
39 |
+
if not os.path.exists(model_path):
|
40 |
+
http_get('https://dl.fbaipublicfiles.com/fasttext/supervised-models/'+model_path, model_path)
|
41 |
+
global_fasttext_lang_id = fasttext.load_model(model_path)
|
42 |
+
|
43 |
+
def lang_detect(text: str) -> str:
|
44 |
+
return global_fasttext_lang_id.predict(text.lower().replace("\r\n", " ").replace("\n", " ").strip())[0][0].split('__')[-1]
|
45 |
+
|
46 |
+
filepaths = sorted(sys.argv[1:])
|
47 |
+
|
48 |
+
output_folder = "question_best_answer_lang"
|
49 |
+
output_files = {}
|
50 |
+
|
51 |
+
try:
|
52 |
+
for filepath in filepaths:
|
53 |
+
with gzip.open(filepath, 'rt') as fIn:
|
54 |
+
for line in tqdm.tqdm(fIn, desc=filepath):
|
55 |
+
data = json.loads(line)
|
56 |
+
text = data['title']+" "+data['body']
|
57 |
+
lang = lang_detect(text)
|
58 |
+
|
59 |
+
if lang not in output_files:
|
60 |
+
output_files[lang] = gzip.open(f"{output_folder}/{lang}.jsonl.gz", "wt")
|
61 |
+
|
62 |
+
output_files[lang].write(line)
|
63 |
+
finally:
|
64 |
+
for outfile in output_files.values():
|
65 |
+
outfile.close()
|
66 |
+
|
nl.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8c1863d8290602dc0f501cdb641397d0ee9ab52a9a393e22866f22c7c2c5b00f
|
3 |
+
size 30222723
|
pl.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:96cd343084afe61a08c0d0b89b7d2ab0a973bad2549520908f347ba247b2722c
|
3 |
+
size 14516883
|
pt.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b82f64607e8945967e9414df96e23f070e55dff1e47fb707cdef6ec5310e3fe0
|
3 |
+
size 139876600
|
ro.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f729d7b4e3bb05f7b50bc32bf40d3c97ea5baa2a0b6c7113544e2ab6c074868c
|
3 |
+
size 26639774
|
ru.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cadd82d500c6eed113160959aa9c9bca1dd8ee7f6096a18bc12138c794814745
|
3 |
+
size 42949076
|
sr.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:466ee2c23f2e00896903d08e5e633de7ef9b7f200ba598eaf4007df61ac10823
|
3 |
+
size 23078320
|
sv.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2204bf37bd923c965a0cd9d6d739a3b10b1a3d2f4924ffa8d4ce3bf726bafcc8
|
3 |
+
size 30362441
|
tr.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7435a7cab9c7f3271822371bd33742ae05cfa893ef3afc7c9b8e5168dcb1592f
|
3 |
+
size 17026502
|
zh.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3db0f767a756f6bd9ff1f30c9ac9a206d87319f83958868f1f01d915813db789
|
3 |
+
size 26735537
|