{ "cells": [ { "cell_type": "code", "execution_count": 5, "id": "fe90069e-d214-4439-9536-3cff4d993308", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total samples: 6563\n", "Splits created successfully.\n" ] } ], "source": [ "import json\n", "import random\n", "\n", "INPUT_JSONL = \"merged_voxcpm_dataset.jsonl\"\n", "\n", "SET_A_JSONL = \"set_A.jsonl\"\n", "SET_B_JSONL = \"set_B.jsonl\"\n", "SET_C_JSONL = \"set_C.jsonl\"\n", "\n", "random.seed(42)\n", "\n", "# ---- Load JSONL properly ----\n", "data = []\n", "with open(INPUT_JSONL, \"r\", encoding=\"utf-8\") as f:\n", " for line in f:\n", " line = line.strip()\n", " if line:\n", " data.append(json.loads(line))\n", "\n", "print(\"Total samples:\", len(data))\n", "\n", "# ---- Split ----\n", "set_A_pool = data[0:5000]\n", "set_B_pool = data[5000:6300]\n", "set_C_pool = data[6300:]\n", "\n", "set_A = random.sample(set_A_pool, 500)\n", "set_B = random.sample(set_B_pool, 400)\n", "set_C = random.sample(set_C_pool, 50)\n", "\n", "# ---- Save JSONL ----\n", "def save_jsonl(path, dataset):\n", " with open(path, \"w\", encoding=\"utf-8\") as f:\n", " for item in dataset:\n", " f.write(json.dumps(item, ensure_ascii=False) + \"\\n\")\n", "\n", "save_jsonl(SET_A_JSONL, set_A)\n", "save_jsonl(SET_B_JSONL, set_B)\n", "save_jsonl(SET_C_JSONL, set_C)\n", "\n", "print(\"Splits created successfully.\")" ] }, { "cell_type": "code", "execution_count": null, "id": "ed19a713-2c8c-4701-b112-2a95fd43fccd", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.18" } }, "nbformat": 4, "nbformat_minor": 5 }