Upload lscp_DataSet.ipynb
Browse files- lscp_DataSet.ipynb +191 -0
lscp_DataSet.ipynb
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"nbformat": 4,
|
3 |
+
"nbformat_minor": 0,
|
4 |
+
"metadata": {
|
5 |
+
"colab": {
|
6 |
+
"provenance": []
|
7 |
+
},
|
8 |
+
"kernelspec": {
|
9 |
+
"name": "python3",
|
10 |
+
"display_name": "Python 3"
|
11 |
+
},
|
12 |
+
"language_info": {
|
13 |
+
"name": "python"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"cells": [
|
17 |
+
{
|
18 |
+
"cell_type": "code",
|
19 |
+
"source": [
|
20 |
+
"!pip install -q datasets"
|
21 |
+
],
|
22 |
+
"metadata": {
|
23 |
+
"id": "2qqQTNJwG9nq"
|
24 |
+
},
|
25 |
+
"execution_count": null,
|
26 |
+
"outputs": []
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"cell_type": "code",
|
30 |
+
"source": [
|
31 |
+
"!huggingface-cli login --token toooooookeeeeeen"
|
32 |
+
],
|
33 |
+
"metadata": {
|
34 |
+
"id": "zX5wF0ckFDgp"
|
35 |
+
},
|
36 |
+
"execution_count": null,
|
37 |
+
"outputs": []
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"cell_type": "code",
|
41 |
+
"execution_count": null,
|
42 |
+
"metadata": {
|
43 |
+
"id": "0hetyPDEExaQ"
|
44 |
+
},
|
45 |
+
"outputs": [],
|
46 |
+
"source": [
|
47 |
+
"!curl --remote-name-all https://lindat.mff.cuni.cz/repository/xmlui/bitstream/handle/11234/1-3195/lscp-0.5-fa-cs.7z\n",
|
48 |
+
"!7z -y e \"lscp-0.5-fa-cs.7z\""
|
49 |
+
]
|
50 |
+
},
|
51 |
+
{
|
52 |
+
"cell_type": "code",
|
53 |
+
"source": [
|
54 |
+
"import pandas as pd\n",
|
55 |
+
"df = pd.read_csv(\"lscp-0.5-fa-cs.txt\", sep=\"@@@@\" ,names=[ 'text'])"
|
56 |
+
],
|
57 |
+
"metadata": {
|
58 |
+
"id": "UK7MZn5_E1Vg"
|
59 |
+
},
|
60 |
+
"execution_count": null,
|
61 |
+
"outputs": []
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"source": [
|
66 |
+
"df.iloc[0:10]"
|
67 |
+
],
|
68 |
+
"metadata": {
|
69 |
+
"id": "06_9eulXE3KC"
|
70 |
+
},
|
71 |
+
"execution_count": null,
|
72 |
+
"outputs": []
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"cell_type": "code",
|
76 |
+
"source": [
|
77 |
+
"df['text'][:10].to_csv(\"1111lscptest.csv\",index=False)"
|
78 |
+
],
|
79 |
+
"metadata": {
|
80 |
+
"id": "sToNTy_AIgoD"
|
81 |
+
},
|
82 |
+
"execution_count": null,
|
83 |
+
"outputs": []
|
84 |
+
},
|
85 |
+
{
|
86 |
+
"cell_type": "code",
|
87 |
+
"source": [
|
88 |
+
"df.dropna()"
|
89 |
+
],
|
90 |
+
"metadata": {
|
91 |
+
"id": "--Op1EQnVuPO"
|
92 |
+
},
|
93 |
+
"execution_count": null,
|
94 |
+
"outputs": []
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"cell_type": "code",
|
98 |
+
"source": [
|
99 |
+
"fa_token = ['ا','ل','ر','م','ن','و','د','ب','ت','س',\n",
|
100 |
+
" 'ی','ه','ع','ح','ف','ش','ق','ج','ز','خ','ک','ص',\n",
|
101 |
+
" 'ط','أ','گ','پ','غ','ض','آ','ئ','ث','چ','ظ']\n",
|
102 |
+
"\n",
|
103 |
+
"def isfarsi(x):\n",
|
104 |
+
" if x[0] in fa_token or x[-1] in fa_token:\n",
|
105 |
+
" return True\n",
|
106 |
+
" else:\n",
|
107 |
+
" return False\n",
|
108 |
+
"\n",
|
109 |
+
"#cf = pd.read_csv(\"/content/1111lscptest.csv\" ,names=[ 'text'])\n",
|
110 |
+
"df['isfarsi'] = df['text'].apply(isfarsi)\n",
|
111 |
+
"df.iloc[:100]"
|
112 |
+
],
|
113 |
+
"metadata": {
|
114 |
+
"id": "4qpDuUv7VvUX"
|
115 |
+
},
|
116 |
+
"execution_count": null,
|
117 |
+
"outputs": []
|
118 |
+
},
|
119 |
+
{
|
120 |
+
"cell_type": "code",
|
121 |
+
"source": [
|
122 |
+
"df.describe()"
|
123 |
+
],
|
124 |
+
"metadata": {
|
125 |
+
"id": "q1JeSfj8ZJkX"
|
126 |
+
},
|
127 |
+
"execution_count": null,
|
128 |
+
"outputs": []
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"cell_type": "code",
|
132 |
+
"source": [
|
133 |
+
"newdf = df[(df.isfarsi == True)]\n",
|
134 |
+
"newdf.describe()"
|
135 |
+
],
|
136 |
+
"metadata": {
|
137 |
+
"id": "usQLQBIiZC6u"
|
138 |
+
},
|
139 |
+
"execution_count": null,
|
140 |
+
"outputs": []
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"cell_type": "code",
|
144 |
+
"source": [
|
145 |
+
"newdf.dropna()\n",
|
146 |
+
"newdf['text'][:6000000].to_csv(\"lscptrain.csv\" , index=False)\n",
|
147 |
+
"newdf['text'][6000000:].to_csv(\"lscptest.csv\" , index=False)"
|
148 |
+
],
|
149 |
+
"metadata": {
|
150 |
+
"id": "Lr0DiXJ3E5M0"
|
151 |
+
},
|
152 |
+
"execution_count": null,
|
153 |
+
"outputs": []
|
154 |
+
},
|
155 |
+
{
|
156 |
+
"cell_type": "code",
|
157 |
+
"source": [
|
158 |
+
"from datasets import load_dataset\n",
|
159 |
+
"dataset = load_dataset(\"csv\", data_files={\"train\": [\"/content/lscptrain.csv\"], \"test\": \"/content/lscptest.csv\"})"
|
160 |
+
],
|
161 |
+
"metadata": {
|
162 |
+
"id": "4p9yKtoBE7pc"
|
163 |
+
},
|
164 |
+
"execution_count": null,
|
165 |
+
"outputs": []
|
166 |
+
},
|
167 |
+
{
|
168 |
+
"cell_type": "code",
|
169 |
+
"source": [
|
170 |
+
"dataset.push_to_hub(\"Aleereza/lscp\")"
|
171 |
+
],
|
172 |
+
"metadata": {
|
173 |
+
"id": "zHtP2IqdE9qk"
|
174 |
+
},
|
175 |
+
"execution_count": null,
|
176 |
+
"outputs": []
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"cell_type": "code",
|
180 |
+
"source": [
|
181 |
+
"from datasets import load_dataset\n",
|
182 |
+
"dataset = load_dataset( \"Aleereza/lscp\", split=\"train\")"
|
183 |
+
],
|
184 |
+
"metadata": {
|
185 |
+
"id": "ZQl1AmokE_Oa"
|
186 |
+
},
|
187 |
+
"execution_count": null,
|
188 |
+
"outputs": []
|
189 |
+
}
|
190 |
+
]
|
191 |
+
}
|