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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"attachments": {},
|
5 |
+
"cell_type": "markdown",
|
6 |
+
"id": "f133d1af",
|
7 |
+
"metadata": {},
|
8 |
+
"source": [
|
9 |
+
"# Working with Data"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"attachments": {},
|
14 |
+
"cell_type": "markdown",
|
15 |
+
"id": "231cb7ec",
|
16 |
+
"metadata": {},
|
17 |
+
"source": [
|
18 |
+
"In this notebook, we are going to work on the datasets that are going to be used in order to fine tune our NLP models. \n",
|
19 |
+
"The different steps that we are going to follow are:\n",
|
20 |
+
"\n",
|
21 |
+
"- Scraping ads data from Moroccan youtube products channels"
|
22 |
+
]
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"cell_type": "markdown",
|
26 |
+
"id": "8313dd19",
|
27 |
+
"metadata": {},
|
28 |
+
"source": [
|
29 |
+
"# Scraping Data"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"cell_type": "code",
|
34 |
+
"execution_count": 39,
|
35 |
+
"id": "978c782a",
|
36 |
+
"metadata": {},
|
37 |
+
"outputs": [],
|
38 |
+
"source": [
|
39 |
+
"from selenium import webdriver\n",
|
40 |
+
"from selenium.webdriver.edge.options import Options\n",
|
41 |
+
"from selenium.webdriver.common.by import By\n",
|
42 |
+
"from selenium.webdriver.support.ui import WebDriverWait\n",
|
43 |
+
"from selenium.webdriver.support import expected_conditions as EC\n",
|
44 |
+
"from bs4 import BeautifulSoup\n",
|
45 |
+
"import time\n",
|
46 |
+
"import pandas as pd"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"cell_type": "code",
|
51 |
+
"execution_count": 52,
|
52 |
+
"id": "5c643463",
|
53 |
+
"metadata": {},
|
54 |
+
"outputs": [],
|
55 |
+
"source": [
|
56 |
+
"def scrape_ads(url, channel_name, max_scroll=3, wait_time=2):\n",
|
57 |
+
" options = Options()\n",
|
58 |
+
" options.headless = True\n",
|
59 |
+
" options.add_argument(\"--disable-gpu\")\n",
|
60 |
+
" options.add_argument(\"--no-sandbox\")\n",
|
61 |
+
" \n",
|
62 |
+
" # Mute the audio\n",
|
63 |
+
" options.add_argument(\"--mute-audio\")\n",
|
64 |
+
"\n",
|
65 |
+
" driver = webdriver.Edge(options=options)\n",
|
66 |
+
"\n",
|
67 |
+
" driver.get(url)\n",
|
68 |
+
"\n",
|
69 |
+
" # Scroll down to load more videos\n",
|
70 |
+
" height = driver.execute_script(\"return document.documentElement.scrollHeight\")\n",
|
71 |
+
" while True:\n",
|
72 |
+
" driver.execute_script(\"window.scrollTo(0, document.documentElement.scrollHeight);\")\n",
|
73 |
+
" time.sleep(3) # Allow time for the page to load\n",
|
74 |
+
" new_height = driver.execute_script(\"return document.documentElement.scrollHeight\")\n",
|
75 |
+
" if new_height == height:\n",
|
76 |
+
" time.sleep(5) # Wait a bit longer to check if more content loads\n",
|
77 |
+
" new_height = driver.execute_script(\"return document.documentElement.scrollHeight\")\n",
|
78 |
+
" if new_height == height: # If the height is still the same, we are at the bottom\n",
|
79 |
+
" break\n",
|
80 |
+
" height = new_height\n",
|
81 |
+
"\n",
|
82 |
+
" src = driver.page_source\n",
|
83 |
+
" soup = BeautifulSoup(src, 'lxml')\n",
|
84 |
+
" video_links = soup.find_all('a', {'class': 'yt-simple-endpoint focus-on-expand style-scope ytd-rich-grid-media'})\n",
|
85 |
+
" links = [\"https://www.youtube.com\" + link.get('href') for link in video_links if link.get('href')]\n",
|
86 |
+
"\n",
|
87 |
+
" ads = []\n",
|
88 |
+
" titles = []\n",
|
89 |
+
" for link in links:\n",
|
90 |
+
" driver.get(link)\n",
|
91 |
+
" time.sleep(5)\n",
|
92 |
+
"\n",
|
93 |
+
" src = driver.page_source\n",
|
94 |
+
" soup = BeautifulSoup(src, 'lxml')\n",
|
95 |
+
"\n",
|
96 |
+
" ad_text_span = soup.find('span', class_='yt-core-attributed-string--link-inherit-color')\n",
|
97 |
+
" ad_text = ad_text_span.text.strip() if ad_text_span else \"No ad found\"\n",
|
98 |
+
" ads.append(ad_text)\n",
|
99 |
+
"\n",
|
100 |
+
" title_tag = soup.find('h1', {'class': 'title style-scope ytd-video-primary-info-renderer'})\n",
|
101 |
+
" video_title = title_tag.text.strip() if title_tag else 'Title not found'\n",
|
102 |
+
" titles.append(video_title)\n",
|
103 |
+
"\n",
|
104 |
+
" driver.quit()\n",
|
105 |
+
" return ads, titles, links"
|
106 |
+
]
|
107 |
+
},
|
108 |
+
{
|
109 |
+
"cell_type": "code",
|
110 |
+
"execution_count": 63,
|
111 |
+
"id": "939fa26b",
|
112 |
+
"metadata": {},
|
113 |
+
"outputs": [
|
114 |
+
{
|
115 |
+
"name": "stderr",
|
116 |
+
"output_type": "stream",
|
117 |
+
"text": [
|
118 |
+
"C:\\Users\\ADS\\AppData\\Local\\Temp\\ipykernel_14604\\116512856.py:3: DeprecationWarning: headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new')\n",
|
119 |
+
" options.headless = True\n"
|
120 |
+
]
|
121 |
+
}
|
122 |
+
],
|
123 |
+
"source": [
|
124 |
+
"channel = '@inwi'\n",
|
125 |
+
"url = f\"https://www.youtube.com/{channel}/videos\"\n",
|
126 |
+
"ads, titles, links = scrape_ads(url, channel)"
|
127 |
+
]
|
128 |
+
},
|
129 |
+
{
|
130 |
+
"cell_type": "code",
|
131 |
+
"execution_count": 64,
|
132 |
+
"id": "188b9ba2",
|
133 |
+
"metadata": {},
|
134 |
+
"outputs": [
|
135 |
+
{
|
136 |
+
"data": {
|
137 |
+
"text/plain": [
|
138 |
+
"(1380, 1380, 1380)"
|
139 |
+
]
|
140 |
+
},
|
141 |
+
"execution_count": 64,
|
142 |
+
"metadata": {},
|
143 |
+
"output_type": "execute_result"
|
144 |
+
}
|
145 |
+
],
|
146 |
+
"source": [
|
147 |
+
"len(ads), len(titles), len(links)"
|
148 |
+
]
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"cell_type": "code",
|
152 |
+
"execution_count": 65,
|
153 |
+
"id": "d6dedc02",
|
154 |
+
"metadata": {},
|
155 |
+
"outputs": [],
|
156 |
+
"source": [
|
157 |
+
"# put ads, titles and links in a dataframe\n",
|
158 |
+
"df3 = pd.DataFrame({'ad': ads, 'title': titles, 'link': links})\n",
|
159 |
+
"\n",
|
160 |
+
"# add channel column\n",
|
161 |
+
"df3['channel'] = channel"
|
162 |
+
]
|
163 |
+
},
|
164 |
+
{
|
165 |
+
"cell_type": "code",
|
166 |
+
"execution_count": 67,
|
167 |
+
"id": "c7a6bb24",
|
168 |
+
"metadata": {},
|
169 |
+
"outputs": [
|
170 |
+
{
|
171 |
+
"data": {
|
172 |
+
"text/html": [
|
173 |
+
"<div>\n",
|
174 |
+
"<style scoped>\n",
|
175 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
176 |
+
" vertical-align: middle;\n",
|
177 |
+
" }\n",
|
178 |
+
"\n",
|
179 |
+
" .dataframe tbody tr th {\n",
|
180 |
+
" vertical-align: top;\n",
|
181 |
+
" }\n",
|
182 |
+
"\n",
|
183 |
+
" .dataframe thead th {\n",
|
184 |
+
" text-align: right;\n",
|
185 |
+
" }\n",
|
186 |
+
"</style>\n",
|
187 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
188 |
+
" <thead>\n",
|
189 |
+
" <tr style=\"text-align: right;\">\n",
|
190 |
+
" <th></th>\n",
|
191 |
+
" <th>ad</th>\n",
|
192 |
+
" <th>title</th>\n",
|
193 |
+
" <th>link</th>\n",
|
194 |
+
" <th>channel</th>\n",
|
195 |
+
" </tr>\n",
|
196 |
+
" </thead>\n",
|
197 |
+
" <tbody>\n",
|
198 |
+
" <tr>\n",
|
199 |
+
" <th>1375</th>\n",
|
200 |
+
" <td>initiative e-Madrassa proposée par inwi (Souti...</td>\n",
|
201 |
+
" <td>النشاط العلمي - حت التربة - الجزء الأول Janvie...</td>\n",
|
202 |
+
" <td>https://www.youtube.com/watch?v=9z2eSPv7dLo</td>\n",
|
203 |
+
" <td>@inwi</td>\n",
|
204 |
+
" </tr>\n",
|
205 |
+
" <tr>\n",
|
206 |
+
" <th>1376</th>\n",
|
207 |
+
" <td>initiative e-Madrassa proposée par inwi (Souti...</td>\n",
|
208 |
+
" <td>اللغة العربية -أنشطة تطبيقية - الجزء الثاني - ...</td>\n",
|
209 |
+
" <td>https://www.youtube.com/watch?v=IgsAKIPPjig</td>\n",
|
210 |
+
" <td>@inwi</td>\n",
|
211 |
+
" </tr>\n",
|
212 |
+
" <tr>\n",
|
213 |
+
" <th>1377</th>\n",
|
214 |
+
" <td>Le présent de l'indicatif des verbes pronominaux</td>\n",
|
215 |
+
" <td>Le présent de l'indicatif des verbes pronominaux</td>\n",
|
216 |
+
" <td>https://www.youtube.com/watch?v=NvYs05Ix3OY</td>\n",
|
217 |
+
" <td>@inwi</td>\n",
|
218 |
+
" </tr>\n",
|
219 |
+
" <tr>\n",
|
220 |
+
" <th>1378</th>\n",
|
221 |
+
" <td>Soutien scolaire - Français - Novembre 2012</td>\n",
|
222 |
+
" <td>Soutien scolaire - Français - Novembre 2012</td>\n",
|
223 |
+
" <td>https://www.youtube.com/watch?v=ThXZp-jRrUY</td>\n",
|
224 |
+
" <td>@inwi</td>\n",
|
225 |
+
" </tr>\n",
|
226 |
+
" <tr>\n",
|
227 |
+
" <th>1379</th>\n",
|
228 |
+
" <td>Les contes marocains par la voix de Rachi El O...</td>\n",
|
229 |
+
" <td>Emadrassa - L'espace de lecture présenté par R...</td>\n",
|
230 |
+
" <td>https://www.youtube.com/watch?v=OPaECpKBl6I</td>\n",
|
231 |
+
" <td>@inwi</td>\n",
|
232 |
+
" </tr>\n",
|
233 |
+
" </tbody>\n",
|
234 |
+
"</table>\n",
|
235 |
+
"</div>"
|
236 |
+
],
|
237 |
+
"text/plain": [
|
238 |
+
" ad \n",
|
239 |
+
"1375 initiative e-Madrassa proposée par inwi (Souti... \\\n",
|
240 |
+
"1376 initiative e-Madrassa proposée par inwi (Souti... \n",
|
241 |
+
"1377 Le présent de l'indicatif des verbes pronominaux \n",
|
242 |
+
"1378 Soutien scolaire - Français - Novembre 2012 \n",
|
243 |
+
"1379 Les contes marocains par la voix de Rachi El O... \n",
|
244 |
+
"\n",
|
245 |
+
" title \n",
|
246 |
+
"1375 النشاط العلمي - حت التربة - الجزء الأول Janvie... \\\n",
|
247 |
+
"1376 اللغة العربية -أنشطة تطبيقية - الجزء الثاني - ... \n",
|
248 |
+
"1377 Le présent de l'indicatif des verbes pronominaux \n",
|
249 |
+
"1378 Soutien scolaire - Français - Novembre 2012 \n",
|
250 |
+
"1379 Emadrassa - L'espace de lecture présenté par R... \n",
|
251 |
+
"\n",
|
252 |
+
" link channel \n",
|
253 |
+
"1375 https://www.youtube.com/watch?v=9z2eSPv7dLo @inwi \n",
|
254 |
+
"1376 https://www.youtube.com/watch?v=IgsAKIPPjig @inwi \n",
|
255 |
+
"1377 https://www.youtube.com/watch?v=NvYs05Ix3OY @inwi \n",
|
256 |
+
"1378 https://www.youtube.com/watch?v=ThXZp-jRrUY @inwi \n",
|
257 |
+
"1379 https://www.youtube.com/watch?v=OPaECpKBl6I @inwi "
|
258 |
+
]
|
259 |
+
},
|
260 |
+
"execution_count": 67,
|
261 |
+
"metadata": {},
|
262 |
+
"output_type": "execute_result"
|
263 |
+
}
|
264 |
+
],
|
265 |
+
"source": [
|
266 |
+
"df3.tail()"
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"cell_type": "code",
|
271 |
+
"execution_count": 69,
|
272 |
+
"id": "e9f0c14f",
|
273 |
+
"metadata": {},
|
274 |
+
"outputs": [],
|
275 |
+
"source": [
|
276 |
+
"# concat df and df1 , df1, df3\n",
|
277 |
+
"df_ads = pd.concat([df, df1, df2, df3], ignore_index=True)"
|
278 |
+
]
|
279 |
+
},
|
280 |
+
{
|
281 |
+
"cell_type": "code",
|
282 |
+
"execution_count": 73,
|
283 |
+
"id": "94398c8a",
|
284 |
+
"metadata": {},
|
285 |
+
"outputs": [
|
286 |
+
{
|
287 |
+
"data": {
|
288 |
+
"text/html": [
|
289 |
+
"<div>\n",
|
290 |
+
"<style scoped>\n",
|
291 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
292 |
+
" vertical-align: middle;\n",
|
293 |
+
" }\n",
|
294 |
+
"\n",
|
295 |
+
" .dataframe tbody tr th {\n",
|
296 |
+
" vertical-align: top;\n",
|
297 |
+
" }\n",
|
298 |
+
"\n",
|
299 |
+
" .dataframe thead th {\n",
|
300 |
+
" text-align: right;\n",
|
301 |
+
" }\n",
|
302 |
+
"</style>\n",
|
303 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
304 |
+
" <thead>\n",
|
305 |
+
" <tr style=\"text-align: right;\">\n",
|
306 |
+
" <th></th>\n",
|
307 |
+
" <th>ad</th>\n",
|
308 |
+
" <th>title</th>\n",
|
309 |
+
" <th>link</th>\n",
|
310 |
+
" <th>channel</th>\n",
|
311 |
+
" </tr>\n",
|
312 |
+
" </thead>\n",
|
313 |
+
" <tbody>\n",
|
314 |
+
" <tr>\n",
|
315 |
+
" <th>0</th>\n",
|
316 |
+
" <td>بشراكة مع بنك التغدية، مؤسسة أورنج تلتزم بالمس...</td>\n",
|
317 |
+
" <td>Orange Maroc : خطوة خير</td>\n",
|
318 |
+
" <td>https://www.youtube.com/watch?v=3RoNBU-snrc</td>\n",
|
319 |
+
" <td>@orangemaroc</td>\n",
|
320 |
+
" </tr>\n",
|
321 |
+
" <tr>\n",
|
322 |
+
" <th>1</th>\n",
|
323 |
+
" <td>خدمة Transfert internet كاينة مع أورنج 🧡\\n\\nعن...</td>\n",
|
324 |
+
" <td>Orange Maroc: Transfert de solde</td>\n",
|
325 |
+
" <td>https://www.youtube.com/watch?v=oQKRx9i2NdY</td>\n",
|
326 |
+
" <td>@orangemaroc</td>\n",
|
327 |
+
" </tr>\n",
|
328 |
+
" <tr>\n",
|
329 |
+
" <th>2</th>\n",
|
330 |
+
" <td>أورنج ديما كاينة معاك !🧡\\n\\nمع خدمة solde dépa...</td>\n",
|
331 |
+
" <td>Orange Maroc: Solde dépannage</td>\n",
|
332 |
+
" <td>https://www.youtube.com/watch?v=ElW8plKHRrI</td>\n",
|
333 |
+
" <td>@orangemaroc</td>\n",
|
334 |
+
" </tr>\n",
|
335 |
+
" <tr>\n",
|
336 |
+
" <th>3</th>\n",
|
337 |
+
" <td>لفراجة كاينة مع La Fibre d'Orange !\\nنتا غير ...</td>\n",
|
338 |
+
" <td>Orange Maroc : La Fibre d'Orange لفراجة كاينة مع</td>\n",
|
339 |
+
" <td>https://www.youtube.com/watch?v=sDt4tK29Vy8</td>\n",
|
340 |
+
" <td>@orangemaroc</td>\n",
|
341 |
+
" </tr>\n",
|
342 |
+
" <tr>\n",
|
343 |
+
" <th>4</th>\n",
|
344 |
+
" <td>سخاوة النجمة 3 المضوبلة كاينة ! 😍\\nاستافدو من ...</td>\n",
|
345 |
+
" <td>Orange Maroc : النجمة 3 المضوبلة كاينة</td>\n",
|
346 |
+
" <td>https://www.youtube.com/watch?v=U2VOn8mhN8U</td>\n",
|
347 |
+
" <td>@orangemaroc</td>\n",
|
348 |
+
" </tr>\n",
|
349 |
+
" </tbody>\n",
|
350 |
+
"</table>\n",
|
351 |
+
"</div>"
|
352 |
+
],
|
353 |
+
"text/plain": [
|
354 |
+
" ad \n",
|
355 |
+
"0 بشراكة مع بنك التغدية، مؤسسة أورنج تلتزم بالمس... \\\n",
|
356 |
+
"1 خدمة Transfert internet كاينة مع أورنج 🧡\\n\\nعن... \n",
|
357 |
+
"2 أورنج ديما كاينة معاك !🧡\\n\\nمع خدمة solde dépa... \n",
|
358 |
+
"3 لفراجة كاينة مع La Fibre d'Orange !\\nنتا غير ... \n",
|
359 |
+
"4 سخاوة النجمة 3 المضوبلة كاينة ! 😍\\nاستافدو من ... \n",
|
360 |
+
"\n",
|
361 |
+
" title \n",
|
362 |
+
"0 Orange Maroc : خطوة خير \\\n",
|
363 |
+
"1 Orange Maroc: Transfert de solde \n",
|
364 |
+
"2 Orange Maroc: Solde dépannage \n",
|
365 |
+
"3 Orange Maroc : La Fibre d'Orange لفراجة كاينة مع \n",
|
366 |
+
"4 Orange Maroc : النجمة 3 المضوبلة كاينة \n",
|
367 |
+
"\n",
|
368 |
+
" link channel \n",
|
369 |
+
"0 https://www.youtube.com/watch?v=3RoNBU-snrc @orangemaroc \n",
|
370 |
+
"1 https://www.youtube.com/watch?v=oQKRx9i2NdY @orangemaroc \n",
|
371 |
+
"2 https://www.youtube.com/watch?v=ElW8plKHRrI @orangemaroc \n",
|
372 |
+
"3 https://www.youtube.com/watch?v=sDt4tK29Vy8 @orangemaroc \n",
|
373 |
+
"4 https://www.youtube.com/watch?v=U2VOn8mhN8U @orangemaroc "
|
374 |
+
]
|
375 |
+
},
|
376 |
+
"execution_count": 73,
|
377 |
+
"metadata": {},
|
378 |
+
"output_type": "execute_result"
|
379 |
+
}
|
380 |
+
],
|
381 |
+
"source": [
|
382 |
+
"df_ads.head()"
|
383 |
+
]
|
384 |
+
},
|
385 |
+
{
|
386 |
+
"cell_type": "code",
|
387 |
+
"execution_count": 72,
|
388 |
+
"id": "bb4effba",
|
389 |
+
"metadata": {},
|
390 |
+
"outputs": [
|
391 |
+
{
|
392 |
+
"name": "stdout",
|
393 |
+
"output_type": "stream",
|
394 |
+
"text": [
|
395 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
396 |
+
"RangeIndex: 3992 entries, 0 to 3991\n",
|
397 |
+
"Data columns (total 4 columns):\n",
|
398 |
+
" # Column Non-Null Count Dtype \n",
|
399 |
+
"--- ------ -------------- ----- \n",
|
400 |
+
" 0 ad 3992 non-null object\n",
|
401 |
+
" 1 title 3992 non-null object\n",
|
402 |
+
" 2 link 3992 non-null object\n",
|
403 |
+
" 3 channel 3992 non-null object\n",
|
404 |
+
"dtypes: object(4)\n",
|
405 |
+
"memory usage: 124.9+ KB\n"
|
406 |
+
]
|
407 |
+
}
|
408 |
+
],
|
409 |
+
"source": [
|
410 |
+
"df_ads.info()"
|
411 |
+
]
|
412 |
+
},
|
413 |
+
{
|
414 |
+
"cell_type": "code",
|
415 |
+
"execution_count": 70,
|
416 |
+
"id": "76633f3d",
|
417 |
+
"metadata": {},
|
418 |
+
"outputs": [],
|
419 |
+
"source": [
|
420 |
+
"# push to huggingface dataset\n",
|
421 |
+
"from datasets import Dataset\n",
|
422 |
+
"\n",
|
423 |
+
"dataset = Dataset.from_pandas(df_ads)"
|
424 |
+
]
|
425 |
+
},
|
426 |
+
{
|
427 |
+
"cell_type": "code",
|
428 |
+
"execution_count": 49,
|
429 |
+
"id": "7e41b632",
|
430 |
+
"metadata": {},
|
431 |
+
"outputs": [
|
432 |
+
{
|
433 |
+
"data": {
|
434 |
+
"application/vnd.jupyter.widget-view+json": {
|
435 |
+
"model_id": "40e4f65f82e44cfb8a28f6da043299bd",
|
436 |
+
"version_major": 2,
|
437 |
+
"version_minor": 0
|
438 |
+
},
|
439 |
+
"text/plain": [
|
440 |
+
"VBox(children=(HTML(value='<center> <img\\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.sv…"
|
441 |
+
]
|
442 |
+
},
|
443 |
+
"metadata": {},
|
444 |
+
"output_type": "display_data"
|
445 |
+
}
|
446 |
+
],
|
447 |
+
"source": [
|
448 |
+
"from huggingface_hub import notebook_login\n",
|
449 |
+
"notebook_login()"
|
450 |
+
]
|
451 |
+
},
|
452 |
+
{
|
453 |
+
"cell_type": "code",
|
454 |
+
"execution_count": 71,
|
455 |
+
"id": "6b3bd971",
|
456 |
+
"metadata": {},
|
457 |
+
"outputs": [
|
458 |
+
{
|
459 |
+
"data": {
|
460 |
+
"application/vnd.jupyter.widget-view+json": {
|
461 |
+
"model_id": "c35e547ccf024c4580e2433504954f89",
|
462 |
+
"version_major": 2,
|
463 |
+
"version_minor": 0
|
464 |
+
},
|
465 |
+
"text/plain": [
|
466 |
+
"Pushing dataset shards to the dataset hub: 0%| | 0/1 [00:00<?, ?it/s]"
|
467 |
+
]
|
468 |
+
},
|
469 |
+
"metadata": {},
|
470 |
+
"output_type": "display_data"
|
471 |
+
},
|
472 |
+
{
|
473 |
+
"data": {
|
474 |
+
"application/vnd.jupyter.widget-view+json": {
|
475 |
+
"model_id": "48d39e651d034177bcd28097a735febd",
|
476 |
+
"version_major": 2,
|
477 |
+
"version_minor": 0
|
478 |
+
},
|
479 |
+
"text/plain": [
|
480 |
+
"Creating parquet from Arrow format: 0%| | 0/4 [00:00<?, ?ba/s]"
|
481 |
+
]
|
482 |
+
},
|
483 |
+
"metadata": {},
|
484 |
+
"output_type": "display_data"
|
485 |
+
},
|
486 |
+
{
|
487 |
+
"data": {
|
488 |
+
"application/vnd.jupyter.widget-view+json": {
|
489 |
+
"model_id": "b8dde35a9d784fcf81aeeb610837e73d",
|
490 |
+
"version_major": 2,
|
491 |
+
"version_minor": 0
|
492 |
+
},
|
493 |
+
"text/plain": [
|
494 |
+
"Deleting unused files from dataset repository: 0%| | 0/1 [00:00<?, ?it/s]"
|
495 |
+
]
|
496 |
+
},
|
497 |
+
"metadata": {},
|
498 |
+
"output_type": "display_data"
|
499 |
+
},
|
500 |
+
{
|
501 |
+
"data": {
|
502 |
+
"application/vnd.jupyter.widget-view+json": {
|
503 |
+
"model_id": "335d994ba0bf4e069f562eb0e68e1fca",
|
504 |
+
"version_major": 2,
|
505 |
+
"version_minor": 0
|
506 |
+
},
|
507 |
+
"text/plain": [
|
508 |
+
"Downloading metadata: 0%| | 0.00/538 [00:00<?, ?B/s]"
|
509 |
+
]
|
510 |
+
},
|
511 |
+
"metadata": {},
|
512 |
+
"output_type": "display_data"
|
513 |
+
}
|
514 |
+
],
|
515 |
+
"source": [
|
516 |
+
"# Push the dataset to your Hugging Face account\n",
|
517 |
+
"dataset.push_to_hub('MLINSEA/Moroccan_ads')"
|
518 |
+
]
|
519 |
+
}
|
520 |
+
],
|
521 |
+
"metadata": {
|
522 |
+
"kernelspec": {
|
523 |
+
"display_name": "Python 3 (ipykernel)",
|
524 |
+
"language": "python",
|
525 |
+
"name": "python3"
|
526 |
+
},
|
527 |
+
"language_info": {
|
528 |
+
"codemirror_mode": {
|
529 |
+
"name": "ipython",
|
530 |
+
"version": 3
|
531 |
+
},
|
532 |
+
"file_extension": ".py",
|
533 |
+
"mimetype": "text/x-python",
|
534 |
+
"name": "python",
|
535 |
+
"nbconvert_exporter": "python",
|
536 |
+
"pygments_lexer": "ipython3",
|
537 |
+
"version": "undefined.undefined.undefined"
|
538 |
+
}
|
539 |
+
},
|
540 |
+
"nbformat": 4,
|
541 |
+
"nbformat_minor": 5
|
542 |
+
}
|