US-02 submit 641024cf91b6c47969fb53e8704ba1ad,ea705bef166e509b6d9972d168ea8c0d,97c7b076ec3c6e39a4672a13af8f45c5,dabc84b52d8569f2f5c153087150628d,b55fe351c4e50212c01421a956b37166

#79177
This view is limited to 50 files because it contains too many changes.  See the raw diff here.
Files changed (50) hide show
  1. .gitattributes +14 -54
  2. .gitignore +0 -7
  3. .save/100k_sampling.py +0 -18
  4. .save/filters.py +0 -170
  5. .save/filters.sh +0 -21
  6. .save/filters_epub.py +0 -170
  7. .save/filters_tiasang.py +0 -170
  8. .save/parquet2jsonl.py +0 -58
  9. .save/parquet2jsonl.sh +0 -12
  10. README.md +0 -37
  11. crawl-data/CC-MAIN-2013-20/segments/1368696381249/warc/CC-MAIN-20130516092621-00038-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  12. crawl-data/CC-MAIN-2013-20/segments/1368696381249/warc/CC-MAIN-20130516092621-00039-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  13. crawl-data/CC-MAIN-2013-20/segments/1368696381249/warc/CC-MAIN-20130516092621-00059-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  14. crawl-data/CC-MAIN-2013-20/segments/1368696381630/warc/CC-MAIN-20130516092621-00009-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  15. crawl-data/CC-MAIN-2013-20/segments/1368696381630/warc/CC-MAIN-20130516092621-00070-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  16. crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00021-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  17. crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00058-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  18. crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00072-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  19. crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00081-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  20. crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00007-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  21. crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00011-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  22. crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00048-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  23. crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00051-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  24. crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00070-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  25. crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00083-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  26. crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00001-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  27. crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00018-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  28. crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00039-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  29. crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00046-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  30. crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00013-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  31. crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00023-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  32. crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00027-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  33. crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00047-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  34. crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00067-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  35. crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00072-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  36. crawl-data/CC-MAIN-2013-20/segments/1368696382398/warc/CC-MAIN-20130516092622-00003-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  37. crawl-data/CC-MAIN-2013-20/segments/1368696382398/warc/CC-MAIN-20130516092622-00006-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  38. crawl-data/CC-MAIN-2013-20/segments/1368696382398/warc/CC-MAIN-20130516092622-00019-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  39. crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00001-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  40. crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00031-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  41. crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00046-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  42. crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00074-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  43. crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00080-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  44. crawl-data/CC-MAIN-2013-20/segments/1368696382503/warc/CC-MAIN-20130516092622-00020-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  45. crawl-data/CC-MAIN-2013-20/segments/1368696382503/warc/CC-MAIN-20130516092622-00074-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  46. crawl-data/CC-MAIN-2013-20/segments/1368696382584/warc/CC-MAIN-20130516092622-00001-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  47. crawl-data/CC-MAIN-2013-20/segments/1368696382584/warc/CC-MAIN-20130516092622-00007-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  48. crawl-data/CC-MAIN-2013-20/segments/1368696382584/warc/CC-MAIN-20130516092622-00034-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  49. crawl-data/CC-MAIN-2013-20/segments/1368696382705/warc/CC-MAIN-20130516092622-00038-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
  50. crawl-data/CC-MAIN-2013-20/segments/1368696382705/warc/CC-MAIN-20130516092622-00044-ip-10-60-113-184.ec2.internal.jsonl.xz +0 -3
.gitattributes CHANGED
@@ -1,54 +1,14 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.lz4 filter=lfs diff=lfs merge=lfs -text
12
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
- *.model filter=lfs diff=lfs merge=lfs -text
14
- *.msgpack filter=lfs diff=lfs merge=lfs -text
15
- *.npy filter=lfs diff=lfs merge=lfs -text
16
- *.npz filter=lfs diff=lfs merge=lfs -text
17
- *.onnx filter=lfs diff=lfs merge=lfs -text
18
- *.ot filter=lfs diff=lfs merge=lfs -text
19
- *.parquet filter=lfs diff=lfs merge=lfs -text
20
- *.pb filter=lfs diff=lfs merge=lfs -text
21
- *.pickle filter=lfs diff=lfs merge=lfs -text
22
- *.pkl filter=lfs diff=lfs merge=lfs -text
23
- *.pt filter=lfs diff=lfs merge=lfs -text
24
- *.pth filter=lfs diff=lfs merge=lfs -text
25
- *.rar filter=lfs diff=lfs merge=lfs -text
26
- *.safetensors filter=lfs diff=lfs merge=lfs -text
27
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
- *.tar.* filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- # Audio files - uncompressed
37
- *.pcm filter=lfs diff=lfs merge=lfs -text
38
- *.sam filter=lfs diff=lfs merge=lfs -text
39
- *.raw filter=lfs diff=lfs merge=lfs -text
40
- # Audio files - compressed
41
- *.aac filter=lfs diff=lfs merge=lfs -text
42
- *.flac filter=lfs diff=lfs merge=lfs -text
43
- *.mp3 filter=lfs diff=lfs merge=lfs -text
44
- *.ogg filter=lfs diff=lfs merge=lfs -text
45
- *.wav filter=lfs diff=lfs merge=lfs -text
46
- # Image files - uncompressed
47
- *.bmp filter=lfs diff=lfs merge=lfs -text
48
- *.gif filter=lfs diff=lfs merge=lfs -text
49
- *.png filter=lfs diff=lfs merge=lfs -text
50
- *.tiff filter=lfs diff=lfs merge=lfs -text
51
- # Image files - compressed
52
- *.jpg filter=lfs diff=lfs merge=lfs -text
53
- *.jpeg filter=lfs diff=lfs merge=lfs -text
54
- *.webp filter=lfs diff=lfs merge=lfs -text
 
