Buckets:
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "b6755ac9", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from glob import glob\n", | |
| "import json\n", | |
| "import re" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 39, | |
| "id": "1c20e2f4", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "['terengganu-malaysia.jsonl',\n", | |
| " 'kelantan-malaysia-code.jsonl',\n", | |
| " 'kelantan-malaysia.jsonl',\n", | |
| " 'perak-malaysia-code.jsonl',\n", | |
| " 'local-malay-malaysia.jsonl',\n", | |
| " 'pahang-malaysia.jsonl',\n", | |
| " 'pahang-malaysia-code.jsonl',\n", | |
| " 'kedah-malaysia.jsonl',\n", | |
| " 'sarawak-malaysia.jsonl',\n", | |
| " 'sarawak-malaysia-code.jsonl',\n", | |
| " 'sabah-malaysia-code.jsonl',\n", | |
| " 'local-malay-malaysia-code.jsonl',\n", | |
| " 'negeri-sembilan-malaysia-code.jsonl',\n", | |
| " 'sabah-malaysia.jsonl',\n", | |
| " 'melaka-malaysia.jsonl',\n", | |
| " 'terengganu-malaysia-code.jsonl',\n", | |
| " 'johor-malaysia-code.jsonl',\n", | |
| " 'perak-malaysia.jsonl',\n", | |
| " 'negeri-sembilan-malaysia.jsonl',\n", | |
| " 'johor-malaysia.jsonl',\n", | |
| " 'melaka-malaysia-code.jsonl',\n", | |
| " 'kedah-malaysia-code.jsonl']" | |
| ] | |
| }, | |
| "execution_count": 39, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "files = glob('*.jsonl')\n", | |
| "files" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 40, | |
| "id": "1e4d73fd", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "[]" | |
| ] | |
| }, | |
| "execution_count": 40, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "tags = set()\n", | |
| "\n", | |
| "for f in files:\n", | |
| " with open(f) as fopen:\n", | |
| " for l in fopen:\n", | |
| " l = json.loads(l)\n", | |
| " for v in l.values():\n", | |
| " if not isinstance(v, str):\n", | |
| " continue\n", | |
| " t = re.findall(r'</?[^>]+>', v)\n", | |
| " t = [t_ for t_ in t if 'http' not in t_]\n", | |
| " tags.update(set(t))\n", | |
| "rejected = [t for t in tags if 'translate' in t.lower()]\n", | |
| "rejected" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 38, | |
| "id": "8cc6425e", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "for f in files:\n", | |
| " with open(f) as fopen:\n", | |
| " alls = []\n", | |
| " for l in fopen:\n", | |
| " l = json.loads(l)\n", | |
| " for k in l.keys():\n", | |
| " if not isinstance(l[k], str):\n", | |
| " continue\n", | |
| " for r in rejected:\n", | |
| " l[k] = l[k].replace(r, '').strip()\n", | |
| " alls.append(l)\n", | |
| " with open(f, 'w') as fopen:\n", | |
| " for a in alls:\n", | |
| " fopen.write(f'{json.dumps(a)}\\n')\n", | |
| " fopen.flush()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "eb771485", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "python3.10", | |
| "language": "python", | |
| "name": "python3.10" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.10.15" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } | |
Xet Storage Details
- Size:
- 3.65 kB
- Xet hash:
- bd968e8c557ca36b34db200f3792ae2447d62a54f5797fa545093d7fffebe3b2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.