Datasets:
corpus_v4 cleaned
Browse filesFiles changed (29)
- corpus_v4/DONE.jsonAdded+1
- corpus_v4/clean/train-fineweb2-000.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-001.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-002.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-003.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-004.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-005.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-006.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-007.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-008.jsonl.gzAdded+3
- corpus_v4/clean/train-fineweb2-009.jsonl.gzAdded+3
- corpus_v4/clean/train-health-000.jsonl.gzAdded+3
- corpus_v4/clean/train-hplt2-000.jsonl.gzAdded+3
- corpus_v4/clean/train-hplt2-001.jsonl.gzAdded+3
- corpus_v4/clean/train-madlad-000.jsonl.gzAdded+3
- corpus_v4/clean/train-madlad-001.jsonl.gzAdded+3
- corpus_v4/clean/train-madlad-002.jsonl.gzAdded+3
- corpus_v4/clean/train-madlad-003.jsonl.gzAdded+3
- corpus_v4/clean/train-own-000.jsonl.gzAdded+3
- corpus_v4/clean/train-wikipedia-000.jsonl.gzAdded+3
- corpus_v4/clean/val-fineweb2-000.jsonl.gzAdded+3
- corpus_v4/clean/val-health-000.jsonl.gzAdded+3
- corpus_v4/clean/val-hplt2-000.jsonl.gzAdded+3
- corpus_v4/clean/val-madlad-000.jsonl.gzAdded+3
- corpus_v4/clean/val-own-000.jsonl.gzAdded+3
- corpus_v4/clean/val-wikipedia-000.jsonl.gzAdded+3
- corpus_v4/cleaner4.pyAdded+81
- corpus_v4/stats.jsonAdded+143
- corpus_v4/vocab.jsonAdded
1{"chars_train": 1106130081, "chars_val": 16921432, "docs": 504003}123version https://git-lfs.github.com/spec/v1oid sha256:0f80d47a45f393f0815cf310d8df0d56e7e983a693ada803a54772eac0d9e669size 31805133123version https://git-lfs.github.com/spec/v1oid sha256:82df459adf4194aa85b1b00986e69f554931c505351e9a8a02c3911caccff4f1size 31734304123version https://git-lfs.github.com/spec/v1oid sha256:460037f9d648885a74e31bebe21fc4dfe63a0bbbcff095b43034096d0e95e108size 31703507123version https://git-lfs.github.com/spec/v1oid sha256:640b548c36fcb685bea111bb5c61a55d52d398a3f63c5f19d409d44c8f8136a7size 31688203123version https://git-lfs.github.com/spec/v1oid sha256:fe682de0489efbae9ab28f0d9eed46a866873e1d162458d1153b40d60c2e7e85size 31662826123version https://git-lfs.github.com/spec/v1oid sha256:f7f794c2431a10645f6a8c51c30b904ae1c53257f8dbb79d123903781dbe107dsize 31639690123version https://git-lfs.github.com/spec/v1oid sha256:8016ba962dcdf1757ee6217606efa4376f0018df07c8d9e2b8248716ea5f5dacsize 31602959123version https://git-lfs.github.com/spec/v1oid sha256:fe0c37326513f52271928af0ab3ab1133fd98579fdefdf2d9c3a7525c8344d86size 31625946123version https://git-lfs.github.com/spec/v1oid sha256:b5a00fe84345d92fbfe05c43e3b702ad83faa87322e03626bea159e0313ac48esize 31611286123version https://git-lfs.github.com/spec/v1oid sha256:0951653eb57fa67262f1c863822fb978ae29b217e64979e3a6d0b73aec238059size 4104894123version https://git-lfs.github.com/spec/v1oid sha256:ed835f197fb91864c823bd217d54c5ec346de775a6a99a42a90a762b89ed17c3size 862375123version https://git-lfs.github.com/spec/v1oid sha256:be299bf39f6f43d529d952f0e0560b25b21553c6de6a28dfc230228eff14f942size 32017463123version https://git-lfs.github.com/spec/v1oid sha256:f51dc07e6ed9bddddcb723b0083a0d83ab58f546ddc6489592f234e8d54bf287size 19648213123version https://git-lfs.github.com/spec/v1oid sha256:691a6e6f1a8a2b503133a9377334b8df10f63a22ac5e8f60d0a2a7f795e80c27size 31881491123version https://git-lfs.github.com/spec/v1oid sha256:4b76b2e10ea36ba241e05f9866f232918a86cb75208aa777d468b5db18531faasize 31935685123version https://git-lfs.github.com/spec/v1oid sha256:10c6f7e5163e22239910bf49eb24aa33edf28d588970e34e9d9c784ab219ee93size 31908598123version https://git-lfs.github.com/spec/v1oid sha256:e474a7aac6fe034e3c38ff9cb3cac8f2ccdbec76e86467ce3b0fcd34ab5d77c8size 4197223123version https://git-lfs.github.com/spec/v1oid sha256:a47cbf0d174865db92e61f573a15c76504f1cfd866d4e747033aacbe8c60bd7bsize 5948551123version https://git-lfs.github.com/spec/v1oid sha256:e803e076f97ce1926b20dd7a148b88fae8217f3ed805f1be27c1143b2f309396size 684185123version https://git-lfs.github.com/spec/v1oid sha256:dca41c3094732bd384b9fc6b287b5d9cf8d9d98250f4310cf980766d922c3d7esize 4396543123version https://git-lfs.github.com/spec/v1oid sha256:ffb237d4e8ec6bcf71eda35ac5bf7e0d5d9b1909d3a0c1e6c1cdde44fd8c452fsize 16275123version https://git-lfs.github.com/spec/v1oid sha256:54e4e6dd8d6c8ae094bbb5528c125c9e36941ad61766003e696d4a7c332be320size 822926123version https://git-lfs.github.com/spec/v1oid sha256:d51954f480d26c54c0fbe33b04e2fe0efda752e0237ddceb81bd64a12f7bd389size 1554478123version https://git-lfs.github.com/spec/v1oid sha256:ecaa1a005796c72d33697a9ba30ca65c5e676f0a743cc4745dae634454d8a5a7size 104433123version https://git-lfs.github.com/spec/v1oid sha256:eb44e3dae281b899f7ee54f510632a905c4eb57920c17c63321deab77271c782size 1502123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
import re, unicodedata, collectionsKIN = set("""ni mu ku na wa ya ba bya cya rya za ko kandi ariko cyangwa uko iyo aho kuko ngo yavuze yagize abantu igihugu rwanda abana umuntu byose none ubu nta ntabwo uyu iki iyi aba ibi icyo iryo ibyo ubwo bwa bwo rwa rwo mbere nyuma muri kuri cyane yari bari ari ry n w y z b kndetse hamwe rero maze bose buri hari hano ibindi abandi umwaka igihe ejo uwo nk nka nko nyamara kugira gukora kuba ubundi yaba bavuga avuga bavuze kugeza hagati hejuru munsi imbere inyuma hanze iminsi umunsi ukwezi ubuzima ubukungu abaturage umuryango ikigo leta guverinoma minisitiri perezida umuyobozi uburyo ubwoko ibintu ikintu gusa ahubwo kubera bityo kugirango nubwo naho nawe nabo nayo nabyo ntawe ntacyo mwe""".split())FOREIGN = set("""the and of to is for with that this are was were have has been from by on it as at or an not but you your our their will they what when how which also more than into about said les des est pour dans avec une pas que qui sur aux du la le et en ce cette sont ont par plus nous vous""".split())EXTRA_EN = set("""in on at it as be we he she they there their his her its if so do no yes all any can may one two new more most also such than then them these those some other out up over only just like get got use used http https com www org net html php jpg png tags posted comment comments share tweet email""".split())ENG = (FOREIGN | EXTRA_EN) - {"no", "we", "a"}ONE = set("nwyzbkr")BOILER_RE = re.compile(r"cookie|subscribe|copyright|all rights reserved|click here|follow us|read more|read also|share this|whatsapp|facebook|instagram|twitter|youtube|kanda hano|tanga igitekerezo|soma na byo|dukurikire|twandikire|iyandikishe|ohereza igitekerezo|advertis|kwamamaza|\u00a9", re.I)META_RE = re.compile(r"^(tags?|posted|categories|category|filed under|related|source|photos?|share|tweet|email|print|comments?|leave a|reply|by)\s*[:\-]", re.I)CTRL = re.compile(r"[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2060\ufeff\u00ad]")SYM = re.compile("[\U0001F000-\U0001FFFF\u2190-\u2BFF\uFE00-\uFE0F]")QUOTES = str.maketrans({"\u2019": "'", "\u2018": "'", "\u02bc": "'", "`": "'", "\u00b4": "'", "\u201c": '"', "\u201d": '"', "\u00ab": '"', "\u00bb": '"', "\u2013": "-", "\u2014": "-", "\u2010": "-", "\u2011": "-", "\u2012": "-", "\u2015": "-", "\u2212": "-", "\u2026": "...", "\u00a0": " ", "\u2009": " ", "\u202f": " "})MD_IMG, MD_LINK = re.compile(r"!\[[^\]]*\]\([^)]*\)"), re.compile(r"\[([^\]]*)\]\([^)]*\)")URL, MARK, HTML = re.compile(r"https?://\S+|www\.\S+|\S+@\S+\.\S+"), re.compile(r"[*_#>|~]+"), re.compile(r"<[^>]{1,200}>")RUNP, RUNC, WORD = re.compile(r"([.!?,;:\-=])\1{2,}"), re.compile(r"(.)\1{5,}"), re.compile(r"[a-z]+")VOCAB = None
def nonlatin_letter(c): o = ord(c); return o > 0x24f and not (0x1e00 <= o <= 0x1eff) and unicodedata.category(c).startswith("L")def expand(text): if "\\n" in text and text.count("\\n") > text.count("\n"): text = text.replace("\\n", "\n") if "\\t" in text and "\t" not in text: text = text.replace("\\t", "\n") if "\\r" in text and "\r" not in text: text = text.replace("\\r", "\n") return textdef clean_line(l): if "\ufffd" in l: return None, "encoding_damage" l = CTRL.sub("", unicodedata.normalize("NFC", l).translate(QUOTES)); l = SYM.sub(" ", l) l = HTML.sub(" ", l); l = MD_IMG.sub(" ", l); l = MD_LINK.sub(r"\1", l); l = URL.sub(" ", l); l = MARK.sub(" ", l); l = RUNP.sub(r"\1", l) l = re.sub(r"\s+", " ", l).strip(" -\u2022\u00b7\u00bb\u00ab\"'") n = len(l) if n < 25: return None, "short" if META_RE.match(l): return None, "meta" alpha = sum(ch.isalpha() for ch in l) if alpha / n < 0.65: return None, "symbols" if sum(ch.isdigit() for ch in l) / n > 0.2: return None, "digits" if sum(nonlatin_letter(ch) for ch in l) / n > 0.02: return None, "non_latin" tag = None if RUNC.search(l): if n < 100: return None, "repeat_chars" l, tag = RUNC.sub(lambda m: m.group(1) * 2, l), "FIX_collapsed_runs" if sum(ch.isupper() for ch in l) / max(alpha, 1) > 0.8 and n < 100: return None, "all_caps" if BOILER_RE.search(l) and n < 140: return None, "boiler_kw" w = WORD.findall(l.lower()); k = sum(x in KIN for x in w); f = sum(x in FOREIGN for x in w) if f >= 2 and f > k: return None, "foreign" if VOCAB is not None and len(w) >= 6: cov = sum((x in VOCAB) or (x in ONE) for x in w) / len(w) if cov < 0.25 or (cov < 0.4 and f >= 1): return None, "low_vocab" return l, tag_orig_clean_line = clean_linedef clean_line(l): # extra rule: lines that are mostly English words (product titles, tags) out, tag = _orig_clean_line(l) if out is not None: w = WORD.findall(out.lower()) if len(w) >= 5 and sum(x in ENG for x in w) / len(w) > 0.3: return None, "english_heavy" return out, tagdef clean_doc(text): lines, why = [], collections.Counter() for l in expand(text).split("\n"): c, r = clean_line(l) if c: lines.append(c) if r: why[r] += 1 elif l.strip(): why[r] += 1 return lines, whydef build_vocab(docs, min_count=10): global VOCAB VOCAB = None; cnt = collections.Counter() for d in docs: for l in clean_doc(d)[0]: cnt.update(WORD.findall(l.lower())) return {w for w, c in cnt.items() if c >= min_count and len(w) >= 2 and w not in FOREIGN and w not in EXTRA_EN}def worker_init(vocab): # runs once in each worker process global VOCAB VOCAB = set(vocab) if vocab is not None else Nonedef clean_batch(docs): out = [] for d in docs: lines, why = clean_doc(d); out.append((lines, dict(why))) return out123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143{ "own": { "n_in": 9952, "n_out": 9701, "non_latin": 218, "doc_empty": 251, "FIX_collapsed_runs": 7, "foreign": 21, "low_vocab": 9, "boiler_kw": 1, "meta": 1, "encoding_damage": 1, "docs_kept": 8817, "chars_train": 15555805, "chars_val": 257142, "doc_short": 884, "boiler_line": 16, "dup_line": 1 }, "wikipedia": { "n_in": 8063, "n_out": 7706, "short": 41043, "foreign": 781, "symbols": 1409, "low_vocab": 406, "doc_empty": 357, "all_caps": 218, "non_latin": 543, "english_heavy": 19, "boiler_kw": 35, "digits": 6, "meta": 7, "FIX_collapsed_runs": 3, "encoding_damage": 1, "boiler_line": 1907, "doc_dup": 4605, "docs_kept": 511, "chars_train": 1787296, "dup_line": 2685, "doc_short": 2587, "doc_repetitive": 3, "chars_val": 2800 }, "health": { "n_in": 955, "n_out": 955, "all_caps": 892, "short": 3469, "symbols": 96, "foreign": 29, "low_vocab": 16, "digits": 1, "docs_kept": 954, "chars_train": 2342486, "dup_line": 127, "chars_val": 40479, "boiler_line": 2, "doc_short": 1 }, "fineweb2": { "n_in": 326120, "n_out": 326111, "short": 277420, "all_caps": 17233, "foreign": 23329, "boiler_kw": 14385, "symbols": 21961, "low_vocab": 2800, "FIX_collapsed_runs": 857, "meta": 945, "english_heavy": 334, "digits": 186, "encoding_damage": 656, "repeat_chars": 383, "non_latin": 317, "doc_empty": 9, "docs_kept": 313716, "chars_train": 715763065, "boiler_line": 206438, "dup_line": 189854, "doc_short": 11991, "chars_val": 10864743, "doc_dup": 404 }, "hplt2": { "n_in": 92699, "n_out": 92647, "short": 255592, "low_vocab": 3421, "foreign": 23859, "digits": 241, "symbols": 32120, "boiler_kw": 14568, "all_caps": 26847, "repeat_chars": 638, "english_heavy": 943, "FIX_collapsed_runs": 1742, "meta": 817, "non_latin": 2095, "doc_empty": 52, "encoding_damage": 39, "docs_kept": 42671, "chars_train": 126194351, "boiler_line": 300448, "doc_short": 49204, "dup_line": 682890, "doc_dup": 467, "doc_repetitive": 305, "chars_val": 2009563 }, "madlad": { "n_in": 300000, "n_out": 240756, "low_vocab": 522783, "symbols": 415101, "foreign": 305160, "short": 283723, "doc_empty": 59244, "boiler_kw": 21890, "english_heavy": 4231, "all_caps": 28726, "non_latin": 6235, "encoding_damage": 3319, "meta": 12122, "FIX_collapsed_runs": 2807, "digits": 1571, "repeat_chars": 1319, "docs_kept": 137334, "chars_train": 244487078, "doc_short": 102946, "dup_line": 1029143, "boiler_line": 38691, "chars_val": 3746705, "doc_dup": 271, "doc_repetitive": 205 }, "_total": { "chars_train": 1106130081, "chars_val": 16921432, "docs": 504003 }}corpus_v4/DONE.jsonAdded+1
corpus_v4/clean/train-fineweb2-000.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-001.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-002.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-003.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-004.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-005.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-006.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-007.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-008.jsonl.gzAdded+3
corpus_v4/clean/train-fineweb2-009.jsonl.gzAdded+3
corpus_v4/clean/train-health-000.jsonl.gzAdded+3
corpus_v4/clean/train-hplt2-000.jsonl.gzAdded+3
corpus_v4/clean/train-hplt2-001.jsonl.gzAdded+3
corpus_v4/clean/train-madlad-000.jsonl.gzAdded+3
corpus_v4/clean/train-madlad-001.jsonl.gzAdded+3
corpus_v4/clean/train-madlad-002.jsonl.gzAdded+3
corpus_v4/clean/train-madlad-003.jsonl.gzAdded+3
corpus_v4/clean/train-own-000.jsonl.gzAdded+3
corpus_v4/clean/train-wikipedia-000.jsonl.gzAdded+3
corpus_v4/clean/val-fineweb2-000.jsonl.gzAdded+3
corpus_v4/clean/val-health-000.jsonl.gzAdded+3
corpus_v4/clean/val-hplt2-000.jsonl.gzAdded+3
corpus_v4/clean/val-madlad-000.jsonl.gzAdded+3
corpus_v4/clean/val-own-000.jsonl.gzAdded+3
corpus_v4/clean/val-wikipedia-000.jsonl.gzAdded+3
corpus_v4/cleaner4.pyAdded+81
corpus_v4/stats.jsonAdded+143
corpus_v4/vocab.jsonAdded