{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "074301dc-5c70-421c-b2e4-2c6eea686ad2",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import random\n",
    "from collections import Counter\n",
    "\n",
    "from sklearn.model_selection import train_test_split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "06bcfc78-dfe5-4536-a4f0-3efe9bc376d9",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "random.seed(123)\n",
    "\n",
    "positive = []\n",
    "negative = []\n",
    "\n",
    "CHARS = []\n",
    "\n",
    "with open(\"keysmash.txt\") as f:\n",
    "    for line in f:\n",
    "        line = line.strip().lower()\n",
    "        if not line:\n",
    "            continue\n",
    "        \n",
    "        positive.append(line)\n",
    "        \n",
    "        for c in line:\n",
    "            CHARS.append(c)\n",
    "\n",
    "def gen_random_seq(length):\n",
    "    \n",
    "    s = \"\"\n",
    "    \n",
    "    for c in range(length):\n",
    "        s += random.choice(CHARS)\n",
    "    return s\n",
    "        \n",
    "for line in positive:\n",
    "    negative.append(gen_random_seq(len(line)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "2f6a33b9-1b25-4931-8b51-450993f0f4cb",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "df = pd.DataFrame()\n",
    "df[\"text\"] = positive + negative\n",
    "df[\"label\"] = [\"BOTTOM_KEY_SMASH\" for _ in positive] + [\"RANDOM\" for _ in negative]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "5434b9be-2067-4eb2-a7d2-13cfd6bb379a",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>429</th>\n",
       "      <td>dndoid fkfescechb.lhudf64yi</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>282</th>\n",
       "      <td>iieidfjmagvoff</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>383</th>\n",
       "      <td>gjhdgdfjjtosgrf;djdpphoin;o</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>477</th>\n",
       "      <td>fp pnjsenhffgweshudltcvavltbheris;puksuupakafz...</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>428</th>\n",
       "      <td>iprzdbrfkuijsmrpjrnnfggd wpnldjlsskghvdghvnoga...</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>yesasdjh fg</td>\n",
       "      <td>BOTTOM_KEY_SMASH</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>a;slkdfj</td>\n",
       "      <td>BOTTOM_KEY_SMASH</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>447</th>\n",
       "      <td>okkdsgdthfjid;iflvni;hdijkhhsbbdshfsidjupheurd...</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>434</th>\n",
       "      <td>adv0gsho.ishldimsbitbdgchledklsjsljl</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>399</th>\n",
       "      <td>ugkls;lhwhughbhkdpanbfbbv.sa fliutiefsedbdscis...</td>\n",
       "      <td>RANDOM</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  text             label\n",
       "429                        dndoid fkfescechb.lhudf64yi            RANDOM\n",
       "282                                     iieidfjmagvoff            RANDOM\n",
       "383                        gjhdgdfjjtosgrf;djdpphoin;o            RANDOM\n",
       "477  fp pnjsenhffgweshudltcvavltbheris;puksuupakafz...            RANDOM\n",
       "428  iprzdbrfkuijsmrpjrnnfggd wpnldjlsskghvdghvnoga...            RANDOM\n",
       "132                                        yesasdjh fg  BOTTOM_KEY_SMASH\n",
       "5                                             a;slkdfj  BOTTOM_KEY_SMASH\n",
       "447  okkdsgdthfjid;iflvni;hdijkhhsbbdshfsidjupheurd...            RANDOM\n",
       "434               adv0gsho.ishldimsbitbdgchledklsjsljl            RANDOM\n",
       "399  ugkls;lhwhughbhkdpanbfbbv.sa fliutiefsedbdscis...            RANDOM"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_train, df_test = train_test_split(df, test_size=0.2, random_state=123)\n",
    "\n",
    "df_test.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "24e2c4f4-caed-4519-820c-02a135c99f82",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "df_train.to_csv(\"train.csv\", index=False)\n",
    "df_test.to_csv(\"test.csv\", index=False)"
   ]
  }
 ],
 "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}