1
+ crawl-data/CC-MAIN-2022-49/segments/1669446711121.31/warc/CC-MAIN-20221206225143-20221207015143-00727.jsonl.xz filter=lfs diff=lfs merge=lfs -text
2
+ crawl-data/CC-MAIN-2019-18/segments/1555578529472.24/warc/CC-MAIN-20190420080927-20190420102127-00069.jsonl.xz filter=lfs diff=lfs merge=lfs -text
3
+ crawl-data/CC-MAIN-2021-25/segments/1623488273983.63/warc/CC-MAIN-20210621120456-20210621150456-00288.jsonl.xz filter=lfs diff=lfs merge=lfs -text
4
+ crawl-data/CC-MAIN-2022-40/segments/1664030334987.39/warc/CC-MAIN-20220927033539-20220927063539-00769.jsonl.xz filter=lfs diff=lfs merge=lfs -text
5
+ crawl-data/CC-MAIN-2021-39/segments/1631780057427.71/warc/CC-MAIN-20210923165408-20210923195408-00372.jsonl.xz filter=lfs diff=lfs merge=lfs -text
6
+ crawl-data/CC-MAIN-2013-48/segments/1386163049631/warc/CC-MAIN-20131204131729-00014-ip-10-33-133-15.ec2.internal.jsonl.xz filter=lfs diff=lfs merge=lfs -text
7
+ crawl-data/CC-MAIN-2022-49/segments/1669446710534.53/warc/CC-MAIN-20221128171516-20221128201516-00593.jsonl.xz filter=lfs diff=lfs merge=lfs -text
8
+ crawl-data/CC-MAIN-2021-43/segments/1634323588053.38/warc/CC-MAIN-20211027022823-20211027052823-00422.jsonl.xz filter=lfs diff=lfs merge=lfs -text
9
+ crawl-data/CC-MAIN-2013-48/segments/1386164128316/warc/CC-MAIN-20131204133528-00012-ip-10-33-133-15.ec2.internal.jsonl.xz filter=lfs diff=lfs merge=lfs -text
10
+ crawl-data/CC-MAIN-2022-40/segments/1664030337446.8/warc/CC-MAIN-20221003231906-20221004021906-00129.jsonl.xz filter=lfs diff=lfs merge=lfs -text
11
+ crawl-data/CC-MAIN-2018-26/segments/1529267860684.14/warc/CC-MAIN-20180618164208-20180618184208-00065.jsonl.xz filter=lfs diff=lfs merge=lfs -text
12
+ crawl-data/CC-MAIN-2016-18/segments/1461860118369.35/warc/CC-MAIN-20160428161518-00208-ip-10-239-7-51.ec2.internal.jsonl.xz filter=lfs diff=lfs merge=lfs -text
13
+ crawl-data/CC-MAIN-2021-49/segments/1637964358323.91/warc/CC-MAIN-20211127223710-20211128013710-00570.jsonl.xz filter=lfs diff=lfs merge=lfs -text
14
+ crawl-data/CC-MAIN-2018-39/segments/1537267158958.72/warc/CC-MAIN-20180923020407-20180923040807-00201.jsonl.xz filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore DELETED
@@ -1,7 +0,0 @@
1
- filtered
2
- automerge.py
3
- *.jsonl
4
- nohup.out
5
- *.bin
6
- jsonl
7
-
 
 
 
 
 
 
 
 
.save/100k_sampling.py DELETED
@@ -1,18 +0,0 @@
1
- import glob, sys, gzip, random, json
2
-
3
- dumps = glob.glob("CC-MAIN-*")
4
- for dump in dumps:
5
- print(dump)
6
- buckets = glob.glob(f"{dump}/CC-MAIN-*")
7
- for bucket in buckets:
8
- bucket = bucket.replace(f"{dump}/", f"{dump}_")
9
- bucket = bucket.replace("CC-MAIN-", "")
10
- with gzip.open(f"jsonl/{bucket}.jsonl.gz") as fin:
11
- count = 0
12
- for line in fin:
13
- if random.randint(0, 90) < 3:
14
- count += 1
15
- text = json.loads(line)["text"]
16
- ss = json.dumps({ "text" : text }, ensure_ascii = False)
17
- print(ss)
18
- if count == 1000: break
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.save/filters.py DELETED
@@ -1,170 +0,0 @@
1
- import json, sys, gzip, glob, lzma
2
- import re, unicodedata
3
-
4
- try:
5
- sys.argv[2]
6
- logging = True
7
- except:
8
- logging = False
9
-
10
- import fasttext
11
- fasttext_model = fasttext.load_model("fasttext_good_vs_c4_001.bin")
12
- def fasttext_predict(text) -> tuple:
13
- result = fasttext_model.predict(text)
14
- label = result[0][0]
15
- prob = result[1][0]
16
- return label, prob
17
-
18
- syms = set("khum toap chuyn mien khuech khun nun lin dong buan kay nhuyen ruet duet khoap lum nhit khoanh kheng lieng xuap thia luot truynh khoay thy quap vien chieng duya luech mai moam nguyech chuych phuan hach xuyen chum phoeng duyu giech suya loam choam bich biu phuya trai doa khim xom phec cunh buch quep rien meu muoi lunh uap penh xach chuang triec luo khi soi choo muu phun chuen meng oai nghenh toen que troam tap gheu cheu chuam rao khuynh nec phu ruom xuech thoac tuon hech bien ghi duyp ping khoi bap koai suyp thoam chieu gienh noe sap cau loap chay day pinh chuo cieu goao duon min nuyn mia nen nang thoao rech nam troanh lit toong ngha thuonh toac hooc tuat genh cup phia linh chich nhoai giua meo ngoat quyu chic xeu lep vic kat chuyech niet soeng khe hao nganh nhuon thau nuoch chuyenh tup tac boet piep vot choanh goam xec tuay doc dac bech oeo dang hoach loen set goon pooc noon toat phuyn nia nghau uyt kong nhoem kich bic xuyec coang nget thuam tuem khuyenh khoeo lien ging boo chot nghin voang man sut koa che quan uang moon ung hien nghit sun hue kien quai ghec hiu puya kuan ngoac goan suen thuy luenh tre dec moe thoo men ning quac soat nhim nuang nheo ngit ngheo nguyet bup doan pha nuot mach khoang bay thup nghienh troang hoang tem guyet nhiep phoai nung khoe hoai phuen kec oach ben koam ghech vuo beo choach phoanh quem thao giec giuong pic treng eng ngoe xoc huet khiem xoep roon nguen huonh xoe chinh ghet duang bum vich ngu niu phoem guo hiep chep ghip vuat beu tric chue kuop chat rim phoc goap lai piu noang bep moang tron luyp lia nge xenh chuet try soem duong guong trua huy vum ghem mon quing vuong dut dop giuoc hap viem nem vue luep ruem piet thiet tunh soc ron quiet khuam doe hoanh nghuoi cuya giai nieng giuc nhut phau phiec xuong guang pim puat sit vep pin rut nghinh rom nheng troeo diem kuoi xoang tai theu suou boch uyn van pen doat luc pang reo senh vunh sach liec quyenh phuyu bun huynh troi deng ret ghang xuom phy chiet quao sen pau tuep guech lac nghoanh giue booc roach toai doo nhuang khui nuyt hiem nhap vooc rang khuyn puong thoay mom vuya kao ceng minh quyet ram xien nhac chooc gen nau ngum guoi ghup thoat voon quong poac trop vuyet doang tuo soe vai buc nuat giom ren henh kuat nghom trinh duonh nac tren nhiet pong num pac guom loach chac ghep gioan luan poe son tet riep doen huon nhuc tinh muom cheng khuay nhin heo leo thec poc yen koay lonh gioay hich nguo phuoc xai mooc loanh xieng dim yem ruou vieng liet tuyt duen nay nguenh huay khet luong ghit uot dien truen dao hec pap poem nguan hoo gem conh phoang lop xuyet ong huenh nguong coo sum ghap thing nhien menh xem phim ghim nghac ruech kan nhet tuya hang quu rung chach xuyt uem muou noo phet tuyn chy nghang toeng hem tic tay piem pui but hoch nghe trum gioen uenh rum tat giao chuyec giuu khoeng nguyem ngieu much kiep nhuem tuang soach coan boi khuong gung bon ming khot toanh xia guc gium quia nhon gin phuyen thuynh phing oanh khoet choong khen oay choen trut nghut guych khuc uoi het hieu siec gut map quam giuam khit truyenh tuet uat phon kung khoat phuom chuom luyen nghuyen buon cat ngien nhuo triu vuoc dai nguem ngoot sip kenh tech troc noa ruen ngoec tuu ach cooc tom siem trin chuc rec giooc nom kin dieng coom khuen xen choap hung xop geo ranh phut puou huyu nghap nghao nich chuong xun nhoc nhoeng quang phot muop ngom choon huech manh koi nhech puu sot ruang siet khenh sop truan giong han phuc thuem giach buay san tuenh loac ngoa xiep buat huem quon nhiu giuyt lieu suap xoeo duynh nhui boac pien cuoc nghiem tung xao nhuen oen ghieu xan neo luynh pat pheu quech ruc buoc goeng khing munh cenh uoc mip vap puan nhoang chiec soang yet hienh seu khoem ganh miet khuop coem duan uong geng ich ham phem moem ngiu daa liu koang rin xuac huac guop nguu kanh roai seo ruan ghuan kam riet tuych koach voom tring voat buou thich roeng kuon nin lut nguay nguyen trup boom chit xuoc tieng nhoi noonh noam khiec thieu nhum vip giuop vem gheng ghop giay hep moo biep oem duc xip thenh song quoat quyng poo goach vun vuom boen huat duyenh kon nhenh quay xoo muonh diec nuou loet khuyen giuyn lem nghoc xinh gianh luyt loi suat giem khuenh kueng kut khuot mot hing let doem tenh thoang mienh vuec huoi suon phich tuoc sech ruch piec guem ruy lun uet chun sieu toep kim phup ngai oong soap ngoai sua keu bec kia ing truay ngy muot truou ria cun sing xanh nim quenh hay beng duoi gie khoep doi ngan nuop pao ngoach chuap giat lan deo xim hinh oat puyt nooc chuyt cim thuyet phiep tao gio troat mui noan troa poanh quoam nghech noen tooc cuo goe trieng moi xac nhuenh kooc dam hom lat roam thuyu loon sau ruat nginh dach suc nao truyu roi thuot ngho peu nghiep chonh hoe suyu ten leng vet bui tuou coai noao soao quen hoam nghiec trim quy khuom mua gooc nhoach put pue tuynh tuap cui xoec goat cuyen doam truoc hiec pun nghiu ving thoe gich rip vom ghien khu bat kic kuc ghan ruot nghat ken luay nhuu vui sui buoi loong reng boem toet bit khoach uech guyen ruoc them khiu roen nha soong gam dap dom cuoi choeo koong diu luoc bunh mam xing nhe huot kit lach binh ngen gian cung din gieng koem vin kai khanh toi gac puyu nguyeng och thuya dieu moanh ghiec khoo vao choom venh voen hau khoen guou khieng chec nhoet giuoi voan gan ghia khao voay ngoong mong nhach nguou kep huyet cot kui queo duech phip phinh tuong vec xit ghanh tuyenh bin pet dooc quim voi pit nghoeo huyep lap tut ruyn poay doao phuat duo dau dip vieu doch coa ngao chau hoon koom roo quoong hat buyet khooc heu ngia phooc mic nuc pia duat kap pum nghip tiep poai boat nuoi nua thoon trang quyeu hoeng ngang thi ngam noom gop oam gech nhoap muo sac mung duenh khia nup quach gao noi nhat truo xong khuyng luu chiem rooc bim hong khip king sem sep rua thuon pec oap punh chet phua gum nhieu due nghuy phuu ngooc vuy uya giap huyenh poen luyu chao vup muy kha dich hieng nan loom khuoi luap mue khat ngiem yep xiet nghi duyt xich nong khem kuong chuay hoao thuong siep goanh quuy loec phoong xiec khuu kienh roat puyn ghiu rieu goai cuu xuyenh dunh soac ngoen chan vuych tanh mum rep truyet chop phic nhoe giup nip loch phat huu vang ngui nue phuo khech khuyet thuyen nghen say mup sec voai ngoam truop roep moa nga xuc nghoi ngung yeu luy lam niem vong chai nuoc guat buyen gioong cing thuc soen dot thet cuon khueu tru luyet dem ngoi via nhom cen noay lot niec giang ninh thun vop buyu huan nhu phien chut duu khunh ngot nhoay ruyen phom xoam teng quau sat nghoe guy quet nghanh hop nghec huyen xup khap vung phum toe chuat xuych buang pay thoeng kheu nuyu nguot cuou biet khom nien tranh phay phuot quooc suec nieu hua trich giuyp trit kiet ngong nhem tip muc phep xuy thuyn xum nhang xoac koo nhoa nhoanh voe luych nuem thuech khien hoac goet truyp ngoang thot vech con khoec muyng miem xunh huang duyet chen ghong duch phang uyp ngin gioe boao anh trung xung lic luang tret xoa gang canh tan xang tang bom suoi long thuenh bot nghich thong ngech giu chi huyech xoat kua nguy hut doong vach nhoong hai tit uay thon kinh bam huong cac xiu troai gioai noat quynh hit phit xoan goong liem gioang doach phoam quinh pieng giau mep oec thien truc choeng guan vac vat kach nham khan nhuot nhoam nhuan ngiep loang guon poong noeng thieng hot pheo boon tien dua phach giui runh gap hic loay luet voanh den chanh thui buong ching boang gai choay loem nach troon phoo vim nuon huych trem poap xat tuop tri phong onh hun sien ghy huya pam tran vinh uep nhoat luop thuet tiu suyen duop hac thuoi cin nuyen bing gioanh ghiem vuou nghieng truyn trieu ngoet oon bet tray rem quoc tich nuyp phoi sim liep nhup trec bong triem gui xech choao teu kot lec keng quoan roao som lim nhuych yec soo puyet mop roan nhung bieng boanh khon phieng toeo xuam nhua leu then thut thep thuay len thoong phuyet cua guu nguech ech xui truyt hoan cinh trenh tua buop khy quat sic moong khonh nghia kheo duay pai kiem neu thiec bop roa quyn nuay hoc voa giop bia chua goang kac noong koe cuan gion huen ngich quin mao ngoem phop khai neng nhop oet coi phac qua suyn sue ngoc nghem sao ngieng thuych cec kang buyp get tuot thac choet mieng poang gioi luon gau nuech tronh khua goen viep nguop truych ngo det got guen mec gip phui pich heng nuya gioem voo sung giuom suech chem phai ghin khoon doom puc peo khoop hoet ruoi quoet nghien the nhunh quo hanh chunh trui nhue chup phieu luou xuang kuy nhoeo suop loao khuon tha xap nguon doet git trau soanh ghu cuong vam queng ton loe nguom nhiec choac chuenh nonh thiep veng pop nhun vuot vuu nech nhoan trep tuyu triep muya huam puom thoc tiem moai muyen vuen uyet xoeng monh khuang toon cop cien lung ghom gia troong tuen kun soet nuen hoay ruynh kuyen pieu cut viet oom xuon pho koc huop chong duych boa rot bieu xoai nhip cam nhieng boai xuay quoang cach ngoeo nguoi nho guoc thung bang muoc thuat muyn nhuop soai ghai phi dung nhy nhan hoap boach coon gheo von giuy suy tin tuy roang dech giut soon bue nghuong suay chuop sang tui muong khoai nghiet xep khop lau chuya cheo gho gha xua ngim diep lip xiem sieng lue nhanh luat trien suu lech goem goay huom ngoanh thoai luen phoen xuyp phuam nghy quuyet chung loc noc lui quyeng hoat kom chien luya rit sam ting nghic tuyep guyn tonh buot oeng uom gionh gic nuong khut hoen thang chuech xoon buyng cuc cuang xuyn hoep treo hin kho triet phoan xuya ngoao trip quop xut mieu poeng lang koanh khuoc nhay thoan duyn dup thoi guay khuyt nguoc phoe cham ghiep huyn khuyem keo viu giac vuyen xieu bao trom cao chuoc tue xoi khoao doeng thuen nhao vuop kue yeng not thic ciu choang ngay bienh doac xoom lich muat nghach nguat ngoay boeng ngoan uym choan trap phap ngoap suang pem chiep rai khic suyet pot thoen giuon boong roem lanh nguya huc guyu dit khieu phoa danh uan nop ran thonh khoa doon pheng sinh duot enh ghiet khuyech puo ngau ngeo nhoep nguych tuoi gep cuy gham nat soa doay truenh nhot trac gim loai coe cho siu pach rue nhoac diet xau giet nhuyet nhic mut xuenh tho chuec thai phuang choem uych thuap chuyem bai ric gioc tuam hui khung gieu nghung nhi voch khec kop xoap nguyt khuan vau xoet khuet phiem trot sup duem khang nuom gua may ngue ngheng roong ngheu uonh cuom ang hip nghieu gioao phung chang hoi choai nuy lao ceo uyen bac can xoay puoc tam cong muan nghep pip vut ruyt ooc phen guet khep ngun bem chuyep roet chu thuan khuych quoac xam trooc pan true nguyn chuyen trat vua rat mat nghu rieng sia uop nghan truon suan moan ciec buen suom soan poom thuoc vuoi nhep cap loeo troan viec thanh cha nhuom nenh giung phiu thoanh khuat uou doap guynh tim luoi quych toang nheu moc denh khuyec vuan voet kieng thay top gonh rinh xuynh cai kiec nghong coong vuon phuy truong xuen tot seng xoen thoeo nghuech cem phan chuu inh nuo quiu teo rong nguynh phiet khuyp cum xue ngut truot xic unh ruop phoac moeng oao gue ngi rop thim quoi nanh sooc truya duom roay vanh chuy run gong nhuoc bau veo nic nhen choc dui tuyem choat rac luom thum xuot chuynh riu gioa bua ruyu buu nhuoi choe gon toa quec lon thach qui vuc met puch quyem thop nep uoy mich chui nai tong kham lay xoanh toc ngop huo khoam nghuen chim nghing ghen soeo moach cuop quoay khach guyt goc luyn pung thuo tuyp dan luonh cay chuoi loat tau truu puyen guot thap dic xoong don vay tiec coc gay ruya ruon nguet sonh phoat koon ghot khinh thom boe khuo quich deu truom moac truat vuay ruong ghac quyen duyen gieo xuet thiem boan poam buyt ruenh ding xot mim xuan khue ghenh quym noai benh nuu banh hum toay puy tuyen donh dep tro nhuong moat khac mac vuet uen sin troen khoac ruyet rui pua suynh poon kip ngeu kieu lup loa nhai thoet puoi tia him phuem khuou miu buoy xuop xuch queu huap chom pom tun muyt ngua khuyu khoc tra noanh xet tria nui ven nhiem suong tach hia thuop cuot buo puon huyng ghun ngiet phonh chuon nguac choi bung quanh mun nhoen tiet duou trech kuyng thech vuem biem nuan gun renh cang ruych ghay nguc duam gec xoem loan panh treu goa lua chia sai quot tieu nghot hon buom gach buynh lenh rup coam ray truy bip vuyt tep thooc huou truyen guyp tuan ngap dinh guya muych roac koen koonh riec nhuynh roap kau nhia soam poa quit oac giuot ponh net ginh bach kuo uon toach that hoem suot vuang ngup phanh ruu chuan pham kiu hup suoc xeng ket khau xooc doanh nhec hoong cit muon dun goi khay mem pup rach moen rich rap ngach duoc uyu dia thuou buya com suam pech guym sich thuang nghim phao vit chenh ring voong nhich phech chiu nghai peng noet quip loo ghieng noem toem khich khuya tham nghuyet tum thua theo nuyet tuc ghach thoa coen thu thuu moom miec khoong khuy kem riem thue tuyet thinh oep chech than khoan looc ngham chuot oang soay cia duy thoach hunh loeng nap poat pep thuom nhuat roc room muen buy phuynh nut hoa moay trun toam khiep poi troe dat phuong phuon giuo puot tuom mang xoach biec mit gom nhinh tram noac phin xin quoanh ruo troac lom voc xuat voam ngac phenh ngenh chin nhuech non muay chuyet ling nguyu chip thip buyn toec ngat xuyu trong trach doai kech dum quoai roanh giam thit tec roe huyt tuyech goac xon boc ghat gien mech thiu nhuam khiet giun sanh theng nghet nhuay ghe choa xay oan cuat pon nhuyn quuyen xeo xuoi ban mau miep nhong truonh chon phuoi quyt too gup nhuyu hen kum thin giot truoi muet troet hiet nhuy nuynh ghich khup trao trunh goo huoc poan giep uam quuay khong phue niep khin rau ghinh nhooc uynh toan veu phe buet ngon nit tuech suyt gat suo xuu nhau reu chap".split())
19
- def tieng_viet_thuong_khong_dau(s):
20
- s = re.sub(u'Đ', 'D', s) # ko cần nữa vì text đã ở dạng lower
21
- s = re.sub(u'đ', 'd', s)
22
- s = unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
23
- return s.decode("utf-8")
24
-
25
- bad_words = """
26
- bú cu, bú cặc, bú lồn, bú lol, bú lon, bú cac, bú cak, bú cax, clip sêx,
27
- bú buoi, bú mút, chịch kiểu chó, chịch lỗ đít, chịch lén, chịch tập thể, húp lol, húp lon, húp sò,
28
- nung lol, nung lon, nug lon, nung cac, nung buoi, thèm dit, thèm lon, thèm lol, thèm buoi, thèm dit,
29
- thèm chich, thèm chịch, thèm cax, thèm cak, móc lol, móc lon, lồn múp, nứng lồn, buscu, lol non,
30
- bướm non, vú to, vú bự, lon to, phim sex, phim xex, phim xxx, phim dâm, hiep dam, làm tình, bú cặc,
31
- yeusex, sexloasn, xem lồn, địt mũi, buồi địt, sex asian, Sex lau xanh, coi quan ao, fuck sillicon toy
32
- """.strip().split(",")
33
- bad_words = [ x.strip().replace(" ","\\s*") for x in bad_words]
34
- bad_words = list(set(bad_words)) # uniq
35
- tmp = "|".join(bad_words)
36
- bad_words_re = rf"[^\S]({tmp})[^\S]"
37
- def bad_words_count(t):
38
- return len(re.findall(bad_words_re, t))
39
-
40
- def sym_filter(t, ratio=0.6):
41
- t = tieng_viet_thuong_khong_dau(t)
42
- tokens = re.split(r'[^a-z]+', t)
43
- sym_count = 0
44
- for tk in tokens:
45
- if tk in syms: sym_count += 1
46
- if sym_count / len(tokens) < ratio:
47
- return t
48
- else: return True
49
-
50
-
51
- # https://github.com/CarperAI/squeakily/blob/main/squeakily/filter.py
52
- from collections import Counter
53
- import numpy as np
54
- def _char_rep_ratio(
55
- doc: str, # document to be analyzed
56
- char_rep_len: int, # length of character repetition
57
- ) -> float:
58
- """Returns the ratio of character repetitions in a document."""
59
- def calc_ngrams(doc, n):
60
- char_ngrams = [doc[i : i + n] for i in range(len(doc) - n + 1)]
61
- freq_char_ngrams = Counter(char_ngrams)
62
- return freq_char_ngrams
63
-
64
- freq_char_ngrams = calc_ngrams(doc, char_rep_len)
65
- if len(freq_char_ngrams) == 0:
66
- return 0
67
- freq_char_ngrams = list(freq_char_ngrams.values())
68
- freq_char_ngrams = sorted(freq_char_ngrams, reverse=True)
69
- val_one = len([el for el in freq_char_ngrams if el == 1])
70
- num_rep_char_ngrams = min(
71
- int(np.sqrt(len(freq_char_ngrams))),
72
- len(freq_char_ngrams) - val_one,
73
- )
74
- char_rep_ratio = sum(freq_char_ngrams[:num_rep_char_ngrams]) / sum(freq_char_ngrams)
75
- return char_rep_ratio
76
-
77
-
78
- def check_char_repetition(
79
- document, # document to be analyzed
80
- char_repetition_len=10, # length of character repetition
81
- char_repetition_threshold=0.02, # threshold for character repetition
82
- dry_run=False, # if True, returns the ratio of character repetition
83
- ) -> bool: # returns True if document is below threshold
84
- """Checks if the document is below the character repetition threshold."""
85
- char_rep_ratio = _char_rep_ratio(document, char_repetition_len)
86
- if dry_run: return char_rep_ratio
87
- else: return char_rep_ratio <= char_repetition_threshold
88
-
89
-
90
- ###########################
91
-
92
- input_files = sys.argv[1].split(",")
93
- if input_files[0] == "jsonl":
94
- import glob
95
- input_files = glob.glob("jsonl/*")
96
-
97
- for input_file in input_files:
98
- file_prefix = input_file.split(".jsonl.lzma")[0]
99
- output_file = f"{file_prefix}_filtered.jsonl.gz"
100
- output_file = output_file.replace("jsonl/", "filtered/")
101
-
102
- print(f"{input_file} => {output_file}")
103
- fo = gzip.open(output_file, "wt")
104
- if logging:
105
- fb = open(f"{file_prefix}_bad.txt", "wt")
106
- fl = open(f"{file_prefix}_low.txt", "wt")
107
- fa = open(f"{file_prefix}_avg.txt", "wt")
108
- fr = open(f"{file_prefix}_rep.txt", "wt")
109
-
110
- with lzma.open(input_file, "rt") as f:
111
- count = bad_count = short_count = low_count = avg_count = rep_count = 0
112
- for line in f:
113
- count += 1
114
- d = json.loads(line)
115
-
116
- # Lọc theo độ dài văn bản
117
- if len(d["text"]) < 600:
118
- short_count += 1
119
- continue
120
-
121
- low_text = d["text"].lower()
122
- # Lọc theo bad words
123
- if bad_words_count(low_text) > 5:
124
- bad_count += 1
125
- if logging: fb.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
126
- continue
127
-
128
- # Lọc theo tỉ lệ âm tiết tiếng Việt
129
- t = sym_filter(low_text)
130
- if t != True:
131
- low_count += 1
132
- if logging: fl.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
133
- continue
134
-
135
- # Lọc theo độ lặp lại của ký tự
136
- if check_char_repetition(low_text):
137
- rep_count += 1
138
- if logging: fr.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
139
- continue
140
-
141
- # Lọc theo good vs c4 classifier
142
- t = d["text"].replace("\n", " ")
143
- label, score = fasttext_predict(t)
144
- if label != "__label__good" and score > 0.98:
145
- avg_count += 1
146
- if logging: fa.write(f"{label} {t}\n")
147
- continue
148
-
149
- ss = json.dumps({"text": d["text"]}, ensure_ascii=False)
150
- fo.write(ss + "\n")
151
-
152
- fo.close()
153
- if logging:
154
- fb.close()
155
- fl.close()
156
- fa.close()
157
- fr.close()
158
-
159
-
160
- print(f"total {count}, short {short_count}, bad {bad_count}, \
161
- low {low_count}, rep {rep_count}, avg {avg_count}")
162
-
163
- short_percent = "{0:.2%}".format(short_count / count); count -= short_count
164
- bad_percent = "{0:.2%}".format(bad_count / count); count -= bad_count
165
- low_percent = "{0:.2%}".format(low_count / count); count -= low_count
166
- rep_percent = "{0:.2%}".format(rep_count / count); count -= rep_count
167
- avg_percent = "{0:.2%}".format(avg_count / count); count -= avg_count
168
-
169
- print(f"remain {count}, short {short_percent}, bad {bad_percent}, \
170
- low {low_percent}, rep {rep_percent}, avg {avg_percent}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.save/filters.sh DELETED
@@ -1,21 +0,0 @@
1
- nohup python3 filters.py jsonl/2023-14_20230320083513-20230320113513.jsonl.lzma,jsonl/2023-14_20230320114206-20230320144206.jsonl.lzma,jsonl/2023-14_20230320144934-20230320174934.jsonl.lzma,jsonl/2023-14_20230320175948-20230320205948.jsonl.lzma,jsonl/2023-14_20230320211022-20230321001022.jsonl.lzma,jsonl/2023-14_20230321002050-20230321032050.jsonl.lzma,jsonl/2023-14_20230321033306-20230321063306.jsonl.lzma,jsonl/2023-14_20230321064400-20230321094400.jsonl.lzma,jsonl/2023-14_20230321095704-20230321125704.jsonl.lzma,jsonl/2023-14_20230321131205-20230321161205.jsonl.lzma &
2
-
3
- nohup python3 filters.py jsonl/2023-14_20230321162614-20230321192614.jsonl.lzma,jsonl/2023-14_20230321193811-20230321223811.jsonl.lzma,jsonl/2023-14_20230321225117-20230322015117.jsonl.lzma,jsonl/2023-14_20230322020215-20230322050215.jsonl.lzma,jsonl/2023-14_20230322051607-20230322081607.jsonl.lzma,jsonl/2023-14_20230322082826-20230322112826.jsonl.lzma,jsonl/2023-14_20230322114226-20230322144226.jsonl.lzma,jsonl/2023-14_20230322145537-20230322175537.jsonl.lzma,jsonl/2023-14_20230322180852-20230322210852.jsonl.lzma,jsonl/2023-14_20230322211955-20230323001955.jsonl.lzma &
4
-
5
- nohup python3 filters.py jsonl/2023-14_20230323003026-20230323033026.jsonl.lzma,jsonl/2023-14_20230323034459-20230323064459.jsonl.lzma,jsonl/2023-14_20230323065609-20230323095609.jsonl.lzma,jsonl/2023-14_20230323100829-20230323130829.jsonl.lzma,jsonl/2023-14_20230323132026-20230323162026.jsonl.lzma,jsonl/2023-14_20230323163125-20230323193125.jsonl.lzma,jsonl/2023-14_20230323194025-20230323224025.jsonl.lzma,jsonl/2023-14_20230323225049-20230324015049.jsonl.lzma,jsonl/2023-14_20230324020038-20230324050038.jsonl.lzma,jsonl/2023-14_20230324051147-20230324081147.jsonl.lzma &
6
-
7
- nohup python3 filters.py jsonl/2023-14_20230324082226-20230324112226.jsonl.lzma,jsonl/2023-14_20230324113500-20230324143500.jsonl.lzma,jsonl/2023-14_20230324144746-20230324174746.jsonl.lzma,jsonl/2023-14_20230324180032-20230324210032.jsonl.lzma,jsonl/2023-14_20230324211121-20230325001121.jsonl.lzma,jsonl/2023-14_20230325002113-20230325032113.jsonl.lzma,jsonl/2023-14_20230325033306-20230325063306.jsonl.lzma,jsonl/2023-14_20230325064253-20230325094253.jsonl.lzma,jsonl/2023-14_20230325095252-20230325125252.jsonl.lzma,jsonl/2023-14_20230325130029-20230325160029.jsonl.lzma &
8
-
9
- nohup python3 filters.py jsonl/2023-14_20230325161021-20230325191021.jsonl.lzma,jsonl/2023-14_20230325191930-20230325221930.jsonl.lzma,jsonl/2023-14_20230325222822-20230326012822.jsonl.lzma,jsonl/2023-14_20230326013652-20230326043652.jsonl.lzma,jsonl/2023-14_20230326044821-20230326074821.jsonl.lzma,jsonl/2023-14_20230326075911-20230326105911.jsonl.lzma,jsonl/2023-14_20230326111045-20230326141045.jsonl.lzma,jsonl/2023-14_20230326142035-20230326172035.jsonl.lzma,jsonl/2023-14_20230326173112-20230326203112.jsonl.lzma,jsonl/2023-14_20230326204136-20230326234136.jsonl.lzma &
10
-
11
- nohup python3 filters.py jsonl/2023-14_20230326235016-20230327025016.jsonl.lzma,jsonl/2023-14_20230327025922-20230327055922.jsonl.lzma,jsonl/2023-14_20230327060940-20230327090940.jsonl.lzma,jsonl/2023-14_20230327092225-20230327122225.jsonl.lzma,jsonl/2023-14_20230327123514-20230327153514.jsonl.lzma,jsonl/2023-14_20230327154814-20230327184814.jsonl.lzma,jsonl/2023-14_20230327185741-20230327215741.jsonl.lzma,jsonl/2023-14_20230327220742-20230328010742.jsonl.lzma,jsonl/2023-14_20230328011555-20230328041555.jsonl.lzma,jsonl/2023-14_20230328042424-20230328072424.jsonl.lzma &
12
-
13
- nohup python3 filters.py jsonl/2023-14_20230328073515-20230328103515.jsonl.lzma,jsonl/2023-14_20230328104523-20230328134523.jsonl.lzma,jsonl/2023-14_20230328135732-20230328165732.jsonl.lzma,jsonl/2023-14_20230328170730-20230328200730.jsonl.lzma,jsonl/2023-14_20230328201715-20230328231715.jsonl.lzma,jsonl/2023-14_20230328232645-20230329022645.jsonl.lzma,jsonl/2023-14_20230329023546-20230329053546.jsonl.lzma,jsonl/2023-14_20230329054547-20230329084547.jsonl.lzma,jsonl/2023-14_20230329085436-20230329115436.jsonl.lzma,jsonl/2023-14_20230329120545-20230329150545.jsonl.lzma &
14
-
15
- nohup python3 filters.py jsonl/2023-14_20230329151629-20230329181629.jsonl.lzma,jsonl/2023-14_20230329182643-20230329212643.jsonl.lzma,jsonl/2023-14_20230329213541-20230330003541.jsonl.lzma,jsonl/2023-14_20230330004340-20230330034340.jsonl.lzma,jsonl/2023-14_20230330035241-20230330065241.jsonl.lzma,jsonl/2023-14_20230330070451-20230330100451.jsonl.lzma,jsonl/2023-14_20230330101355-20230330131355.jsonl.lzma,jsonl/2023-14_20230330132508-20230330162508.jsonl.lzma,jsonl/2023-14_20230330163823-20230330193823.jsonl.lzma,jsonl/2023-14_20230330194843-20230330224843.jsonl.lzma &
16
-
17
- nohup python3 filters.py jsonl/2023-14_20230330225648-20230331015648.jsonl.lzma,jsonl/2023-14_20230331020535-20230331050535.jsonl.lzma,jsonl/2023-14_20230331051439-20230331081439.jsonl.lzma,jsonl/2023-14_20230331082653-20230331112653.jsonl.lzma,jsonl/2023-14_20230331113819-20230331143819.jsonl.lzma,jsonl/2023-14_20230331144941-20230331174941.jsonl.lzma,jsonl/2023-14_20230331175950-20230331205950.jsonl.lzma,jsonl/2023-14_20230331210803-20230401000803.jsonl.lzma,jsonl/2023-14_20230401001704-20230401031704.jsonl.lzma,jsonl/2023-14_20230401032604-20230401062604.jsonl.lzma &
18
-
19
- nohup python3 filters.py jsonl/2023-14_20230401063607-20230401093607.jsonl.lzma,jsonl/2023-14_20230401094611-20230401124611.jsonl.lzma,jsonl/2023-14_20230401125552-20230401155552.jsonl.lzma,jsonl/2023-14_20230401160259-20230401190259.jsonl.lzma,jsonl/2023-14_20230401191131-20230401221131.jsonl.lzma,jsonl/2023-14_20230401221921-20230402011921.jsonl.lzma,jsonl/2023-14_20230402012805-20230402042805.jsonl.lzma,jsonl/2023-14_20230402043600-20230402073600.jsonl.lzma,jsonl/2023-14_20230402074255-20230402104255.jsonl.lzma,jsonl/2023-14_20230402105054-20230402135054.jsonl.lzma &
20
-
21
- tail -f nohup.out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.save/filters_epub.py DELETED
@@ -1,170 +0,0 @@
1
- import json, sys, gzip, glob, lzma
2
- import re, unicodedata
3
-
4
- try:
5
- sys.argv[2]
6
- logging = True
7
- except:
8
- logging = False
9
-
10
- import fasttext
11
- fasttext_model = fasttext.load_model("fasttext_epub_vs_cc.bin")
12
- def fasttext_predict(text) -> tuple:
13
- result = fasttext_model.predict(text)
14
- label = result[0][0]
15
- prob = result[1][0]
16
- return label, prob
17
-
18
- syms = set("khum toap chuyn mien khuech khun nun lin dong buan kay nhuyen ruet duet khoap lum nhit khoanh kheng lieng xuap thia luot truynh khoay thy quap vien chieng duya luech mai moam nguyech chuych phuan hach xuyen chum phoeng duyu giech suya loam choam bich biu phuya trai doa khim xom phec cunh buch quep rien meu muoi lunh uap penh xach chuang triec luo khi soi choo muu phun chuen meng oai nghenh toen que troam tap gheu cheu chuam rao khuynh nec phu ruom xuech thoac tuon hech bien ghi duyp ping khoi bap koai suyp thoam chieu gienh noe sap cau loap chay day pinh chuo cieu goao duon min nuyn mia nen nang thoao rech nam troanh lit toong ngha thuonh toac hooc tuat genh cup phia linh chich nhoai giua meo ngoat quyu chic xeu lep vic kat chuyech niet soeng khe hao nganh nhuon thau nuoch chuyenh tup tac boet piep vot choanh goam xec tuay doc dac bech oeo dang hoach loen set goon pooc noon toat phuyn nia nghau uyt kong nhoem kich bic xuyec coang nget thuam tuem khuyenh khoeo lien ging boo chot nghin voang man sut koa che quan uang moon ung hien nghit sun hue kien quai ghec hiu puya kuan ngoac goan suen thuy luenh tre dec moe thoo men ning quac soat nhim nuang nheo ngit ngheo nguyet bup doan pha nuot mach khoang bay thup nghienh troang hoang tem guyet nhiep phoai nung khoe hoai phuen kec oach ben koam ghech vuo beo choach phoanh quem thao giec giuong pic treng eng ngoe xoc huet khiem xoep roon nguen huonh xoe chinh ghet duang bum vich ngu niu phoem guo hiep chep ghip vuat beu tric chue kuop chat rim phoc goap lai piu noang bep moang tron luyp lia nge xenh chuet try soem duong guong trua huy vum ghem mon quing vuong dut dop giuoc hap viem nem vue luep ruem piet thiet tunh soc ron quiet khuam doe hoanh nghuoi cuya giai nieng giuc nhut phau phiec xuong guang pim puat sit vep pin rut nghinh rom nheng troeo diem kuoi xoang tai theu suou boch uyn van pen doat luc pang reo senh vunh sach liec quyenh phuyu bun huynh troi deng ret ghang xuom phy chiet quao sen pau tuep guech lac nghoanh giue booc roach toai doo nhuang khui nuyt hiem nhap vooc rang khuyn puong thoay mom vuya kao ceng minh quyet ram xien nhac chooc gen nau ngum guoi ghup thoat voon quong poac trop vuyet doang tuo soe vai buc nuat giom ren henh kuat nghom trinh duonh nac tren nhiet pong num pac guom loach chac ghep gioan luan poe son tet riep doen huon nhuc tinh muom cheng khuay nhin heo leo thec poc yen koay lonh gioay hich nguo phuoc xai mooc loanh xieng dim yem ruou vieng liet tuyt duen nay nguenh huay khet luong ghit uot dien truen dao hec pap poem nguan hoo gem conh phoang lop xuyet ong huenh nguong coo sum ghap thing nhien menh xem phim ghim nghac ruech kan nhet tuya hang quu rung chach xuyt uem muou noo phet tuyn chy nghang toeng hem tic tay piem pui but hoch nghe trum gioen uenh rum tat giao chuyec giuu khoeng nguyem ngieu much kiep nhuem tuang soach coan boi khuong gung bon ming khot toanh xia guc gium quia nhon gin phuyen thuynh phing oanh khoet choong khen oay choen trut nghut guych khuc uoi het hieu siec gut map quam giuam khit truyenh tuet uat phon kung khoat phuom chuom luyen nghuyen buon cat ngien nhuo triu vuoc dai nguem ngoot sip kenh tech troc noa ruen ngoec tuu ach cooc tom siem trin chuc rec giooc nom kin dieng coom khuen xen choap hung xop geo ranh phut puou huyu nghap nghao nich chuong xun nhoc nhoeng quang phot muop ngom choon huech manh koi nhech puu sot ruang siet khenh sop truan giong han phuc thuem giach buay san tuenh loac ngoa xiep buat huem quon nhiu giuyt lieu suap xoeo duynh nhui boac pien cuoc nghiem tung xao nhuen oen ghieu xan neo luynh pat pheu quech ruc buoc goeng khing munh cenh uoc mip vap puan nhoang chiec soang yet hienh seu khoem ganh miet khuop coem duan uong geng ich ham phem moem ngiu daa liu koang rin xuac huac guop nguu kanh roai seo ruan ghuan kam riet tuych koach voom tring voat buou thich roeng kuon nin lut nguay nguyen trup boom chit xuoc tieng nhoi noonh noam khiec thieu nhum vip giuop vem gheng ghop giay hep moo biep oem duc xip thenh song quoat quyng poo goach vun vuom boen huat duyenh kon nhenh quay xoo muonh diec nuou loet khuyen giuyn lem nghoc xinh gianh luyt loi suat giem khuenh kueng kut khuot mot hing let doem tenh thoang mienh vuec huoi suon phich tuoc sech ruch piec guem ruy lun uet chun sieu toep kim phup ngai oong soap ngoai sua keu bec kia ing truay ngy muot truou ria cun sing xanh nim quenh hay beng duoi gie khoep doi ngan nuop pao ngoach chuap giat lan deo xim hinh oat puyt nooc chuyt cim thuyet phiep tao gio troat mui noan troa poanh quoam nghech noen tooc cuo goe trieng moi xac nhuenh kooc dam hom lat roam thuyu loon sau ruat nginh dach suc nao truyu roi thuot ngho peu nghiep chonh hoe suyu ten leng vet bui tuou coai noao soao quen hoam nghiec trim quy khuom mua gooc nhoach put pue tuynh tuap cui xoec goat cuyen doam truoc hiec pun nghiu ving thoe gich rip vom ghien khu bat kic kuc ghan ruot nghat ken luay nhuu vui sui buoi loong reng boem toet bit khoach uech guyen ruoc them khiu roen nha soong gam dap dom cuoi choeo koong diu luoc bunh mam xing nhe huot kit lach binh ngen gian cung din gieng koem vin kai khanh toi gac puyu nguyeng och thuya dieu moanh ghiec khoo vao choom venh voen hau khoen guou khieng chec nhoet giuoi voan gan ghia khao voay ngoong mong nhach nguou kep huyet cot kui queo duech phip phinh tuong vec xit ghanh tuyenh bin pet dooc quim voi pit nghoeo huyep lap tut ruyn poay doao phuat duo dau dip vieu doch coa ngao chau hoon koom roo quoong hat buyet khooc heu ngia phooc mic nuc pia duat kap pum nghip tiep poai boat nuoi nua thoon trang quyeu hoeng ngang thi ngam noom gop oam gech nhoap muo sac mung duenh khia nup quach gao noi nhat truo xong khuyng luu chiem rooc bim hong khip king sem sep rua thuon pec oap punh chet phua gum nhieu due nghuy phuu ngooc vuy uya giap huyenh poen luyu chao vup muy kha dich hieng nan loom khuoi luap mue khat ngiem yep xiet nghi duyt xich nong khem kuong chuay hoao thuong siep goanh quuy loec phoong xiec khuu kienh roat puyn ghiu rieu goai cuu xuyenh dunh soac ngoen chan vuych tanh mum rep truyet chop phic nhoe giup nip loch phat huu vang ngui nue phuo khech khuyet thuyen nghen say mup sec voai ngoam truop roep moa nga xuc nghoi ngung yeu luy lam niem vong chai nuoc guat buyen gioong cing thuc soen dot thet cuon khueu tru luyet dem ngoi via nhom cen noay lot niec giang ninh thun vop buyu huan nhu phien chut duu khunh ngot nhoay ruyen phom xoam teng quau sat nghoe guy quet nghanh hop nghec huyen xup khap vung phum toe chuat xuych buang pay thoeng kheu nuyu nguot cuou biet khom nien tranh phay phuot quooc suec nieu hua trich giuyp trit kiet ngong nhem tip muc phep xuy thuyn xum nhang xoac koo nhoa nhoanh voe luych nuem thuech khien hoac goet truyp ngoang thot vech con khoec muyng miem xunh huang duyet chen ghong duch phang uyp ngin gioe boao anh trung xung lic luang tret xoa gang canh tan xang tang bom suoi long thuenh bot nghich thong ngech giu chi huyech xoat kua nguy hut doong vach nhoong hai tit uay thon kinh bam huong cac xiu troai gioai noat quynh hit phit xoan goong liem gioang doach phoam quinh pieng giau mep oec thien truc choeng guan vac vat kach nham khan nhuot nhoam nhuan ngiep loang guon poong noeng thieng hot pheo boon tien dua phach giui runh gap hic loay luet voanh den chanh thui buong ching boang gai choay loem nach troon phoo vim nuon huych trem poap xat tuop tri phong onh hun sien ghy huya pam tran vinh uep nhoat luop thuet tiu suyen duop hac thuoi cin nuyen bing gioanh ghiem vuou nghieng truyn trieu ngoet oon bet tray rem quoc tich nuyp phoi sim liep nhup trec bong triem gui xech choao teu kot lec keng quoan roao som lim nhuych yec soo puyet mop roan nhung bieng boanh khon phieng toeo xuam nhua leu then thut thep thuay len thoong phuyet cua guu nguech ech xui truyt hoan cinh trenh tua buop khy quat sic moong khonh nghia kheo duay pai kiem neu thiec bop roa quyn nuay hoc voa giop bia chua goang kac noong koe cuan gion huen ngich quin mao ngoem phop khai neng nhop oet coi phac qua suyn sue ngoc nghem sao ngieng thuych cec kang buyp get tuot thac choet mieng poang gioi luon gau nuech tronh khua goen viep nguop truych ngo det got guen mec gip phui pich heng nuya gioem voo sung giuom suech chem phai ghin khoon doom puc peo khoop hoet ruoi quoet nghien the nhunh quo hanh chunh trui nhue chup phieu luou xuang kuy nhoeo suop loao khuon tha xap nguon doet git trau soanh ghu cuong vam queng ton loe nguom nhiec choac chuenh nonh thiep veng pop nhun vuot vuu nech nhoan trep tuyu triep muya huam puom thoc tiem moai muyen vuen uyet xoeng monh khuang toon cop cien lung ghom gia troong tuen kun soet nuen hoay ruynh kuyen pieu cut viet oom xuon pho koc huop chong duych boa rot bieu xoai nhip cam nhieng boai xuay quoang cach ngoeo nguoi nho guoc thung bang muoc thuat muyn nhuop soai ghai phi dung nhy nhan hoap boach coon gheo von giuy suy tin tuy roang dech giut soon bue nghuong suay chuop sang tui muong khoai nghiet xep khop lau chuya cheo gho gha xua ngim diep lip xiem sieng lue nhanh luat trien suu lech goem goay huom ngoanh thoai luen phoen xuyp phuam nghy quuyet chung loc noc lui quyeng hoat kom chien luya rit sam ting nghic tuyep guyn tonh buot oeng uom gionh gic nuong khut hoen thang chuech xoon buyng cuc cuang xuyn hoep treo hin kho triet phoan xuya ngoao trip quop xut mieu poeng lang koanh khuoc nhay thoan duyn dup thoi guay khuyt nguoc phoe cham ghiep huyn khuyem keo viu giac vuyen xieu bao trom cao chuoc tue xoi khoao doeng thuen nhao vuop kue yeng not thic ciu choang ngay bienh doac xoom lich muat nghach nguat ngoay boeng ngoan uym choan trap phap ngoap suang pem chiep rai khic suyet pot thoen giuon boong roem lanh nguya huc guyu dit khieu phoa danh uan nop ran thonh khoa doon pheng sinh duot enh ghiet khuyech puo ngau ngeo nhoep nguych tuoi gep cuy gham nat soa doay truenh nhot trac gim loai coe cho siu pach rue nhoac diet xau giet nhuyet nhic mut xuenh tho chuec thai phuang choem uych thuap chuyem bai ric gioc tuam hui khung gieu nghung nhi voch khec kop xoap nguyt khuan vau xoet khuet phiem trot sup duem khang nuom gua may ngue ngheng roong ngheu uonh cuom ang hip nghieu gioao phung chang hoi choai nuy lao ceo uyen bac can xoay puoc tam cong muan nghep pip vut ruyt ooc phen guet khep ngun bem chuyep roet chu thuan khuych quoac xam trooc pan true nguyn chuyen trat vua rat mat nghu rieng sia uop nghan truon suan moan ciec buen suom soan poom thuoc vuoi nhep cap loeo troan viec thanh cha nhuom nenh giung phiu thoanh khuat uou doap guynh tim luoi quych toang nheu moc denh khuyec vuan voet kieng thay top gonh rinh xuynh cai kiec nghong coong vuon phuy truong xuen tot seng xoen thoeo nghuech cem phan chuu inh nuo quiu teo rong nguynh phiet khuyp cum xue ngut truot xic unh ruop phoac moeng oao gue ngi rop thim quoi nanh sooc truya duom roay vanh chuy run gong nhuoc bau veo nic nhen choc dui tuyem choat rac luom thum xuot chuynh riu gioa bua ruyu buu nhuoi choe gon toa quec lon thach qui vuc met puch quyem thop nep uoy mich chui nai tong kham lay xoanh toc ngop huo khoam nghuen chim nghing ghen soeo moach cuop quoay khach guyt goc luyn pung thuo tuyp dan luonh cay chuoi loat tau truu puyen guot thap dic xoong don vay tiec coc gay ruya ruon nguet sonh phoat koon ghot khinh thom boe khuo quich deu truom moac truat vuay ruong ghac quyen duyen gieo xuet thiem boan poam buyt ruenh ding xot mim xuan khue ghenh quym noai benh nuu banh hum toay puy tuyen donh dep tro nhuong moat khac mac vuet uen sin troen khoac ruyet rui pua suynh poon kip ngeu kieu lup loa nhai thoet puoi tia him phuem khuou miu buoy xuop xuch queu huap chom pom tun muyt ngua khuyu khoc tra noanh xet tria nui ven nhiem suong tach hia thuop cuot buo puon huyng ghun ngiet phonh chuon nguac choi bung quanh mun nhoen tiet duou trech kuyng thech vuem biem nuan gun renh cang ruych ghay nguc duam gec xoem loan panh treu goa lua chia sai quot tieu nghot hon buom gach buynh lenh rup coam ray truy bip vuyt tep thooc huou truyen guyp tuan ngap dinh guya muych roac koen koonh riec nhuynh roap kau nhia soam poa quit oac giuot ponh net ginh bach kuo uon toach that hoem suot vuang ngup phanh ruu chuan pham kiu hup suoc xeng ket khau xooc doanh nhec hoong cit muon dun goi khay mem pup rach moen rich rap ngach duoc uyu dia thuou buya com suam pech guym sich thuang nghim phao vit chenh ring voong nhich phech chiu nghai peng noet quip loo ghieng noem toem khich khuya tham nghuyet tum thua theo nuyet tuc ghach thoa coen thu thuu moom miec khoong khuy kem riem thue tuyet thinh oep chech than khoan looc ngham chuot oang soay cia duy thoach hunh loeng nap poat pep thuom nhuat roc room muen buy phuynh nut hoa moay trun toam khiep poi troe dat phuong phuon giuo puot tuom mang xoach biec mit gom nhinh tram noac phin xin quoanh ruo troac lom voc xuat voam ngac phenh ngenh chin nhuech non muay chuyet ling nguyu chip thip buyn toec ngat xuyu trong trach doai kech dum quoai roanh giam thit tec roe huyt tuyech goac xon boc ghat gien mech thiu nhuam khiet giun sanh theng nghet nhuay ghe choa xay oan cuat pon nhuyn quuyen xeo xuoi ban mau miep nhong truonh chon phuoi quyt too gup nhuyu hen kum thin giot truoi muet troet hiet nhuy nuynh ghich khup trao trunh goo huoc poan giep uam quuay khong phue niep khin rau ghinh nhooc uynh toan veu phe buet ngon nit tuech suyt gat suo xuu nhau reu chap".split())
19
- def tieng_viet_thuong_khong_dau(s):
20
- s = re.sub(u'Đ', 'D', s) # ko cần nữa vì text đã ở dạng lower
21
- s = re.sub(u'đ', 'd', s)
22
- s = unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
23
- return s.decode("utf-8")
24
-
25
- bad_words = """
26
- bú cu, bú cặc, bú lồn, bú lol, bú lon, bú cac, bú cak, bú cax, clip sêx,
27
- bú buoi, bú mút, chịch kiểu chó, chịch lỗ đít, chịch lén, chịch tập thể, húp lol, húp lon, húp sò,
28
- nung lol, nung lon, nug lon, nung cac, nung buoi, thèm dit, thèm lon, thèm lol, thèm buoi, thèm dit,
29
- thèm chich, thèm chịch, thèm cax, thèm cak, móc lol, móc lon, lồn múp, nứng lồn, buscu, lol non,
30
- bướm non, vú to, vú bự, lon to, phim sex, phim xex, phim xxx, phim dâm, hiep dam, làm tình, bú cặc,
31
- yeusex, sexloasn, xem lồn, địt mũi, buồi địt, sex asian, Sex lau xanh, coi quan ao, fuck sillicon toy
32
- """.strip().split(",")
33
- bad_words = [ x.strip().replace(" ","\\s*") for x in bad_words]
34
- bad_words = list(set(bad_words)) # uniq
35
- tmp = "|".join(bad_words)
36
- bad_words_re = rf"[^\S]({tmp})[^\S]"
37
- def bad_words_count(t):
38
- return len(re.findall(bad_words_re, t))
39
-
40
- def sym_filter(t, ratio=0.6):
41
- t = tieng_viet_thuong_khong_dau(t)
42
- tokens = re.split(r'[^a-z]+', t)
43
- sym_count = 0
44
- for tk in tokens:
45
- if tk in syms: sym_count += 1
46
- if sym_count / len(tokens) < ratio:
47
- return t
48
- else: return True
49
-
50
-
51
- # https://github.com/CarperAI/squeakily/blob/main/squeakily/filter.py
52
- from collections import Counter
53
- import numpy as np
54
- def _char_rep_ratio(
55
- doc: str, # document to be analyzed
56
- char_rep_len: int, # length of character repetition
57
- ) -> float:
58
- """Returns the ratio of character repetitions in a document."""
59
- def calc_ngrams(doc, n):
60
- char_ngrams = [doc[i : i + n] for i in range(len(doc) - n + 1)]
61
- freq_char_ngrams = Counter(char_ngrams)
62
- return freq_char_ngrams
63
-
64
- freq_char_ngrams = calc_ngrams(doc, char_rep_len)
65
- if len(freq_char_ngrams) == 0:
66
- return 0
67
- freq_char_ngrams = list(freq_char_ngrams.values())
68
- freq_char_ngrams = sorted(freq_char_ngrams, reverse=True)
69
- val_one = len([el for el in freq_char_ngrams if el == 1])
70
- num_rep_char_ngrams = min(
71
- int(np.sqrt(len(freq_char_ngrams))),
72
- len(freq_char_ngrams) - val_one,
73
- )
74
- char_rep_ratio = sum(freq_char_ngrams[:num_rep_char_ngrams]) / sum(freq_char_ngrams)
75
- return char_rep_ratio
76
-
77
-
78
- def check_char_repetition(
79
- document, # document to be analyzed
80
- char_repetition_len=10, # length of character repetition
81
- char_repetition_threshold=0.02, # threshold for character repetition
82
- dry_run=False, # if True, returns the ratio of character repetition
83
- ) -> bool: # returns True if document is below threshold
84
- """Checks if the document is below the character repetition threshold."""
85
- char_rep_ratio = _char_rep_ratio(document, char_repetition_len)
86
- if dry_run: return char_rep_ratio
87
- else: return char_rep_ratio <= char_repetition_threshold
88
-
89
-
90
- ###########################
91
-
92
- input_files = sys.argv[1].split(",")
93
- if input_files[0] == "jsonl":
94
- import glob
95
- input_files = glob.glob("jsonl/*")
96
-
97
- for input_file in input_files:
98
- file_prefix = input_file.split(".jsonl.lzma")[0]
99
- output_file = f"{file_prefix}_filtered.jsonl.gz"
100
- output_file = output_file.replace("jsonl/", "filtered/")
101
-
102
- print(f"{input_file} => {output_file}")
103
- fo = gzip.open(output_file, "wt")
104
- if logging:
105
- fb = open(f"{file_prefix}_bad.txt", "wt")
106
- fl = open(f"{file_prefix}_low.txt", "wt")
107
- fa = open(f"{file_prefix}_avg.txt", "wt")
108
- fr = open(f"{file_prefix}_rep.txt", "wt")
109
-
110
- with lzma.open(input_file, "rt") as f:
111
- count = bad_count = short_count = low_count = avg_count = rep_count = 0
112
- for line in f:
113
- count += 1
114
- d = json.loads(line)
115
-
116
- # Lọc theo độ dài văn bản
117
- if len(d["text"]) < 600:
118
- short_count += 1
119
- continue
120
-
121
- low_text = d["text"].lower()
122
- # Lọc theo bad words
123
- if bad_words_count(low_text) > 5:
124
- bad_count += 1
125
- if logging: fb.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
126
- continue
127
-
128
- # Lọc theo tỉ lệ âm tiết tiếng Việt
129
- t = sym_filter(low_text)
130
- if t != True:
131
- low_count += 1
132
- if logging: fl.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
133
- continue
134
-
135
- # Lọc theo độ lặp lại của ký tự
136
- if check_char_repetition(low_text):
137
- rep_count += 1
138
- if logging: fr.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
139
- continue
140
-
141
- # Lọc theo good vs c4 classifier
142
- t = d["text"].replace("\n", " ")
143
- label, score = fasttext_predict(t)
144
- if label != "__label__epub" or score < 0.6:
145
- avg_count += 1
146
- if logging: fa.write(f"{label} {t}\n")
147
- continue
148
-
149
- ss = json.dumps({"text": d["text"]}, ensure_ascii=False)
150
- fo.write(ss + "\n")
151
-
152
- fo.close()
153
- if logging:
154
- fb.close()
155
- fl.close()
156
- fa.close()
157
- fr.close()
158
-
159
-
160
- print(f"total {count}, short {short_count}, bad {bad_count}, \
161
- low {low_count}, rep {rep_count}, avg {avg_count}")
162
-
163
- short_percent = "{0:.2%}".format(short_count / count); count -= short_count
164
- bad_percent = "{0:.2%}".format(bad_count / count); count -= bad_count
165
- low_percent = "{0:.2%}".format(low_count / count); count -= low_count
166
- rep_percent = "{0:.2%}".format(rep_count / count); count -= rep_count
167
- avg_percent = "{0:.2%}".format(avg_count / count); count -= avg_count
168
-
169
- print(f"remain {count}, short {short_percent}, bad {bad_percent}, \
170
- low {low_percent}, rep {rep_percent}, avg {avg_percent}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.save/filters_tiasang.py DELETED
@@ -1,170 +0,0 @@
1
- import json, sys, gzip, glob, lzma
2
- import re, unicodedata
3
-
4
- try:
5
- sys.argv[2]
6
- logging = True
7
- except:
8
- logging = False
9
-
10
- import fasttext
11
- fasttext_model = fasttext.load_model("fasttext_tiasang_vs_cc.bin")
12
- def fasttext_predict(text) -> tuple:
13
- result = fasttext_model.predict(text)
14
- label = result[0][0]
15
- prob = result[1][0]
16
- return label, prob
17
-
18
- syms = set("khum toap chuyn mien khuech khun nun lin dong buan kay nhuyen ruet duet khoap lum nhit khoanh kheng lieng xuap thia luot truynh khoay thy quap vien chieng duya luech mai moam nguyech chuych phuan hach xuyen chum phoeng duyu giech suya loam choam bich biu phuya trai doa khim xom phec cunh buch quep rien meu muoi lunh uap penh xach chuang triec luo khi soi choo muu phun chuen meng oai nghenh toen que troam tap gheu cheu chuam rao khuynh nec phu ruom xuech thoac tuon hech bien ghi duyp ping khoi bap koai suyp thoam chieu gienh noe sap cau loap chay day pinh chuo cieu goao duon min nuyn mia nen nang thoao rech nam troanh lit toong ngha thuonh toac hooc tuat genh cup phia linh chich nhoai giua meo ngoat quyu chic xeu lep vic kat chuyech niet soeng khe hao nganh nhuon thau nuoch chuyenh tup tac boet piep vot choanh goam xec tuay doc dac bech oeo dang hoach loen set goon pooc noon toat phuyn nia nghau uyt kong nhoem kich bic xuyec coang nget thuam tuem khuyenh khoeo lien ging boo chot nghin voang man sut koa che quan uang moon ung hien nghit sun hue kien quai ghec hiu puya kuan ngoac goan suen thuy luenh tre dec moe thoo men ning quac soat nhim nuang nheo ngit ngheo nguyet bup doan pha nuot mach khoang bay thup nghienh troang hoang tem guyet nhiep phoai nung khoe hoai phuen kec oach ben koam ghech vuo beo choach phoanh quem thao giec giuong pic treng eng ngoe xoc huet khiem xoep roon nguen huonh xoe chinh ghet duang bum vich ngu niu phoem guo hiep chep ghip vuat beu tric chue kuop chat rim phoc goap lai piu noang bep moang tron luyp lia nge xenh chuet try soem duong guong trua huy vum ghem mon quing vuong dut dop giuoc hap viem nem vue luep ruem piet thiet tunh soc ron quiet khuam doe hoanh nghuoi cuya giai nieng giuc nhut phau phiec xuong guang pim puat sit vep pin rut nghinh rom nheng troeo diem kuoi xoang tai theu suou boch uyn van pen doat luc pang reo senh vunh sach liec quyenh phuyu bun huynh troi deng ret ghang xuom phy chiet quao sen pau tuep guech lac nghoanh giue booc roach toai doo nhuang khui nuyt hiem nhap vooc rang khuyn puong thoay mom vuya kao ceng minh quyet ram xien nhac chooc gen nau ngum guoi ghup thoat voon quong poac trop vuyet doang tuo soe vai buc nuat giom ren henh kuat nghom trinh duonh nac tren nhiet pong num pac guom loach chac ghep gioan luan poe son tet riep doen huon nhuc tinh muom cheng khuay nhin heo leo thec poc yen koay lonh gioay hich nguo phuoc xai mooc loanh xieng dim yem ruou vieng liet tuyt duen nay nguenh huay khet luong ghit uot dien truen dao hec pap poem nguan hoo gem conh phoang lop xuyet ong huenh nguong coo sum ghap thing nhien menh xem phim ghim nghac ruech kan nhet tuya hang quu rung chach xuyt uem muou noo phet tuyn chy nghang toeng hem tic tay piem pui but hoch nghe trum gioen uenh rum tat giao chuyec giuu khoeng nguyem ngieu much kiep nhuem tuang soach coan boi khuong gung bon ming khot toanh xia guc gium quia nhon gin phuyen thuynh phing oanh khoet choong khen oay choen trut nghut guych khuc uoi het hieu siec gut map quam giuam khit truyenh tuet uat phon kung khoat phuom chuom luyen nghuyen buon cat ngien nhuo triu vuoc dai nguem ngoot sip kenh tech troc noa ruen ngoec tuu ach cooc tom siem trin chuc rec giooc nom kin dieng coom khuen xen choap hung xop geo ranh phut puou huyu nghap nghao nich chuong xun nhoc nhoeng quang phot muop ngom choon huech manh koi nhech puu sot ruang siet khenh sop truan giong han phuc thuem giach buay san tuenh loac ngoa xiep buat huem quon nhiu giuyt lieu suap xoeo duynh nhui boac pien cuoc nghiem tung xao nhuen oen ghieu xan neo luynh pat pheu quech ruc buoc goeng khing munh cenh uoc mip vap puan nhoang chiec soang yet hienh seu khoem ganh miet khuop coem duan uong geng ich ham phem moem ngiu daa liu koang rin xuac huac guop nguu kanh roai seo ruan ghuan kam riet tuych koach voom tring voat buou thich roeng kuon nin lut nguay nguyen trup boom chit xuoc tieng nhoi noonh noam khiec thieu nhum vip giuop vem gheng ghop giay hep moo biep oem duc xip thenh song quoat quyng poo goach vun vuom boen huat duyenh kon nhenh quay xoo muonh diec nuou loet khuyen giuyn lem nghoc xinh gianh luyt loi suat giem khuenh kueng kut khuot mot hing let doem tenh thoang mienh vuec huoi suon phich tuoc sech ruch piec guem ruy lun uet chun sieu toep kim phup ngai oong soap ngoai sua keu bec kia ing truay ngy muot truou ria cun sing xanh nim quenh hay beng duoi gie khoep doi ngan nuop pao ngoach chuap giat lan deo xim hinh oat puyt nooc chuyt cim thuyet phiep tao gio troat mui noan troa poanh quoam nghech noen tooc cuo goe trieng moi xac nhuenh kooc dam hom lat roam thuyu loon sau ruat nginh dach suc nao truyu roi thuot ngho peu nghiep chonh hoe suyu ten leng vet bui tuou coai noao soao quen hoam nghiec trim quy khuom mua gooc nhoach put pue tuynh tuap cui xoec goat cuyen doam truoc hiec pun nghiu ving thoe gich rip vom ghien khu bat kic kuc ghan ruot nghat ken luay nhuu vui sui buoi loong reng boem toet bit khoach uech guyen ruoc them khiu roen nha soong gam dap dom cuoi choeo koong diu luoc bunh mam xing nhe huot kit lach binh ngen gian cung din gieng koem vin kai khanh toi gac puyu nguyeng och thuya dieu moanh ghiec khoo vao choom venh voen hau khoen guou khieng chec nhoet giuoi voan gan ghia khao voay ngoong mong nhach nguou kep huyet cot kui queo duech phip phinh tuong vec xit ghanh tuyenh bin pet dooc quim voi pit nghoeo huyep lap tut ruyn poay doao phuat duo dau dip vieu doch coa ngao chau hoon koom roo quoong hat buyet khooc heu ngia phooc mic nuc pia duat kap pum nghip tiep poai boat nuoi nua thoon trang quyeu hoeng ngang thi ngam noom gop oam gech nhoap muo sac mung duenh khia nup quach gao noi nhat truo xong khuyng luu chiem rooc bim hong khip king sem sep rua thuon pec oap punh chet phua gum nhieu due nghuy phuu ngooc vuy uya giap huyenh poen luyu chao vup muy kha dich hieng nan loom khuoi luap mue khat ngiem yep xiet nghi duyt xich nong khem kuong chuay hoao thuong siep goanh quuy loec phoong xiec khuu kienh roat puyn ghiu rieu goai cuu xuyenh dunh soac ngoen chan vuych tanh mum rep truyet chop phic nhoe giup nip loch phat huu vang ngui nue phuo khech khuyet thuyen nghen say mup sec voai ngoam truop roep moa nga xuc nghoi ngung yeu luy lam niem vong chai nuoc guat buyen gioong cing thuc soen dot thet cuon khueu tru luyet dem ngoi via nhom cen noay lot niec giang ninh thun vop buyu huan nhu phien chut duu khunh ngot nhoay ruyen phom xoam teng quau sat nghoe guy quet nghanh hop nghec huyen xup khap vung phum toe chuat xuych buang pay thoeng kheu nuyu nguot cuou biet khom nien tranh phay phuot quooc suec nieu hua trich giuyp trit kiet ngong nhem tip muc phep xuy thuyn xum nhang xoac koo nhoa nhoanh voe luych nuem thuech khien hoac goet truyp ngoang thot vech con khoec muyng miem xunh huang duyet chen ghong duch phang uyp ngin gioe boao anh trung xung lic luang tret xoa gang canh tan xang tang bom suoi long thuenh bot nghich thong ngech giu chi huyech xoat kua nguy hut doong vach nhoong hai tit uay thon kinh bam huong cac xiu troai gioai noat quynh hit phit xoan goong liem gioang doach phoam quinh pieng giau mep oec thien truc choeng guan vac vat kach nham khan nhuot nhoam nhuan ngiep loang guon poong noeng thieng hot pheo boon tien dua phach giui runh gap hic loay luet voanh den chanh thui buong ching boang gai choay loem nach troon phoo vim nuon huych trem poap xat tuop tri phong onh hun sien ghy huya pam tran vinh uep nhoat luop thuet tiu suyen duop hac thuoi cin nuyen bing gioanh ghiem vuou nghieng truyn trieu ngoet oon bet tray rem quoc tich nuyp phoi sim liep nhup trec bong triem gui xech choao teu kot lec keng quoan roao som lim nhuych yec soo puyet mop roan nhung bieng boanh khon phieng toeo xuam nhua leu then thut thep thuay len thoong phuyet cua guu nguech ech xui truyt hoan cinh trenh tua buop khy quat sic moong khonh nghia kheo duay pai kiem neu thiec bop roa quyn nuay hoc voa giop bia chua goang kac noong koe cuan gion huen ngich quin mao ngoem phop khai neng nhop oet coi phac qua suyn sue ngoc nghem sao ngieng thuych cec kang buyp get tuot thac choet mieng poang gioi luon gau nuech tronh khua goen viep nguop truych ngo det got guen mec gip phui pich heng nuya gioem voo sung giuom suech chem phai ghin khoon doom puc peo khoop hoet ruoi quoet nghien the nhunh quo hanh chunh trui nhue chup phieu luou xuang kuy nhoeo suop loao khuon tha xap nguon doet git trau soanh ghu cuong vam queng ton loe nguom nhiec choac chuenh nonh thiep veng pop nhun vuot vuu nech nhoan trep tuyu triep muya huam puom thoc tiem moai muyen vuen uyet xoeng monh khuang toon cop cien lung ghom gia troong tuen kun soet nuen hoay ruynh kuyen pieu cut viet oom xuon pho koc huop chong duych boa rot bieu xoai nhip cam nhieng boai xuay quoang cach ngoeo nguoi nho guoc thung bang muoc thuat muyn nhuop soai ghai phi dung nhy nhan hoap boach coon gheo von giuy suy tin tuy roang dech giut soon bue nghuong suay chuop sang tui muong khoai nghiet xep khop lau chuya cheo gho gha xua ngim diep lip xiem sieng lue nhanh luat trien suu lech goem goay huom ngoanh thoai luen phoen xuyp phuam nghy quuyet chung loc noc lui quyeng hoat kom chien luya rit sam ting nghic tuyep guyn tonh buot oeng uom gionh gic nuong khut hoen thang chuech xoon buyng cuc cuang xuyn hoep treo hin kho triet phoan xuya ngoao trip quop xut mieu poeng lang koanh khuoc nhay thoan duyn dup thoi guay khuyt nguoc phoe cham ghiep huyn khuyem keo viu giac vuyen xieu bao trom cao chuoc tue xoi khoao doeng thuen nhao vuop kue yeng not thic ciu choang ngay bienh doac xoom lich muat nghach nguat ngoay boeng ngoan uym choan trap phap ngoap suang pem chiep rai khic suyet pot thoen giuon boong roem lanh nguya huc guyu dit khieu phoa danh uan nop ran thonh khoa doon pheng sinh duot enh ghiet khuyech puo ngau ngeo nhoep nguych tuoi gep cuy gham nat soa doay truenh nhot trac gim loai coe cho siu pach rue nhoac diet xau giet nhuyet nhic mut xuenh tho chuec thai phuang choem uych thuap chuyem bai ric gioc tuam hui khung gieu nghung nhi voch khec kop xoap nguyt khuan vau xoet khuet phiem trot sup duem khang nuom gua may ngue ngheng roong ngheu uonh cuom ang hip nghieu gioao phung chang hoi choai nuy lao ceo uyen bac can xoay puoc tam cong muan nghep pip vut ruyt ooc phen guet khep ngun bem chuyep roet chu thuan khuych quoac xam trooc pan true nguyn chuyen trat vua rat mat nghu rieng sia uop nghan truon suan moan ciec buen suom soan poom thuoc vuoi nhep cap loeo troan viec thanh cha nhuom nenh giung phiu thoanh khuat uou doap guynh tim luoi quych toang nheu moc denh khuyec vuan voet kieng thay top gonh rinh xuynh cai kiec nghong coong vuon phuy truong xuen tot seng xoen thoeo nghuech cem phan chuu inh nuo quiu teo rong nguynh phiet khuyp cum xue ngut truot xic unh ruop phoac moeng oao gue ngi rop thim quoi nanh sooc truya duom roay vanh chuy run gong nhuoc bau veo nic nhen choc dui tuyem choat rac luom thum xuot chuynh riu gioa bua ruyu buu nhuoi choe gon toa quec lon thach qui vuc met puch quyem thop nep uoy mich chui nai tong kham lay xoanh toc ngop huo khoam nghuen chim nghing ghen soeo moach cuop quoay khach guyt goc luyn pung thuo tuyp dan luonh cay chuoi loat tau truu puyen guot thap dic xoong don vay tiec coc gay ruya ruon nguet sonh phoat koon ghot khinh thom boe khuo quich deu truom moac truat vuay ruong ghac quyen duyen gieo xuet thiem boan poam buyt ruenh ding xot mim xuan khue ghenh quym noai benh nuu banh hum toay puy tuyen donh dep tro nhuong moat khac mac vuet uen sin troen khoac ruyet rui pua suynh poon kip ngeu kieu lup loa nhai thoet puoi tia him phuem khuou miu buoy xuop xuch queu huap chom pom tun muyt ngua khuyu khoc tra noanh xet tria nui ven nhiem suong tach hia thuop cuot buo puon huyng ghun ngiet phonh chuon nguac choi bung quanh mun nhoen tiet duou trech kuyng thech vuem biem nuan gun renh cang ruych ghay nguc duam gec xoem loan panh treu goa lua chia sai quot tieu nghot hon buom gach buynh lenh rup coam ray truy bip vuyt tep thooc huou truyen guyp tuan ngap dinh guya muych roac koen koonh riec nhuynh roap kau nhia soam poa quit oac giuot ponh net ginh bach kuo uon toach that hoem suot vuang ngup phanh ruu chuan pham kiu hup suoc xeng ket khau xooc doanh nhec hoong cit muon dun goi khay mem pup rach moen rich rap ngach duoc uyu dia thuou buya com suam pech guym sich thuang nghim phao vit chenh ring voong nhich phech chiu nghai peng noet quip loo ghieng noem toem khich khuya tham nghuyet tum thua theo nuyet tuc ghach thoa coen thu thuu moom miec khoong khuy kem riem thue tuyet thinh oep chech than khoan looc ngham chuot oang soay cia duy thoach hunh loeng nap poat pep thuom nhuat roc room muen buy phuynh nut hoa moay trun toam khiep poi troe dat phuong phuon giuo puot tuom mang xoach biec mit gom nhinh tram noac phin xin quoanh ruo troac lom voc xuat voam ngac phenh ngenh chin nhuech non muay chuyet ling nguyu chip thip buyn toec ngat xuyu trong trach doai kech dum quoai roanh giam thit tec roe huyt tuyech goac xon boc ghat gien mech thiu nhuam khiet giun sanh theng nghet nhuay ghe choa xay oan cuat pon nhuyn quuyen xeo xuoi ban mau miep nhong truonh chon phuoi quyt too gup nhuyu hen kum thin giot truoi muet troet hiet nhuy nuynh ghich khup trao trunh goo huoc poan giep uam quuay khong phue niep khin rau ghinh nhooc uynh toan veu phe buet ngon nit tuech suyt gat suo xuu nhau reu chap".split())
19
- def tieng_viet_thuong_khong_dau(s):
20
- s = re.sub(u'Đ', 'D', s) # ko cần nữa vì text đã ở dạng lower
21
- s = re.sub(u'đ', 'd', s)
22
- s = unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
23
- return s.decode("utf-8")
24
-
25
- bad_words = """
26
- bú cu, bú cặc, bú lồn, bú lol, bú lon, bú cac, bú cak, bú cax, clip sêx,
27
- bú buoi, bú mút, chịch kiểu chó, chịch lỗ đít, chịch lén, chịch tập thể, húp lol, húp lon, húp sò,
28
- nung lol, nung lon, nug lon, nung cac, nung buoi, thèm dit, thèm lon, thèm lol, thèm buoi, thèm dit,
29
- thèm chich, thèm chịch, thèm cax, thèm cak, móc lol, móc lon, lồn múp, nứng lồn, buscu, lol non,
30
- bướm non, vú to, vú bự, lon to, phim sex, phim xex, phim xxx, phim dâm, hiep dam, làm tình, bú cặc,
31
- yeusex, sexloasn, xem lồn, địt mũi, buồi địt, sex asian, Sex lau xanh, coi quan ao, fuck sillicon toy
32
- """.strip().split(",")
33
- bad_words = [ x.strip().replace(" ","\\s*") for x in bad_words]
34
- bad_words = list(set(bad_words)) # uniq
35
- tmp = "|".join(bad_words)
36
- bad_words_re = rf"[^\S]({tmp})[^\S]"
37
- def bad_words_count(t):
38
- return len(re.findall(bad_words_re, t))
39
-
40
- def sym_filter(t, ratio=0.6):
41
- t = tieng_viet_thuong_khong_dau(t)
42
- tokens = re.split(r'[^a-z]+', t)
43
- sym_count = 0
44
- for tk in tokens:
45
- if tk in syms: sym_count += 1
46
- if sym_count / len(tokens) < ratio:
47
- return t
48
- else: return True
49
-
50
-
51
- # https://github.com/CarperAI/squeakily/blob/main/squeakily/filter.py
52
- from collections import Counter
53
- import numpy as np
54
- def _char_rep_ratio(
55
- doc: str, # document to be analyzed
56
- char_rep_len: int, # length of character repetition
57
- ) -> float:
58
- """Returns the ratio of character repetitions in a document."""
59
- def calc_ngrams(doc, n):
60
- char_ngrams = [doc[i : i + n] for i in range(len(doc) - n + 1)]
61
- freq_char_ngrams = Counter(char_ngrams)
62
- return freq_char_ngrams
63
-
64
- freq_char_ngrams = calc_ngrams(doc, char_rep_len)
65
- if len(freq_char_ngrams) == 0:
66
- return 0
67
- freq_char_ngrams = list(freq_char_ngrams.values())
68
- freq_char_ngrams = sorted(freq_char_ngrams, reverse=True)
69
- val_one = len([el for el in freq_char_ngrams if el == 1])
70
- num_rep_char_ngrams = min(
71
- int(np.sqrt(len(freq_char_ngrams))),
72
- len(freq_char_ngrams) - val_one,
73
- )
74
- char_rep_ratio = sum(freq_char_ngrams[:num_rep_char_ngrams]) / sum(freq_char_ngrams)
75
- return char_rep_ratio
76
-
77
-
78
- def check_char_repetition(
79
- document, # document to be analyzed
80
- char_repetition_len=10, # length of character repetition
81
- char_repetition_threshold=0.02, # threshold for character repetition
82
- dry_run=False, # if True, returns the ratio of character repetition
83
- ) -> bool: # returns True if document is below threshold
84
- """Checks if the document is below the character repetition threshold."""
85
- char_rep_ratio = _char_rep_ratio(document, char_repetition_len)
86
- if dry_run: return char_rep_ratio
87
- else: return char_rep_ratio <= char_repetition_threshold
88
-
89
-
90
- ###########################
91
-
92
- input_files = sys.argv[1].split(",")
93
- if input_files[0] == "jsonl":
94
- import glob
95
- input_files = glob.glob("jsonl/*")
96
-
97
- for input_file in input_files:
98
- file_prefix = input_file.split(".jsonl.lzma")[0]
99
- output_file = f"{file_prefix}_filtered.jsonl.gz"
100
- output_file = output_file.replace("jsonl/", "filtered/")
101
-
102
- print(f"{input_file} => {output_file}")
103
- fo = gzip.open(output_file, "wt")
104
- if logging:
105
- fb = open(f"{file_prefix}_bad.txt", "wt")
106
- fl = open(f"{file_prefix}_low.txt", "wt")
107
- fa = open(f"{file_prefix}_avg.txt", "wt")
108
- fr = open(f"{file_prefix}_rep.txt", "wt")
109
-
110
- with lzma.open(input_file, "rt") as f:
111
- count = bad_count = short_count = low_count = avg_count = rep_count = 0
112
- for line in f:
113
- count += 1
114
- d = json.loads(line)
115
-
116
- # Lọc theo độ dài văn bản
117
- if len(d["text"]) < 600:
118
- short_count += 1
119
- continue
120
-
121
- low_text = d["text"].lower()
122
- # Lọc theo bad words
123
- if bad_words_count(low_text) > 5:
124
- bad_count += 1
125
- if logging: fb.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
126
- continue
127
-
128
- # Lọc theo tỉ lệ âm tiết tiếng Việt
129
- t = sym_filter(low_text)
130
- if t != True:
131
- low_count += 1
132
- if logging: fl.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
133
- continue
134
-
135
- # Lọc theo độ lặp lại của ký tự
136
- if check_char_repetition(low_text):
137
- rep_count += 1
138
- if logging: fr.write(low_text + "\n\n\n- - - - - - - -\n\n\n")
139
- continue
140
-
141
- # Lọc theo good vs c4 classifier
142
- t = d["text"].replace("\n", " ")
143
- label, score = fasttext_predict(t)
144
- if label != "__label__tiasang" or score < 0.85:
145
- avg_count += 1
146
- if logging: fa.write(f"{label} {t}\n")
147
- continue
148
-
149
- ss = json.dumps({"text": d["text"]}, ensure_ascii=False)
150
- fo.write(ss + "\n")
151
-
152
- fo.close()
153
- if logging:
154
- fb.close()
155
- fl.close()
156
- fa.close()
157
- fr.close()
158
-
159
-
160
- print(f"total {count}, short {short_count}, bad {bad_count}, \
161
- low {low_count}, rep {rep_count}, avg {avg_count}")
162
-
163
- short_percent = "{0:.2%}".format(short_count / count); count -= short_count
164
- bad_percent = "{0:.2%}".format(bad_count / count); count -= bad_count
165
- low_percent = "{0:.2%}".format(low_count / count); count -= low_count
166
- rep_percent = "{0:.2%}".format(rep_count / count); count -= rep_count
167
- avg_percent = "{0:.2%}".format(avg_count / count); count -= avg_count
168
-
169
- print(f"remain {count}, short {short_percent}, bad {bad_percent}, \
170
- low {low_percent}, rep {rep_percent}, avg {avg_percent}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.save/parquet2jsonl.py DELETED
@@ -1,58 +0,0 @@
1
- import glob, pandas, sys, os, gzip, json, time, lzma
2
-
3
- try: fast_mode = (sys.argv[2] == "fast")
4
- except: fast_mode = False
5
-
6
- offset = 10
7
- index = int(sys.argv[1]) * offset
8
-
9
- dumps = glob.glob("CC-MAIN-*")
10
- for dump in dumps:
11
- all_buckets = glob.glob(f"{dump}/CC-MAIN-*")
12
- buckets = all_buckets[index : index + offset]
13
- print("\n\n- - - - -\n", dump, "has", len(all_buckets), flush=True)
14
- print(fast_mode, index, offset, buckets, flush=True) #DEBUG
15
- for bucket in buckets:
16
- files = glob.glob(f"{bucket}/*.parquet")
17
- bucket = bucket.replace(f"{dump}/", f"{dump}_")
18
- bucket = bucket.replace("CC-MAIN-", "")
19
- output_file = f"jsonl/{bucket}.jsonl.lzma"
20
- print(output_file, flush=True)
21
-
22
- added_file_ids = set()
23
- if os.path.exists(output_file):
24
- ti_mcur = os.path.getmtime(output_file)
25
- ti_mmax = 0
26
- remains = []
27
- for file in files:
28
- ti_m = os.path.getmtime(file)
29
- if ti_m > ti_mmax: ti_mmax = ti_m
30
- if fast_mode and ti_m > ti_mcur:
31
- remains.append(file)
32
-
33
- if ti_mcur > ti_mmax: continue
34
-
35
- if fast_mode:
36
- files = remains
37
- else:
38
- skip_token = '"id": "000000000."'
39
- with lzma.open(output_file, "rt") as fin:
40
- for count, line in enumerate(fin):
41
- if skip_token not in line:
42
- file_id = line.split('"id": "')[1].split(".")[0] # "id": "{file_id}.{line_count}"
43
- skip_token = f'"id": "{file_id}.'
44
- assert file_id not in added_file_ids
45
- added_file_ids.add(file_id)
46
-
47
- with lzma.open(output_file, "at") as fout:
48
- for file in files:
49
- file_id = file.split("/")[-1].replace(".parquet", "")
50
- if file_id in added_file_ids: continue
51
- print(f"Adding {file_id} to {output_file}...", flush=True)
52
- df = pandas.read_parquet(file)
53
- for line_count, row in df.iterrows():
54
- idd = f"{file_id}.{line_count}"
55
- ss = json.dumps({"text": row[0], "id": idd}, ensure_ascii=False)
56
- fout.write(ss + "\n")
57
-
58
- print("fast_mode", fast_mode)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.save/parquet2jsonl.sh DELETED
@@ -1,12 +0,0 @@
1
- nohup python3 parquet2jsonl.py 0 fast &
2
- nohup python3 parquet2jsonl.py 1 fast &
3
- nohup python3 parquet2jsonl.py 2 fast &
4
- nohup python3 parquet2jsonl.py 3 fast &
5
- nohup python3 parquet2jsonl.py 4 fast &
6
- nohup python3 parquet2jsonl.py 5 fast &
7
- nohup python3 parquet2jsonl.py 6 fast &
8
- nohup python3 parquet2jsonl.py 7 fast &
9
- nohup python3 parquet2jsonl.py 8 fast &
10
- nohup python3 parquet2jsonl.py 9 fast &
11
- tail -f nohup.out
12
-
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md DELETED
@@ -1,37 +0,0 @@
1
- ---
2
- license: mit
3
- language:
4
- - vi
5
- size_categories:
6
- - 1K<n<10K
7
- ---
8
-
9
- # What is Symato CC?
10
- To download all WARC data from Common Crawl then filter out Vietnamese in Markdown and Plaintext format.
11
- There is 1% of Vietnamse in CC, extract all of them out should be a lot (~10TB of plaintext).
12
-
13
- ## Main contributors
14
- - https://huggingface.co/nampdn-ai
15
- - https://huggingface.co/binhvq
16
- - https://huggingface.co/th1nhng0
17
- - https://huggingface.co/iambestfeed
18
-
19
- # Simple quality filters
20
- To make use of raw data from common crawl, you need to do filtering and deduping.
21
- Below is a simple quality filtering code for reference to write your own filters.
22
-
23
- ```sh
24
- ## Convert .parquet to .jsonl.gz
25
- mkdir -p jsonl filtered
26
- python3 parquet2jsonl.py
27
-
28
- ## Quality filter
29
- # wget https://huggingface.co/datasets/Symato/goods_vs_c4_cc_classifiers/resolve/main/fasttext_good_vs_c4_001.bin
30
- python3 filters.py jsonl/2023-14_20230401125552-20230401155552.jsonl.gz logging
31
- ```
32
-
33
- # Disclaimer
34
- - We use content from Common Crawl as it is. Go to CC website to know more about data.
35
- - We provide simple quality filters code to make it easier for you to use data but no warranty the data quality meet everyone expectations. Modifiy ours or write your own filters in-case you need more advanced / better ones.
36
-
37
- Contact **dung at symato dot xyz** if you have other questions.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696381249/warc/CC-MAIN-20130516092621-00038-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2f6ba8a3755675cd207764829f873e755cab9dae7c8e0e40a9f3d4987e8394fa
3
- size 103416
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696381249/warc/CC-MAIN-20130516092621-00039-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:42562ea86f8d4bde3cd982b3cc55731abc97e11afe4eba0e7b5deca354d4b14a
3
- size 111596
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696381249/warc/CC-MAIN-20130516092621-00059-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ad27faed0ad23c489170ccea4d2419286f1a147379033777ff97802dde94a489
3
- size 152280
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696381630/warc/CC-MAIN-20130516092621-00009-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ae6f9bb788926fbea454b561761e6b6abf2de2780c771f7c4e322d579dc502be
3
- size 70368
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696381630/warc/CC-MAIN-20130516092621-00070-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e3636e462c064ace09800ef5ff437fc0305cd37dd88652d23546a63b08f74c57
3
- size 101068
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00021-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5f6b1c0c474737fc1608a03c0e41e62daca67fc56c8fd58eb9fc2a21be9d6aa7
3
- size 104756
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00058-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8d828cbfd9941e75cc0fbbfcbc026a2f7cd2e63636294ec01287f658490810d6
3
- size 136256
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00072-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8885a42b1395f4ba2174bbc23c8dc5a8146bc499fb9f3ed023daa8a38cfba417
3
- size 102208
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382185/warc/CC-MAIN-20130516092622-00081-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:de1ce5b637a66004080e67ef901e88287b6fd921f917061ea22f5ba5082d1d93
3
- size 97924
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00007-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:41ca4821552dbce54b2d2634d3a6b934ea0ddb33df03e823a50456f292348815
3
- size 132960
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00011-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:29c78fd6305241139fa1f1e4730fcef535953d91952ef98536d28c6bae88f4d0
3
- size 111880
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00048-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0de6da9b5f29597574fb249bbb2922b5b9c73a2efb2aca28a3e406d7c73548a8
3
- size 139676
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00051-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:6cf64f9848f1652488b0018f40d81d237a6a50a06c5b0201f9e4506630ce059b
3
- size 97268
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00070-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8398b14559b4d4617640d9d2b80f1f9aaea1d9f11161129e14f67ee17f3e02a2
3
- size 119632
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382261/warc/CC-MAIN-20130516092622-00083-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:553ae11f2e2af2062d4bf21abb56360db08a2e3472fba932283f7f4b298e940c
3
- size 75164
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00001-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3f89e62082dbb08ee63783496faf1d21670f8a4e6dbd1844a412db6a19da504a
3
- size 150608
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00018-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bcc636c5a1aa3f9d217c54474d8dabbb59a0a22fe2c4d20faa653b03cf2813a9
3
- size 98572
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00039-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ca5d8e56fa9d8602f235a8cbba8eb50f785d91b1badb4063647b58d9c6284020
3
- size 116636
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382360/warc/CC-MAIN-20130516092622-00046-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:81d13e470fd4d7643c67682963d35587792780068093eb52fdc7c3d65d01098f
3
- size 59804
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00013-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:6908fce9ba0e35d0239ce0ec556394b55590c01055ea20235d1cfb04abb3662a
3
- size 102200
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00023-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:548cf7a36894e08b3a035ebde529a4e58ab775f78acc1d62642656ab01f8bde7
3
- size 98648
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00027-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:109c593f80435818382309e153aecc2dcddbad94d1275fcfd0c7b84e1c7a11eb
3
- size 98036
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00047-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bca1caa548be40d9828dbfb6b5c5ed9eb2cd1303af4862181499a828590dc913
3
- size 84288
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00067-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4322003e43b525e1a2eb6e7e7fa2b733eae3e54dee08d241ceadbf1e36f80d40
3
- size 75896
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382396/warc/CC-MAIN-20130516092622-00072-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4562b610c701c551651cdd6c927d91b27b4e7a726ef55e976cc5fd074d0d7aa2
3
- size 82032
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382398/warc/CC-MAIN-20130516092622-00003-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ebd72181baf240354e25cd226d76e715dee56d8551ad1b671168b4568767df6f
3
- size 124604
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382398/warc/CC-MAIN-20130516092622-00006-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c789f4a1f80ce90809c24000c7e933d05425be61bbbb1c73f4f8c1e65cfa5043
3
- size 85600
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382398/warc/CC-MAIN-20130516092622-00019-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f04253c9d020ff98f9856670acc4aadc4972bccb358c95c90515c8bf1091c59e
3
- size 97384
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00001-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:483773d22a19070034c2168226ef744c3e49613667398ef8ed177edda487210e
3
- size 102684
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00031-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1bd0a4483b5c2ff52c49ffa571c43a0a7ee847baf4f42675f37dde25bcc4d84f
3
- size 95692
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00046-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:96ac74a2bbfbb3f68fd8dedb670a89157a8895243a34df2ca2c104f171a770f1
3
- size 105460
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00074-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:55bf39b97a354c9ff06758dfbe899d9e6c5f469d60c50cde4893022d1f9fc158
3
- size 123084
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382450/warc/CC-MAIN-20130516092622-00080-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fc8008eb20124bd51806e1e991e4f03bd5d2938ca4121b447c2481ca75b8ad66
3
- size 106432
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382503/warc/CC-MAIN-20130516092622-00020-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:15e65854bd26766ae20377545b7f4feb66a0a93f8dd01b165f57144d90aaa8c9
3
- size 110444
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382503/warc/CC-MAIN-20130516092622-00074-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c6249e3d9d50aca2457179fcf6eb42ed184923cb361608190ef5ccd1f062ec2d
3
- size 129296
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382584/warc/CC-MAIN-20130516092622-00001-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1b463da53ba06a1f648fd469c45f6d0f83f3d4b14f87d73120e3c69c2199de12
3
- size 99248
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382584/warc/CC-MAIN-20130516092622-00007-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:191f70737924b64165e7c100ae2ce13d56c5467bc3ee49001ed665f4fd5ab035
3
- size 102244
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382584/warc/CC-MAIN-20130516092622-00034-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cb046242a91fa8c233ededdc54d70697a8bd0b2a2d3b82469279965c48cb33b5
3
- size 131904
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382705/warc/CC-MAIN-20130516092622-00038-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:59f669f36d3869096112bc5c88f748503569b04b57bcae45f119bd0591484330
3
- size 112048
 
 
 
 
crawl-data/CC-MAIN-2013-20/segments/1368696382705/warc/CC-MAIN-20130516092622-00044-ip-10-60-113-184.ec2.internal.jsonl.xz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:25d75ded526ab84d690a53717fbaff3d278f5a84531195e7e8e4eb0bdd8417a1
3
- size 107272