{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "source": [ "!pip install -q datasets" ], "metadata": { "id": "2qqQTNJwG9nq" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!huggingface-cli login --token toooooookeeeeeen" ], "metadata": { "id": "zX5wF0ckFDgp" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "0hetyPDEExaQ" }, "outputs": [], "source": [ "!curl --remote-name-all https://lindat.mff.cuni.cz/repository/xmlui/bitstream/handle/11234/1-3195/lscp-0.5-fa-cs.7z\n", "!7z -y e \"lscp-0.5-fa-cs.7z\"" ] }, { "cell_type": "code", "source": [ "import pandas as pd\n", "df = pd.read_csv(\"lscp-0.5-fa-cs.txt\", sep=\"@@@@\" ,names=[ 'text'])" ], "metadata": { "id": "UK7MZn5_E1Vg" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "df.iloc[0:10]" ], "metadata": { "id": "06_9eulXE3KC" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "df['text'][:10].to_csv(\"1111lscptest.csv\",index=False)" ], "metadata": { "id": "sToNTy_AIgoD" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "df.dropna()" ], "metadata": { "id": "--Op1EQnVuPO" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "fa_token = ['ا','ل','ر','م','ن','و','د','ب','ت','س',\n", " 'ی','ه','ع','ح','ف','ش','ق','ج','ز','خ','ک','ص',\n", " 'ط','أ','گ','پ','غ','ض','آ','ئ','ث','چ','ظ']\n", "\n", "def isfarsi(x):\n", " if x[0] in fa_token or x[-1] in fa_token:\n", " return True\n", " else:\n", " return False\n", "\n", "#cf = pd.read_csv(\"/content/1111lscptest.csv\" ,names=[ 'text'])\n", "df['isfarsi'] = df['text'].apply(isfarsi)\n", "df.iloc[:100]" ], "metadata": { "id": "4qpDuUv7VvUX" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "df.describe()" ], "metadata": { "id": "q1JeSfj8ZJkX" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "newdf = df[(df.isfarsi == True)]\n", "newdf.describe()" ], "metadata": { "id": "usQLQBIiZC6u" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "newdf.dropna()\n", "newdf['text'][:6000000].to_csv(\"lscptrain.csv\" , index=False)\n", "newdf['text'][6000000:].to_csv(\"lscptest.csv\" , index=False)" ], "metadata": { "id": "Lr0DiXJ3E5M0" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from datasets import load_dataset\n", "dataset = load_dataset(\"csv\", data_files={\"train\": [\"/content/lscptrain.csv\"], \"test\": \"/content/lscptest.csv\"})" ], "metadata": { "id": "4p9yKtoBE7pc" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "dataset.push_to_hub(\"Aleereza/lscp\")" ], "metadata": { "id": "zHtP2IqdE9qk" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from datasets import load_dataset\n", "dataset = load_dataset( \"Aleereza/lscp\", split=\"train\")" ], "metadata": { "id": "ZQl1AmokE_Oa" }, "execution_count": null, "outputs": [] } ] }