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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 48,
|
6 |
+
"id": "19c5ce1a-039d-4c1e-9795-6eb6116cd1ab",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import pandas as pd\n",
|
11 |
+
"import csv\n",
|
12 |
+
"import pymorphy3\n",
|
13 |
+
"from pymorphy3 import MorphAnalyzer\n",
|
14 |
+
"import time\n",
|
15 |
+
"from tqdm import tqdm\n",
|
16 |
+
"\n",
|
17 |
+
"\n",
|
18 |
+
"import numpy as np\n",
|
19 |
+
"import re\n",
|
20 |
+
"import string\n",
|
21 |
+
"import nltk\n",
|
22 |
+
"from collections import defaultdict\n",
|
23 |
+
"from sklearn import metrics\n",
|
24 |
+
"from time import time\n",
|
25 |
+
"from nltk.corpus import stopwords\n",
|
26 |
+
"from nltk.stem import WordNetLemmatizer\n",
|
27 |
+
"from nltk.tokenize import RegexpTokenizer\n",
|
28 |
+
"from sklearn.feature_extraction.text import TfidfVectorizer\n",
|
29 |
+
"from sklearn.cluster import KMeans\n",
|
30 |
+
"from sklearn.datasets import fetch_20newsgroups\n",
|
31 |
+
"from sklearn.decomposition import TruncatedSVD\n",
|
32 |
+
"from sklearn.pipeline import make_pipeline\n",
|
33 |
+
"from sklearn.preprocessing import Normalizer\n",
|
34 |
+
"\n",
|
35 |
+
"from nltk.tokenize import word_tokenize\n",
|
36 |
+
"import requests\n",
|
37 |
+
"\n",
|
38 |
+
"import sklearn\n",
|
39 |
+
"sklearn.set_config(transform_output='pandas')"
|
40 |
+
]
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"cell_type": "markdown",
|
44 |
+
"id": "991d7d3f-8968-4e99-9148-e17b66761316",
|
45 |
+
"metadata": {},
|
46 |
+
"source": [
|
47 |
+
"Датасет от Валерии"
|
48 |
+
]
|
49 |
+
},
|
50 |
+
{
|
51 |
+
"cell_type": "code",
|
52 |
+
"execution_count": 6,
|
53 |
+
"id": "1de2cc8a-1740-4ebd-aa83-2291cf12e4ef",
|
54 |
+
"metadata": {},
|
55 |
+
"outputs": [
|
56 |
+
{
|
57 |
+
"data": {
|
58 |
+
"text/html": [
|
59 |
+
"<div>\n",
|
60 |
+
"<style scoped>\n",
|
61 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
62 |
+
" vertical-align: middle;\n",
|
63 |
+
" }\n",
|
64 |
+
"\n",
|
65 |
+
" .dataframe tbody tr th {\n",
|
66 |
+
" vertical-align: top;\n",
|
67 |
+
" }\n",
|
68 |
+
"\n",
|
69 |
+
" .dataframe thead th {\n",
|
70 |
+
" text-align: right;\n",
|
71 |
+
" }\n",
|
72 |
+
"</style>\n",
|
73 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
74 |
+
" <thead>\n",
|
75 |
+
" <tr style=\"text-align: right;\">\n",
|
76 |
+
" <th></th>\n",
|
77 |
+
" <th>page_url</th>\n",
|
78 |
+
" <th>image_url</th>\n",
|
79 |
+
" <th>author</th>\n",
|
80 |
+
" <th>title</th>\n",
|
81 |
+
" <th>annotation</th>\n",
|
82 |
+
" </tr>\n",
|
83 |
+
" </thead>\n",
|
84 |
+
" <tbody>\n",
|
85 |
+
" <tr>\n",
|
86 |
+
" <th>0</th>\n",
|
87 |
+
" <td>https://www.biblio-globus.ru//product/10957168</td>\n",
|
88 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
89 |
+
" <td>Маринина А.</td>\n",
|
90 |
+
" <td>Ричард Третий и Генрих Восьмой глазами Шекспира</td>\n",
|
91 |
+
" <td>Расследование жизни и деяний двух самых опороч...</td>\n",
|
92 |
+
" </tr>\n",
|
93 |
+
" <tr>\n",
|
94 |
+
" <th>1</th>\n",
|
95 |
+
" <td>https://www.biblio-globus.ru//product/10997075</td>\n",
|
96 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
97 |
+
" <td>Михалкова Е.И.</td>\n",
|
98 |
+
" <td>Знак истинного пути</td>\n",
|
99 |
+
" <td>Сыщики Макар Илюшин и Сергей Бабкин расследуют...</td>\n",
|
100 |
+
" </tr>\n",
|
101 |
+
" <tr>\n",
|
102 |
+
" <th>2</th>\n",
|
103 |
+
" <td>https://www.biblio-globus.ru//product/10941892</td>\n",
|
104 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
105 |
+
" <td>Маринина А.</td>\n",
|
106 |
+
" <td>Генрих Шестой глазами Шекспира</td>\n",
|
107 |
+
" <td>Генрих Шестой – самая трагическая фигура на ан...</td>\n",
|
108 |
+
" </tr>\n",
|
109 |
+
" <tr>\n",
|
110 |
+
" <th>3</th>\n",
|
111 |
+
" <td>https://www.biblio-globus.ru//product/10978116</td>\n",
|
112 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
113 |
+
" <td>Маринина А.</td>\n",
|
114 |
+
" <td>Иоанн Безземельный, Эдуард Третий и Ричард Вто...</td>\n",
|
115 |
+
" <td>Истории трех знаменитых королей под одной обло...</td>\n",
|
116 |
+
" </tr>\n",
|
117 |
+
" <tr>\n",
|
118 |
+
" <th>4</th>\n",
|
119 |
+
" <td>https://www.biblio-globus.ru//product/10845007</td>\n",
|
120 |
+
" <td>https://static1.bgshop.ru/extraimagehandler.as...</td>\n",
|
121 |
+
" <td>Маринина А.</td>\n",
|
122 |
+
" <td>Шпаргалка для ленивых любителей истории. Корол...</td>\n",
|
123 |
+
" <td>Первая книга в необычном для Александры Марини...</td>\n",
|
124 |
+
" </tr>\n",
|
125 |
+
" <tr>\n",
|
126 |
+
" <th>5</th>\n",
|
127 |
+
" <td>https://www.biblio-globus.ru//product/10928065</td>\n",
|
128 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
129 |
+
" <td>Елена Ивановна Михалкова</td>\n",
|
130 |
+
" <td>Мертвый кролик, живой кролик</td>\n",
|
131 |
+
" <td>Самый громкий провал Илюшина: преступление, ко...</td>\n",
|
132 |
+
" </tr>\n",
|
133 |
+
" </tbody>\n",
|
134 |
+
"</table>\n",
|
135 |
+
"</div>"
|
136 |
+
],
|
137 |
+
"text/plain": [
|
138 |
+
" page_url \\\n",
|
139 |
+
"0 https://www.biblio-globus.ru//product/10957168 \n",
|
140 |
+
"1 https://www.biblio-globus.ru//product/10997075 \n",
|
141 |
+
"2 https://www.biblio-globus.ru//product/10941892 \n",
|
142 |
+
"3 https://www.biblio-globus.ru//product/10978116 \n",
|
143 |
+
"4 https://www.biblio-globus.ru//product/10845007 \n",
|
144 |
+
"5 https://www.biblio-globus.ru//product/10928065 \n",
|
145 |
+
"\n",
|
146 |
+
" image_url \\\n",
|
147 |
+
"0 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
148 |
+
"1 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
149 |
+
"2 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
150 |
+
"3 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
151 |
+
"4 https://static1.bgshop.ru/extraimagehandler.as... \n",
|
152 |
+
"5 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
153 |
+
"\n",
|
154 |
+
" author \\\n",
|
155 |
+
"0 Маринина А. \n",
|
156 |
+
"1 Михалкова Е.И. \n",
|
157 |
+
"2 Маринина А. \n",
|
158 |
+
"3 Маринина А. \n",
|
159 |
+
"4 Маринина А. \n",
|
160 |
+
"5 Елена Ивановна Михалкова \n",
|
161 |
+
"\n",
|
162 |
+
" title \\\n",
|
163 |
+
"0 Ричард Третий и Генрих Восьмой глазами Шекспира \n",
|
164 |
+
"1 Знак истинного пути \n",
|
165 |
+
"2 Генрих Шестой глазами Шекспира \n",
|
166 |
+
"3 Иоанн Безземельный, Эдуард Третий и Ричард Вто... \n",
|
167 |
+
"4 Шпаргалка для ленивых любителей истории. Корол... \n",
|
168 |
+
"5 Мертвый кролик, живой кролик \n",
|
169 |
+
"\n",
|
170 |
+
" annotation \n",
|
171 |
+
"0 Расследование жизни и деяний двух самых опороч... \n",
|
172 |
+
"1 Сыщики Макар Илюшин и Сергей Бабкин расследуют... \n",
|
173 |
+
"2 Генрих Шестой – самая трагическая фигура на ан... \n",
|
174 |
+
"3 Истории трех знаменитых королей под одной обло... \n",
|
175 |
+
"4 Первая книга в необычном для Александры Марини... \n",
|
176 |
+
"5 Самый громкий провал Илюшина: преступление, ко... "
|
177 |
+
]
|
178 |
+
},
|
179 |
+
"execution_count": 6,
|
180 |
+
"metadata": {},
|
181 |
+
"output_type": "execute_result"
|
182 |
+
}
|
183 |
+
],
|
184 |
+
"source": [
|
185 |
+
"data_1 = pd.read_csv('csv_file.csv')\n",
|
186 |
+
"data_1.head(6)"
|
187 |
+
]
|
188 |
+
},
|
189 |
+
{
|
190 |
+
"cell_type": "code",
|
191 |
+
"execution_count": 11,
|
192 |
+
"id": "57e58eee-625e-47d3-9d48-25a05dca21a8",
|
193 |
+
"metadata": {},
|
194 |
+
"outputs": [
|
195 |
+
{
|
196 |
+
"name": "stdout",
|
197 |
+
"output_type": "stream",
|
198 |
+
"text": [
|
199 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
200 |
+
"RangeIndex: 2149 entries, 0 to 2148\n",
|
201 |
+
"Data columns (total 5 columns):\n",
|
202 |
+
" # Column Non-Null Count Dtype \n",
|
203 |
+
"--- ------ -------------- ----- \n",
|
204 |
+
" 0 page_url 2149 non-null object\n",
|
205 |
+
" 1 image_url 2149 non-null object\n",
|
206 |
+
" 2 author 2143 non-null object\n",
|
207 |
+
" 3 title 2149 non-null object\n",
|
208 |
+
" 4 annotation 2146 non-null object\n",
|
209 |
+
"dtypes: object(5)\n",
|
210 |
+
"memory usage: 84.1+ KB\n"
|
211 |
+
]
|
212 |
+
}
|
213 |
+
],
|
214 |
+
"source": [
|
215 |
+
"data_1.info()"
|
216 |
+
]
|
217 |
+
},
|
218 |
+
{
|
219 |
+
"cell_type": "code",
|
220 |
+
"execution_count": 24,
|
221 |
+
"id": "79ae4aac-9301-4e90-85a8-65b6a7b6cd33",
|
222 |
+
"metadata": {},
|
223 |
+
"outputs": [],
|
224 |
+
"source": [
|
225 |
+
"filtered_data_1 = data_1.dropna(subset=['author'])"
|
226 |
+
]
|
227 |
+
},
|
228 |
+
{
|
229 |
+
"cell_type": "code",
|
230 |
+
"execution_count": 26,
|
231 |
+
"id": "d305b67d-4763-46e1-8363-9e2c0f9fb823",
|
232 |
+
"metadata": {},
|
233 |
+
"outputs": [
|
234 |
+
{
|
235 |
+
"name": "stdout",
|
236 |
+
"output_type": "stream",
|
237 |
+
"text": [
|
238 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
239 |
+
"Index: 2140 entries, 0 to 2148\n",
|
240 |
+
"Data columns (total 5 columns):\n",
|
241 |
+
" # Column Non-Null Count Dtype \n",
|
242 |
+
"--- ------ -------------- ----- \n",
|
243 |
+
" 0 page_url 2140 non-null object\n",
|
244 |
+
" 1 image_url 2140 non-null object\n",
|
245 |
+
" 2 author 2140 non-null object\n",
|
246 |
+
" 3 title 2140 non-null object\n",
|
247 |
+
" 4 annotation 2140 non-null object\n",
|
248 |
+
"dtypes: object(5)\n",
|
249 |
+
"memory usage: 100.3+ KB\n"
|
250 |
+
]
|
251 |
+
}
|
252 |
+
],
|
253 |
+
"source": [
|
254 |
+
"filtered_data_1 = filtered_data_1.dropna(subset=['annotation'])\n",
|
255 |
+
"filtered_data_1.info()"
|
256 |
+
]
|
257 |
+
},
|
258 |
+
{
|
259 |
+
"cell_type": "markdown",
|
260 |
+
"id": "c6bb97f1-3efc-45a3-acfa-d3957e6a299c",
|
261 |
+
"metadata": {},
|
262 |
+
"source": [
|
263 |
+
"Датасет от Савра"
|
264 |
+
]
|
265 |
+
},
|
266 |
+
{
|
267 |
+
"cell_type": "code",
|
268 |
+
"execution_count": 8,
|
269 |
+
"id": "7464feea-b7e1-48f0-8206-4f5afdea242f",
|
270 |
+
"metadata": {},
|
271 |
+
"outputs": [],
|
272 |
+
"source": [
|
273 |
+
"data_2 = pd.read_csv('csv_file_Savr.csv', on_bad_lines='skip')"
|
274 |
+
]
|
275 |
+
},
|
276 |
+
{
|
277 |
+
"cell_type": "code",
|
278 |
+
"execution_count": 9,
|
279 |
+
"id": "5922c272-303f-4899-b4e3-26ac7133651d",
|
280 |
+
"metadata": {},
|
281 |
+
"outputs": [
|
282 |
+
{
|
283 |
+
"data": {
|
284 |
+
"text/html": [
|
285 |
+
"<div>\n",
|
286 |
+
"<style scoped>\n",
|
287 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
288 |
+
" vertical-align: middle;\n",
|
289 |
+
" }\n",
|
290 |
+
"\n",
|
291 |
+
" .dataframe tbody tr th {\n",
|
292 |
+
" vertical-align: top;\n",
|
293 |
+
" }\n",
|
294 |
+
"\n",
|
295 |
+
" .dataframe thead th {\n",
|
296 |
+
" text-align: right;\n",
|
297 |
+
" }\n",
|
298 |
+
"</style>\n",
|
299 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
300 |
+
" <thead>\n",
|
301 |
+
" <tr style=\"text-align: right;\">\n",
|
302 |
+
" <th></th>\n",
|
303 |
+
" <th>page_url</th>\n",
|
304 |
+
" <th>image_url</th>\n",
|
305 |
+
" <th>author</th>\n",
|
306 |
+
" <th>title</th>\n",
|
307 |
+
" <th>annotation</th>\n",
|
308 |
+
" </tr>\n",
|
309 |
+
" </thead>\n",
|
310 |
+
" <tbody>\n",
|
311 |
+
" <tr>\n",
|
312 |
+
" <th>0</th>\n",
|
313 |
+
" <td>https://www.biblio-globus.ru//product/10983286</td>\n",
|
314 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
315 |
+
" <td>Лю Цысинь</td>\n",
|
316 |
+
" <td>Темный лес (Воспоминания о прошлом Земли #2. Б...</td>\n",
|
317 |
+
" <td>Трисолярианский кризис продолжается. У землян ...</td>\n",
|
318 |
+
" </tr>\n",
|
319 |
+
" <tr>\n",
|
320 |
+
" <th>1</th>\n",
|
321 |
+
" <td>https://www.biblio-globus.ru//product/10864732</td>\n",
|
322 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
323 |
+
" <td>Чэнь Д.</td>\n",
|
324 |
+
" <td>Вайолет, созданная из шипов (#1)</td>\n",
|
325 |
+
" <td>Вайолет — предсказательница. Но никто не знае...</td>\n",
|
326 |
+
" </tr>\n",
|
327 |
+
" <tr>\n",
|
328 |
+
" <th>2</th>\n",
|
329 |
+
" <td>https://www.biblio-globus.ru//product/10988948</td>\n",
|
330 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
331 |
+
" <td>Лю Цысинь</td>\n",
|
332 |
+
" <td>Задача трех тел (Воспоминания о прошлом Земли ...</td>\n",
|
333 |
+
" <td>В те времена, когда Китай переживал последстви...</td>\n",
|
334 |
+
" </tr>\n",
|
335 |
+
" <tr>\n",
|
336 |
+
" <th>3</th>\n",
|
337 |
+
" <td>https://www.biblio-globus.ru//product/10922727</td>\n",
|
338 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
339 |
+
" <td>Парди К.</td>\n",
|
340 |
+
" <td>Рассвет костяной волшебницы (#2)</td>\n",
|
341 |
+
" <td>Священный долг каждой костяной волшебницы – пе...</td>\n",
|
342 |
+
" </tr>\n",
|
343 |
+
" <tr>\n",
|
344 |
+
" <th>4</th>\n",
|
345 |
+
" <td>https://www.biblio-globus.ru//product/10864123</td>\n",
|
346 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
347 |
+
" <td>Кунц Д.</td>\n",
|
348 |
+
" <td>Холодный огонь</td>\n",
|
349 |
+
" <td>Их свел случай, странное происшествие, которое...</td>\n",
|
350 |
+
" </tr>\n",
|
351 |
+
" </tbody>\n",
|
352 |
+
"</table>\n",
|
353 |
+
"</div>"
|
354 |
+
],
|
355 |
+
"text/plain": [
|
356 |
+
" page_url \\\n",
|
357 |
+
"0 https://www.biblio-globus.ru//product/10983286 \n",
|
358 |
+
"1 https://www.biblio-globus.ru//product/10864732 \n",
|
359 |
+
"2 https://www.biblio-globus.ru//product/10988948 \n",
|
360 |
+
"3 https://www.biblio-globus.ru//product/10922727 \n",
|
361 |
+
"4 https://www.biblio-globus.ru//product/10864123 \n",
|
362 |
+
"\n",
|
363 |
+
" image_url author \\\n",
|
364 |
+
"0 https://static1.bgshop.ru/imagehandler.ashx?fi... Лю Цысинь \n",
|
365 |
+
"1 https://static1.bgshop.ru/imagehandler.ashx?fi... Чэнь Д. \n",
|
366 |
+
"2 https://static1.bgshop.ru/imagehandler.ashx?fi... Лю Цысинь \n",
|
367 |
+
"3 https://static1.bgshop.ru/imagehandler.ashx?fi... Парди К. \n",
|
368 |
+
"4 https://static1.bgshop.ru/imagehandler.ashx?fi... Кунц Д. \n",
|
369 |
+
"\n",
|
370 |
+
" title \\\n",
|
371 |
+
"0 Темный лес (Воспоминания о прошлом Земли #2. Б... \n",
|
372 |
+
"1 Вайолет, созданная из шипов (#1) \n",
|
373 |
+
"2 Задача трех тел (Воспоминания о прошлом Земли ... \n",
|
374 |
+
"3 Рассвет костяной волшебницы (#2) \n",
|
375 |
+
"4 Холодный огонь \n",
|
376 |
+
"\n",
|
377 |
+
" annotation \n",
|
378 |
+
"0 Трисолярианский кризис продолжается. У землян ... \n",
|
379 |
+
"1 Вайолет — предсказательница. Но никто не знае... \n",
|
380 |
+
"2 В те времена, когда Китай переживал последстви... \n",
|
381 |
+
"3 Священный долг каждой костяной волшебницы – пе... \n",
|
382 |
+
"4 Их свел случай, странное происшествие, которое... "
|
383 |
+
]
|
384 |
+
},
|
385 |
+
"execution_count": 9,
|
386 |
+
"metadata": {},
|
387 |
+
"output_type": "execute_result"
|
388 |
+
}
|
389 |
+
],
|
390 |
+
"source": [
|
391 |
+
"data_2.head(5)"
|
392 |
+
]
|
393 |
+
},
|
394 |
+
{
|
395 |
+
"cell_type": "code",
|
396 |
+
"execution_count": 12,
|
397 |
+
"id": "5ff461c2-aef9-4e77-bf6e-d5b3f7229732",
|
398 |
+
"metadata": {},
|
399 |
+
"outputs": [
|
400 |
+
{
|
401 |
+
"name": "stdout",
|
402 |
+
"output_type": "stream",
|
403 |
+
"text": [
|
404 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
405 |
+
"RangeIndex: 3531 entries, 0 to 3530\n",
|
406 |
+
"Data columns (total 5 columns):\n",
|
407 |
+
" # Column Non-Null Count Dtype \n",
|
408 |
+
"--- ------ -------------- ----- \n",
|
409 |
+
" 0 page_url 3531 non-null object\n",
|
410 |
+
" 1 image_url 1970 non-null object\n",
|
411 |
+
" 2 author 1375 non-null object\n",
|
412 |
+
" 3 title 920 non-null object\n",
|
413 |
+
" 4 annotation 581 non-null object\n",
|
414 |
+
"dtypes: object(5)\n",
|
415 |
+
"memory usage: 138.1+ KB\n"
|
416 |
+
]
|
417 |
+
}
|
418 |
+
],
|
419 |
+
"source": [
|
420 |
+
"data_2.info()"
|
421 |
+
]
|
422 |
+
},
|
423 |
+
{
|
424 |
+
"cell_type": "code",
|
425 |
+
"execution_count": 27,
|
426 |
+
"id": "c5da28ad-122b-4ef0-900c-08230a0729a2",
|
427 |
+
"metadata": {},
|
428 |
+
"outputs": [
|
429 |
+
{
|
430 |
+
"name": "stdout",
|
431 |
+
"output_type": "stream",
|
432 |
+
"text": [
|
433 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
434 |
+
"Index: 581 entries, 0 to 3529\n",
|
435 |
+
"Data columns (total 5 columns):\n",
|
436 |
+
" # Column Non-Null Count Dtype \n",
|
437 |
+
"--- ------ -------------- ----- \n",
|
438 |
+
" 0 page_url 581 non-null object\n",
|
439 |
+
" 1 image_url 581 non-null object\n",
|
440 |
+
" 2 author 579 non-null object\n",
|
441 |
+
" 3 title 581 non-null object\n",
|
442 |
+
" 4 annotation 581 non-null object\n",
|
443 |
+
"dtypes: object(5)\n",
|
444 |
+
"memory usage: 27.2+ KB\n"
|
445 |
+
]
|
446 |
+
}
|
447 |
+
],
|
448 |
+
"source": [
|
449 |
+
"filtered_data_2 = data_2.dropna(subset=['annotation'])\n",
|
450 |
+
"filtered_data_2.info()"
|
451 |
+
]
|
452 |
+
},
|
453 |
+
{
|
454 |
+
"cell_type": "code",
|
455 |
+
"execution_count": 28,
|
456 |
+
"id": "4df00d79-f0b9-463b-b495-b2696ea6fac3",
|
457 |
+
"metadata": {},
|
458 |
+
"outputs": [
|
459 |
+
{
|
460 |
+
"name": "stdout",
|
461 |
+
"output_type": "stream",
|
462 |
+
"text": [
|
463 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
464 |
+
"Index: 579 entries, 0 to 3529\n",
|
465 |
+
"Data columns (total 5 columns):\n",
|
466 |
+
" # Column Non-Null Count Dtype \n",
|
467 |
+
"--- ------ -------------- ----- \n",
|
468 |
+
" 0 page_url 579 non-null object\n",
|
469 |
+
" 1 image_url 579 non-null object\n",
|
470 |
+
" 2 author 579 non-null object\n",
|
471 |
+
" 3 title 579 non-null object\n",
|
472 |
+
" 4 annotation 579 non-null object\n",
|
473 |
+
"dtypes: object(5)\n",
|
474 |
+
"memory usage: 27.1+ KB\n"
|
475 |
+
]
|
476 |
+
}
|
477 |
+
],
|
478 |
+
"source": [
|
479 |
+
"filtered_data_2 = filtered_data_2.dropna(subset=['author'])\n",
|
480 |
+
"filtered_data_2.info()"
|
481 |
+
]
|
482 |
+
},
|
483 |
+
{
|
484 |
+
"cell_type": "code",
|
485 |
+
"execution_count": 39,
|
486 |
+
"id": "2b549079-a2e1-4132-9b21-0d77d0ba2e7f",
|
487 |
+
"metadata": {},
|
488 |
+
"outputs": [],
|
489 |
+
"source": [
|
490 |
+
"data_1_2 = pd.concat([filtered_data_1, filtered_data_2], ignore_index=True) # объединенный с библиоглобуса"
|
491 |
+
]
|
492 |
+
},
|
493 |
+
{
|
494 |
+
"cell_type": "code",
|
495 |
+
"execution_count": 33,
|
496 |
+
"id": "b6f4c3ae-270a-4a0e-842a-899c08ef878f",
|
497 |
+
"metadata": {},
|
498 |
+
"outputs": [
|
499 |
+
{
|
500 |
+
"name": "stdout",
|
501 |
+
"output_type": "stream",
|
502 |
+
"text": [
|
503 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
504 |
+
"RangeIndex: 2719 entries, 0 to 2718\n",
|
505 |
+
"Data columns (total 5 columns):\n",
|
506 |
+
" # Column Non-Null Count Dtype \n",
|
507 |
+
"--- ------ -------------- ----- \n",
|
508 |
+
" 0 page_url 2719 non-null object\n",
|
509 |
+
" 1 image_url 2719 non-null object\n",
|
510 |
+
" 2 author 2719 non-null object\n",
|
511 |
+
" 3 title 2719 non-null object\n",
|
512 |
+
" 4 annotation 2719 non-null object\n",
|
513 |
+
"dtypes: object(5)\n",
|
514 |
+
"memory usage: 106.3+ KB\n"
|
515 |
+
]
|
516 |
+
}
|
517 |
+
],
|
518 |
+
"source": [
|
519 |
+
"data_1_2.info()"
|
520 |
+
]
|
521 |
+
},
|
522 |
+
{
|
523 |
+
"cell_type": "markdown",
|
524 |
+
"id": "2ab092ab-8b1f-4cbd-a43c-670c398fee74",
|
525 |
+
"metadata": {},
|
526 |
+
"source": [
|
527 |
+
"Датасет от Сауле (с loveread)"
|
528 |
+
]
|
529 |
+
},
|
530 |
+
{
|
531 |
+
"cell_type": "code",
|
532 |
+
"execution_count": 29,
|
533 |
+
"id": "98e27ab5-74b6-4811-8fec-d499ba024d9f",
|
534 |
+
"metadata": {},
|
535 |
+
"outputs": [],
|
536 |
+
"source": [
|
537 |
+
"data_3 = pd.read_csv('books_v7_500.csv')"
|
538 |
+
]
|
539 |
+
},
|
540 |
+
{
|
541 |
+
"cell_type": "code",
|
542 |
+
"execution_count": 31,
|
543 |
+
"id": "b2483fc7-99fa-4456-80d5-9da972f0ec2e",
|
544 |
+
"metadata": {},
|
545 |
+
"outputs": [
|
546 |
+
{
|
547 |
+
"data": {
|
548 |
+
"text/html": [
|
549 |
+
"<div>\n",
|
550 |
+
"<style scoped>\n",
|
551 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
552 |
+
" vertical-align: middle;\n",
|
553 |
+
" }\n",
|
554 |
+
"\n",
|
555 |
+
" .dataframe tbody tr th {\n",
|
556 |
+
" vertical-align: top;\n",
|
557 |
+
" }\n",
|
558 |
+
"\n",
|
559 |
+
" .dataframe thead th {\n",
|
560 |
+
" text-align: right;\n",
|
561 |
+
" }\n",
|
562 |
+
"</style>\n",
|
563 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
564 |
+
" <thead>\n",
|
565 |
+
" <tr style=\"text-align: right;\">\n",
|
566 |
+
" <th></th>\n",
|
567 |
+
" <th>page_url</th>\n",
|
568 |
+
" <th>image_url</th>\n",
|
569 |
+
" <th>author</th>\n",
|
570 |
+
" <th>title</th>\n",
|
571 |
+
" <th>annotation</th>\n",
|
572 |
+
" </tr>\n",
|
573 |
+
" </thead>\n",
|
574 |
+
" <tbody>\n",
|
575 |
+
" <tr>\n",
|
576 |
+
" <th>495</th>\n",
|
577 |
+
" <td>http://loveread.ec/view_global.php?id=10138</td>\n",
|
578 |
+
" <td>http://loveread.ec/img/photo_books/10138.jpg</td>\n",
|
579 |
+
" <td>Нил Шустерман</td>\n",
|
580 |
+
" <td>Книга Громила</td>\n",
|
581 |
+
" <td>Когда Бронте начинает встречаться с Брюстером ...</td>\n",
|
582 |
+
" </tr>\n",
|
583 |
+
" <tr>\n",
|
584 |
+
" <th>496</th>\n",
|
585 |
+
" <td>http://loveread.ec/view_global.php?id=10150</td>\n",
|
586 |
+
" <td>http://loveread.ec/img/photo_books/10150.jpg</td>\n",
|
587 |
+
" <td>Шеррилин Кеньон</td>\n",
|
588 |
+
" <td>Книга Дьявол может плакать [= Син и Катра ]</td>\n",
|
589 |
+
" <td>Месть. Некоторые говорят, что это яд, просачив...</td>\n",
|
590 |
+
" </tr>\n",
|
591 |
+
" <tr>\n",
|
592 |
+
" <th>497</th>\n",
|
593 |
+
" <td>http://loveread.ec/view_global.php?id=10162</td>\n",
|
594 |
+
" <td>http://loveread.ec/img/photo_books/10162.jpg</td>\n",
|
595 |
+
" <td>Бекка Фицпатрик</td>\n",
|
596 |
+
" <td>Книга Тишина</td>\n",
|
597 |
+
" <td>Ссоры между Патчем и Норой закончились. Они ра...</td>\n",
|
598 |
+
" </tr>\n",
|
599 |
+
" <tr>\n",
|
600 |
+
" <th>498</th>\n",
|
601 |
+
" <td>http://loveread.ec/view_global.php?id=10166</td>\n",
|
602 |
+
" <td>http://loveread.ec/img/photo_books/10166.jpg</td>\n",
|
603 |
+
" <td>Элизабет Гоудж</td>\n",
|
604 |
+
" <td>Книга Маленькая белая лошадка в серебряном све...</td>\n",
|
605 |
+
" <td>…Лунная Долина полнится воспоминаниями о Лунно...</td>\n",
|
606 |
+
" </tr>\n",
|
607 |
+
" <tr>\n",
|
608 |
+
" <th>499</th>\n",
|
609 |
+
" <td>http://loveread.ec/view_global.php?id=10206</td>\n",
|
610 |
+
" <td>http://loveread.ec/img/photo_books/10206.jpg</td>\n",
|
611 |
+
" <td>Кэтрин Коултер</td>\n",
|
612 |
+
" <td>Книга Дикая звезда</td>\n",
|
613 |
+
" <td>С той секунды, как очаровательная Байрони впер...</td>\n",
|
614 |
+
" </tr>\n",
|
615 |
+
" </tbody>\n",
|
616 |
+
"</table>\n",
|
617 |
+
"</div>"
|
618 |
+
],
|
619 |
+
"text/plain": [
|
620 |
+
" page_url \\\n",
|
621 |
+
"495 http://loveread.ec/view_global.php?id=10138 \n",
|
622 |
+
"496 http://loveread.ec/view_global.php?id=10150 \n",
|
623 |
+
"497 http://loveread.ec/view_global.php?id=10162 \n",
|
624 |
+
"498 http://loveread.ec/view_global.php?id=10166 \n",
|
625 |
+
"499 http://loveread.ec/view_global.php?id=10206 \n",
|
626 |
+
"\n",
|
627 |
+
" image_url author \\\n",
|
628 |
+
"495 http://loveread.ec/img/photo_books/10138.jpg Нил Шустерман \n",
|
629 |
+
"496 http://loveread.ec/img/photo_books/10150.jpg Шеррилин Кеньон \n",
|
630 |
+
"497 http://loveread.ec/img/photo_books/10162.jpg Бекка Фицпатрик \n",
|
631 |
+
"498 http://loveread.ec/img/photo_books/10166.jpg Элизабет Гоудж \n",
|
632 |
+
"499 http://loveread.ec/img/photo_books/10206.jpg Кэтрин Коултер \n",
|
633 |
+
"\n",
|
634 |
+
" title \\\n",
|
635 |
+
"495 Книга Громила \n",
|
636 |
+
"496 Книга Дьявол может плакать [= Син и Катра ] \n",
|
637 |
+
"497 Книга Тишина \n",
|
638 |
+
"498 Книга Маленькая белая лошадка в серебряном све... \n",
|
639 |
+
"499 Книга Дикая звезда \n",
|
640 |
+
"\n",
|
641 |
+
" annotation \n",
|
642 |
+
"495 Когда Бронте начинает встречаться с Брюстером ... \n",
|
643 |
+
"496 Месть. Некоторые говорят, что это яд, просачив... \n",
|
644 |
+
"497 Ссоры между Патчем и Норой закончились. Они ра... \n",
|
645 |
+
"498 …Лунная Долина полнится воспоминаниями о Лунно... \n",
|
646 |
+
"499 С той секунды, как очаровательная Байрони впер... "
|
647 |
+
]
|
648 |
+
},
|
649 |
+
"execution_count": 31,
|
650 |
+
"metadata": {},
|
651 |
+
"output_type": "execute_result"
|
652 |
+
}
|
653 |
+
],
|
654 |
+
"source": [
|
655 |
+
"data_3.tail(5)"
|
656 |
+
]
|
657 |
+
},
|
658 |
+
{
|
659 |
+
"cell_type": "code",
|
660 |
+
"execution_count": 34,
|
661 |
+
"id": "0f1ea0d3-9845-4550-9d5d-7d4159e4325f",
|
662 |
+
"metadata": {},
|
663 |
+
"outputs": [
|
664 |
+
{
|
665 |
+
"data": {
|
666 |
+
"text/html": [
|
667 |
+
"<div>\n",
|
668 |
+
"<style scoped>\n",
|
669 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
670 |
+
" vertical-align: middle;\n",
|
671 |
+
" }\n",
|
672 |
+
"\n",
|
673 |
+
" .dataframe tbody tr th {\n",
|
674 |
+
" vertical-align: top;\n",
|
675 |
+
" }\n",
|
676 |
+
"\n",
|
677 |
+
" .dataframe thead th {\n",
|
678 |
+
" text-align: right;\n",
|
679 |
+
" }\n",
|
680 |
+
"</style>\n",
|
681 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
682 |
+
" <thead>\n",
|
683 |
+
" <tr style=\"text-align: right;\">\n",
|
684 |
+
" <th></th>\n",
|
685 |
+
" <th>page_url</th>\n",
|
686 |
+
" <th>image_url</th>\n",
|
687 |
+
" <th>author</th>\n",
|
688 |
+
" <th>title</th>\n",
|
689 |
+
" <th>annotation</th>\n",
|
690 |
+
" </tr>\n",
|
691 |
+
" </thead>\n",
|
692 |
+
" <tbody>\n",
|
693 |
+
" <tr>\n",
|
694 |
+
" <th>0</th>\n",
|
695 |
+
" <td>http://loveread.ec/view_global.php?id=41</td>\n",
|
696 |
+
" <td>http://loveread.ec/img/photo_books/41.jpg</td>\n",
|
697 |
+
" <td>Владимир Набоков</td>\n",
|
698 |
+
" <td>Приглашение на казнь</td>\n",
|
699 |
+
" <td>Это - собрание самых, наверное, странных произ...</td>\n",
|
700 |
+
" </tr>\n",
|
701 |
+
" <tr>\n",
|
702 |
+
" <th>1</th>\n",
|
703 |
+
" <td>http://loveread.ec/view_global.php?id=1166</td>\n",
|
704 |
+
" <td>http://loveread.ec/img/photo_books/1166.jpg</td>\n",
|
705 |
+
" <td>Агата Кристи</td>\n",
|
706 |
+
" <td>Третья девушка</td>\n",
|
707 |
+
" <td>Молодая девушка по имени Норма Рестарик обраща...</td>\n",
|
708 |
+
" </tr>\n",
|
709 |
+
" <tr>\n",
|
710 |
+
" <th>2</th>\n",
|
711 |
+
" <td>http://loveread.ec/view_global.php?id=1187</td>\n",
|
712 |
+
" <td>http://loveread.ec/img/photo_books/1187.jpg</td>\n",
|
713 |
+
" <td>Роджер Желязны</td>\n",
|
714 |
+
" <td>Принеси мне голову Прекрасного принца</td>\n",
|
715 |
+
" <td>Несоврешеннолетний демон Аззи вообразил себя н...</td>\n",
|
716 |
+
" </tr>\n",
|
717 |
+
" <tr>\n",
|
718 |
+
" <th>3</th>\n",
|
719 |
+
" <td>http://loveread.ec/view_global.php?id=1289</td>\n",
|
720 |
+
" <td>http://loveread.ec/img/photo_books/1289.jpg</td>\n",
|
721 |
+
" <td>Гарри Гаррисон</td>\n",
|
722 |
+
" <td>Стальную крысу - в президенты !</td>\n",
|
723 |
+
" <td>Великолепный Джим ди Гриз - знаменитый межзвез...</td>\n",
|
724 |
+
" </tr>\n",
|
725 |
+
" <tr>\n",
|
726 |
+
" <th>4</th>\n",
|
727 |
+
" <td>http://loveread.ec/view_global.php?id=1352</td>\n",
|
728 |
+
" <td>http://loveread.ec/img/photo_books/1352.jpg</td>\n",
|
729 |
+
" <td>Юз Алешковский</td>\n",
|
730 |
+
" <td>Рука</td>\n",
|
731 |
+
" <td>Роман Юза Алешковского «Рука» (1977, опубл. 19...</td>\n",
|
732 |
+
" </tr>\n",
|
733 |
+
" </tbody>\n",
|
734 |
+
"</table>\n",
|
735 |
+
"</div>"
|
736 |
+
],
|
737 |
+
"text/plain": [
|
738 |
+
" page_url \\\n",
|
739 |
+
"0 http://loveread.ec/view_global.php?id=41 \n",
|
740 |
+
"1 http://loveread.ec/view_global.php?id=1166 \n",
|
741 |
+
"2 http://loveread.ec/view_global.php?id=1187 \n",
|
742 |
+
"3 http://loveread.ec/view_global.php?id=1289 \n",
|
743 |
+
"4 http://loveread.ec/view_global.php?id=1352 \n",
|
744 |
+
"\n",
|
745 |
+
" image_url author \\\n",
|
746 |
+
"0 http://loveread.ec/img/photo_books/41.jpg Владимир Набоков \n",
|
747 |
+
"1 http://loveread.ec/img/photo_books/1166.jpg Агата Кристи \n",
|
748 |
+
"2 http://loveread.ec/img/photo_books/1187.jpg Роджер Желязны \n",
|
749 |
+
"3 http://loveread.ec/img/photo_books/1289.jpg Гарри Гаррисон \n",
|
750 |
+
"4 http://loveread.ec/img/photo_books/1352.jpg Юз Алешковский \n",
|
751 |
+
"\n",
|
752 |
+
" title \\\n",
|
753 |
+
"0 Приглашение на казнь \n",
|
754 |
+
"1 Третья девушка \n",
|
755 |
+
"2 Принеси мне голову Прекрасного принца \n",
|
756 |
+
"3 Стальную крысу - в президенты ! \n",
|
757 |
+
"4 Рука \n",
|
758 |
+
"\n",
|
759 |
+
" annotation \n",
|
760 |
+
"0 Это - собрание самых, наверное, странных произ... \n",
|
761 |
+
"1 Молодая девушка по имени Норма Рестарик обраща... \n",
|
762 |
+
"2 Несоврешеннолетний демон Аззи вообразил себя н... \n",
|
763 |
+
"3 Великолепный Джим ди Гриз - знаменитый межзвез... \n",
|
764 |
+
"4 Роман Юза Алешковского «Рука» (1977, опубл. 19... "
|
765 |
+
]
|
766 |
+
},
|
767 |
+
"execution_count": 34,
|
768 |
+
"metadata": {},
|
769 |
+
"output_type": "execute_result"
|
770 |
+
}
|
771 |
+
],
|
772 |
+
"source": [
|
773 |
+
"data_3['title'] = data_3['title'].str.replace(r'^Книга\\s+', '', regex=True)\n",
|
774 |
+
"data_3.head(5)"
|
775 |
+
]
|
776 |
+
},
|
777 |
+
{
|
778 |
+
"cell_type": "code",
|
779 |
+
"execution_count": 35,
|
780 |
+
"id": "17ce45b0-3a29-45ef-8625-33d2f59570ba",
|
781 |
+
"metadata": {},
|
782 |
+
"outputs": [],
|
783 |
+
"source": [
|
784 |
+
"data_main = pd.concat([data_1_2, data_3], ignore_index=True)"
|
785 |
+
]
|
786 |
+
},
|
787 |
+
{
|
788 |
+
"cell_type": "code",
|
789 |
+
"execution_count": 36,
|
790 |
+
"id": "08f59813-2436-4c2d-b9c9-1ea3222ffd43",
|
791 |
+
"metadata": {},
|
792 |
+
"outputs": [
|
793 |
+
{
|
794 |
+
"name": "stdout",
|
795 |
+
"output_type": "stream",
|
796 |
+
"text": [
|
797 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
798 |
+
"RangeIndex: 3219 entries, 0 to 3218\n",
|
799 |
+
"Data columns (total 5 columns):\n",
|
800 |
+
" # Column Non-Null Count Dtype \n",
|
801 |
+
"--- ------ -------------- ----- \n",
|
802 |
+
" 0 page_url 3219 non-null object\n",
|
803 |
+
" 1 image_url 3219 non-null object\n",
|
804 |
+
" 2 author 3219 non-null object\n",
|
805 |
+
" 3 title 3219 non-null object\n",
|
806 |
+
" 4 annotation 3219 non-null object\n",
|
807 |
+
"dtypes: object(5)\n",
|
808 |
+
"memory usage: 125.9+ KB\n"
|
809 |
+
]
|
810 |
+
}
|
811 |
+
],
|
812 |
+
"source": [
|
813 |
+
"data_main.info()"
|
814 |
+
]
|
815 |
+
},
|
816 |
+
{
|
817 |
+
"cell_type": "code",
|
818 |
+
"execution_count": 40,
|
819 |
+
"id": "748b7773-0cb1-430e-aa89-46836488c35e",
|
820 |
+
"metadata": {},
|
821 |
+
"outputs": [
|
822 |
+
{
|
823 |
+
"name": "stdout",
|
824 |
+
"output_type": "stream",
|
825 |
+
"text": [
|
826 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
827 |
+
"RangeIndex: 726 entries, 0 to 725\n",
|
828 |
+
"Data columns (total 5 columns):\n",
|
829 |
+
" # Column Non-Null Count Dtype \n",
|
830 |
+
"--- ------ -------------- ----- \n",
|
831 |
+
" 0 page_url 726 non-null object\n",
|
832 |
+
" 1 image_url 726 non-null object\n",
|
833 |
+
" 2 author 726 non-null object\n",
|
834 |
+
" 3 title 726 non-null object\n",
|
835 |
+
" 4 annotation 726 non-null object\n",
|
836 |
+
"dtypes: object(5)\n",
|
837 |
+
"memory usage: 28.5+ KB\n"
|
838 |
+
]
|
839 |
+
}
|
840 |
+
],
|
841 |
+
"source": [
|
842 |
+
"data_4 = pd.read_csv('books_1000.csv')\n",
|
843 |
+
"data_4.info()"
|
844 |
+
]
|
845 |
+
},
|
846 |
+
{
|
847 |
+
"cell_type": "code",
|
848 |
+
"execution_count": 41,
|
849 |
+
"id": "a3078611-6002-42b5-b168-329e8c35fc91",
|
850 |
+
"metadata": {},
|
851 |
+
"outputs": [],
|
852 |
+
"source": [
|
853 |
+
"data_main = pd.concat([data_main, data_4], ignore_index=True)"
|
854 |
+
]
|
855 |
+
},
|
856 |
+
{
|
857 |
+
"cell_type": "code",
|
858 |
+
"execution_count": 43,
|
859 |
+
"id": "0ce908be-2d12-480d-916c-449c4965f20c",
|
860 |
+
"metadata": {},
|
861 |
+
"outputs": [
|
862 |
+
{
|
863 |
+
"name": "stdout",
|
864 |
+
"output_type": "stream",
|
865 |
+
"text": [
|
866 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
867 |
+
"RangeIndex: 3945 entries, 0 to 3944\n",
|
868 |
+
"Data columns (total 5 columns):\n",
|
869 |
+
" # Column Non-Null Count Dtype \n",
|
870 |
+
"--- ------ -------------- ----- \n",
|
871 |
+
" 0 page_url 3945 non-null object\n",
|
872 |
+
" 1 image_url 3945 non-null object\n",
|
873 |
+
" 2 author 3945 non-null object\n",
|
874 |
+
" 3 title 3945 non-null object\n",
|
875 |
+
" 4 annotation 3945 non-null object\n",
|
876 |
+
"dtypes: object(5)\n",
|
877 |
+
"memory usage: 154.2+ KB\n"
|
878 |
+
]
|
879 |
+
}
|
880 |
+
],
|
881 |
+
"source": [
|
882 |
+
"data_main.info()"
|
883 |
+
]
|
884 |
+
},
|
885 |
+
{
|
886 |
+
"cell_type": "code",
|
887 |
+
"execution_count": 42,
|
888 |
+
"id": "2f94edbf-16d9-4ed4-bd3b-35d54a9cd594",
|
889 |
+
"metadata": {},
|
890 |
+
"outputs": [
|
891 |
+
{
|
892 |
+
"data": {
|
893 |
+
"text/html": [
|
894 |
+
"<div>\n",
|
895 |
+
"<style scoped>\n",
|
896 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
897 |
+
" vertical-align: middle;\n",
|
898 |
+
" }\n",
|
899 |
+
"\n",
|
900 |
+
" .dataframe tbody tr th {\n",
|
901 |
+
" vertical-align: top;\n",
|
902 |
+
" }\n",
|
903 |
+
"\n",
|
904 |
+
" .dataframe thead th {\n",
|
905 |
+
" text-align: right;\n",
|
906 |
+
" }\n",
|
907 |
+
"</style>\n",
|
908 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
909 |
+
" <thead>\n",
|
910 |
+
" <tr style=\"text-align: right;\">\n",
|
911 |
+
" <th></th>\n",
|
912 |
+
" <th>page_url</th>\n",
|
913 |
+
" <th>image_url</th>\n",
|
914 |
+
" <th>author</th>\n",
|
915 |
+
" <th>title</th>\n",
|
916 |
+
" <th>annotation</th>\n",
|
917 |
+
" </tr>\n",
|
918 |
+
" </thead>\n",
|
919 |
+
" <tbody>\n",
|
920 |
+
" <tr>\n",
|
921 |
+
" <th>7</th>\n",
|
922 |
+
" <td>https://www.biblio-globus.ru//product/10974400</td>\n",
|
923 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
924 |
+
" <td>Свечин Н.</td>\n",
|
925 |
+
" <td>Ледяной ветер Суоми</td>\n",
|
926 |
+
" <td>Немудрено, что кассир крупного банка, уроженец...</td>\n",
|
927 |
+
" </tr>\n",
|
928 |
+
" <tr>\n",
|
929 |
+
" <th>15</th>\n",
|
930 |
+
" <td>https://www.biblio-globus.ru//product/10974399</td>\n",
|
931 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
932 |
+
" <td>Свечин Н.</td>\n",
|
933 |
+
" <td>Ледяной ветер Суоми</td>\n",
|
934 |
+
" <td>Немудрено, что кассир крупного банка, уроженец...</td>\n",
|
935 |
+
" </tr>\n",
|
936 |
+
" <tr>\n",
|
937 |
+
" <th>31</th>\n",
|
938 |
+
" <td>https://www.biblio-globus.ru//product/10893792</td>\n",
|
939 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
940 |
+
" <td>Елена Ивановна Михалкова</td>\n",
|
941 |
+
" <td>Перо бумажной птицы</td>\n",
|
942 |
+
" <td>Пропала девушка. Ее любящая семья нанимает час...</td>\n",
|
943 |
+
" </tr>\n",
|
944 |
+
" <tr>\n",
|
945 |
+
" <th>33</th>\n",
|
946 |
+
" <td>https://www.biblio-globus.ru//product/10871804</td>\n",
|
947 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
948 |
+
" <td>Бочарова Т.А.</td>\n",
|
949 |
+
" <td>Восстание Феникса</td>\n",
|
950 |
+
" <td>Всю жизнь Регина Сергеевна проработала учитель...</td>\n",
|
951 |
+
" </tr>\n",
|
952 |
+
" <tr>\n",
|
953 |
+
" <th>46</th>\n",
|
954 |
+
" <td>https://www.biblio-globus.ru//product/10989481</td>\n",
|
955 |
+
" <td>https://static1.bgshop.ru/imagehandler.ashx?fi...</td>\n",
|
956 |
+
" <td>Корецкий Д.А.</td>\n",
|
957 |
+
" <td>Возвращение не гарантируется</td>\n",
|
958 |
+
" <td>Они познакомились на пустынном ночном шоссе, г...</td>\n",
|
959 |
+
" </tr>\n",
|
960 |
+
" <tr>\n",
|
961 |
+
" <th>...</th>\n",
|
962 |
+
" <td>...</td>\n",
|
963 |
+
" <td>...</td>\n",
|
964 |
+
" <td>...</td>\n",
|
965 |
+
" <td>...</td>\n",
|
966 |
+
" <td>...</td>\n",
|
967 |
+
" </tr>\n",
|
968 |
+
" <tr>\n",
|
969 |
+
" <th>3423</th>\n",
|
970 |
+
" <td>http://loveread.ec/view_global.php?id=12245</td>\n",
|
971 |
+
" <td>http://loveread.ec/img/photo_books/12245.jpg</td>\n",
|
972 |
+
" <td>Лилия Белая</td>\n",
|
973 |
+
" <td>Книга Мечта</td>\n",
|
974 |
+
" <td>Что ты будешь делать, когда, попадав в другой ...</td>\n",
|
975 |
+
" </tr>\n",
|
976 |
+
" <tr>\n",
|
977 |
+
" <th>3655</th>\n",
|
978 |
+
" <td>http://loveread.ec/view_global.php?id=14473</td>\n",
|
979 |
+
" <td>http://loveread.ec/img/photo_books/14473.jpg</td>\n",
|
980 |
+
" <td>Эмиль Золя</td>\n",
|
981 |
+
" <td>Книга Мечта</td>\n",
|
982 |
+
" <td>Стояла суровая зима 1860 года, Уаза замерзла, ...</td>\n",
|
983 |
+
" </tr>\n",
|
984 |
+
" <tr>\n",
|
985 |
+
" <th>3800</th>\n",
|
986 |
+
" <td>http://loveread.ec/view_global.php?id=15496</td>\n",
|
987 |
+
" <td>http://loveread.ec/img/photo_books/15496.jpg</td>\n",
|
988 |
+
" <td>Франц Кафка</td>\n",
|
989 |
+
" <td>Книга Превращение</td>\n",
|
990 |
+
" <td>В настоящий том вошли роман Кафки «Замок», при...</td>\n",
|
991 |
+
" </tr>\n",
|
992 |
+
" <tr>\n",
|
993 |
+
" <th>3849</th>\n",
|
994 |
+
" <td>http://loveread.ec/view_global.php?id=16065</td>\n",
|
995 |
+
" <td>http://loveread.ec/img/photo_books/16065.jpg</td>\n",
|
996 |
+
" <td>Келли Армстронг</td>\n",
|
997 |
+
" <td>Книга Пробуждение</td>\n",
|
998 |
+
" <td>Если бы мы встретились несколько недель назад,...</td>\n",
|
999 |
+
" </tr>\n",
|
1000 |
+
" <tr>\n",
|
1001 |
+
" <th>3933</th>\n",
|
1002 |
+
" <td>http://loveread.ec/view_global.php?id=16381</td>\n",
|
1003 |
+
" <td>http://loveread.ec/img/photo_books/16381.jpg</td>\n",
|
1004 |
+
" <td>Дэй Леклер</td>\n",
|
1005 |
+
" <td>Книга Родственные души</td>\n",
|
1006 |
+
" <td>Джей Ранделл начала работать в фирме, которая ...</td>\n",
|
1007 |
+
" </tr>\n",
|
1008 |
+
" </tbody>\n",
|
1009 |
+
"</table>\n",
|
1010 |
+
"<p>485 rows × 5 columns</p>\n",
|
1011 |
+
"</div>"
|
1012 |
+
],
|
1013 |
+
"text/plain": [
|
1014 |
+
" page_url \\\n",
|
1015 |
+
"7 https://www.biblio-globus.ru//product/10974400 \n",
|
1016 |
+
"15 https://www.biblio-globus.ru//product/10974399 \n",
|
1017 |
+
"31 https://www.biblio-globus.ru//product/10893792 \n",
|
1018 |
+
"33 https://www.biblio-globus.ru//product/10871804 \n",
|
1019 |
+
"46 https://www.biblio-globus.ru//product/10989481 \n",
|
1020 |
+
"... ... \n",
|
1021 |
+
"3423 http://loveread.ec/view_global.php?id=12245 \n",
|
1022 |
+
"3655 http://loveread.ec/view_global.php?id=14473 \n",
|
1023 |
+
"3800 http://loveread.ec/view_global.php?id=15496 \n",
|
1024 |
+
"3849 http://loveread.ec/view_global.php?id=16065 \n",
|
1025 |
+
"3933 http://loveread.ec/view_global.php?id=16381 \n",
|
1026 |
+
"\n",
|
1027 |
+
" image_url \\\n",
|
1028 |
+
"7 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
1029 |
+
"15 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
1030 |
+
"31 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
1031 |
+
"33 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
1032 |
+
"46 https://static1.bgshop.ru/imagehandler.ashx?fi... \n",
|
1033 |
+
"... ... \n",
|
1034 |
+
"3423 http://loveread.ec/img/photo_books/12245.jpg \n",
|
1035 |
+
"3655 http://loveread.ec/img/photo_books/14473.jpg \n",
|
1036 |
+
"3800 http://loveread.ec/img/photo_books/15496.jpg \n",
|
1037 |
+
"3849 http://loveread.ec/img/photo_books/16065.jpg \n",
|
1038 |
+
"3933 http://loveread.ec/img/photo_books/16381.jpg \n",
|
1039 |
+
"\n",
|
1040 |
+
" author title \\\n",
|
1041 |
+
"7 Свечин Н. Ледяной ветер Суоми \n",
|
1042 |
+
"15 Свечин Н. Ледяной ветер Суоми \n",
|
1043 |
+
"31 Елена Ивановна Михалкова Перо бумажной птицы \n",
|
1044 |
+
"33 Бочарова Т.А. Восстание Феникса \n",
|
1045 |
+
"46 Корецкий Д.А. Возвращение не гарантируется \n",
|
1046 |
+
"... ... ... \n",
|
1047 |
+
"3423 Лилия Белая Книга Мечта \n",
|
1048 |
+
"3655 Эмиль Золя Книга Мечта \n",
|
1049 |
+
"3800 Франц Кафка Книга Превращение \n",
|
1050 |
+
"3849 Келли Армстронг Книга Пробуждение \n",
|
1051 |
+
"3933 Дэй Леклер Книга Родственные души \n",
|
1052 |
+
"\n",
|
1053 |
+
" annotation \n",
|
1054 |
+
"7 Немудрено, что кассир крупного банка, уроженец... \n",
|
1055 |
+
"15 Немудрено, что кассир крупного банка, уроженец... \n",
|
1056 |
+
"31 Пропала девушка. Ее любящая семья нанимает час... \n",
|
1057 |
+
"33 Всю жизнь Регина Сергеевна проработала учитель... \n",
|
1058 |
+
"46 Они познакомились на пустынном ночном шоссе, г... \n",
|
1059 |
+
"... ... \n",
|
1060 |
+
"3423 Что ты будешь делать, когда, попадав в другой ... \n",
|
1061 |
+
"3655 Стояла суровая зима 1860 года, Уаза замерзла, ... \n",
|
1062 |
+
"3800 В настоящий том вошли роман Кафки «Замок», при... \n",
|
1063 |
+
"3849 Если бы мы встретились несколько недель назад,... \n",
|
1064 |
+
"3933 Джей Ранделл начала работать в фирме, которая ... \n",
|
1065 |
+
"\n",
|
1066 |
+
"[485 rows x 5 columns]"
|
1067 |
+
]
|
1068 |
+
},
|
1069 |
+
"execution_count": 42,
|
1070 |
+
"metadata": {},
|
1071 |
+
"output_type": "execute_result"
|
1072 |
+
}
|
1073 |
+
],
|
1074 |
+
"source": [
|
1075 |
+
"duplicates = data_main[data_main['title'].duplicated(keep=False)]\n",
|
1076 |
+
"duplicates"
|
1077 |
+
]
|
1078 |
+
},
|
1079 |
+
{
|
1080 |
+
"cell_type": "code",
|
1081 |
+
"execution_count": 44,
|
1082 |
+
"id": "06b29a83-5375-4513-9eee-a164534dc2a7",
|
1083 |
+
"metadata": {},
|
1084 |
+
"outputs": [],
|
1085 |
+
"source": [
|
1086 |
+
"data_main_no_duplicates = data_main.drop_duplicates(subset='title', keep='first')"
|
1087 |
+
]
|
1088 |
+
},
|
1089 |
+
{
|
1090 |
+
"cell_type": "code",
|
1091 |
+
"execution_count": 45,
|
1092 |
+
"id": "6d63e0b8-e22a-4264-909f-d928edad28d1",
|
1093 |
+
"metadata": {},
|
1094 |
+
"outputs": [
|
1095 |
+
{
|
1096 |
+
"name": "stdout",
|
1097 |
+
"output_type": "stream",
|
1098 |
+
"text": [
|
1099 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
1100 |
+
"Index: 3691 entries, 0 to 3944\n",
|
1101 |
+
"Data columns (total 5 columns):\n",
|
1102 |
+
" # Column Non-Null Count Dtype \n",
|
1103 |
+
"--- ------ -------------- ----- \n",
|
1104 |
+
" 0 page_url 3691 non-null object\n",
|
1105 |
+
" 1 image_url 3691 non-null object\n",
|
1106 |
+
" 2 author 3691 non-null object\n",
|
1107 |
+
" 3 title 3691 non-null object\n",
|
1108 |
+
" 4 annotation 3691 non-null object\n",
|
1109 |
+
"dtypes: object(5)\n",
|
1110 |
+
"memory usage: 173.0+ KB\n"
|
1111 |
+
]
|
1112 |
+
}
|
1113 |
+
],
|
1114 |
+
"source": [
|
1115 |
+
"data_main_no_duplicates.info()"
|
1116 |
+
]
|
1117 |
+
},
|
1118 |
+
{
|
1119 |
+
"cell_type": "markdown",
|
1120 |
+
"id": "65c7f96b-6633-4e41-9802-1919e1b554c9",
|
1121 |
+
"metadata": {},
|
1122 |
+
"source": [
|
1123 |
+
"Preproccesing"
|
1124 |
+
]
|
1125 |
+
},
|
1126 |
+
{
|
1127 |
+
"cell_type": "code",
|
1128 |
+
"execution_count": 51,
|
1129 |
+
"id": "e409f07e-3d21-4318-a24a-40dcff1a77e4",
|
1130 |
+
"metadata": {},
|
1131 |
+
"outputs": [],
|
1132 |
+
"source": [
|
1133 |
+
"url = \"https://raw.githubusercontent.com/stopwords-iso/stopwords-ru/master/stopwords-ru.txt\"\n",
|
1134 |
+
"stop_words_russian = requests.get(url).text.splitlines()"
|
1135 |
+
]
|
1136 |
+
},
|
1137 |
+
{
|
1138 |
+
"cell_type": "code",
|
1139 |
+
"execution_count": 52,
|
1140 |
+
"id": "89a1ff27-3f90-40cd-9eb6-97c13eb00ca1",
|
1141 |
+
"metadata": {},
|
1142 |
+
"outputs": [],
|
1143 |
+
"source": [
|
1144 |
+
"def clean(text):\n",
|
1145 |
+
" text = re.sub(r'([А-Я])', r' \\1', text) # делаем пробел между верхним и нижним регистром(123/473)\n",
|
1146 |
+
" text = text.lower() # нижний регистр (194)\n",
|
1147 |
+
" text = re.sub(r'[\\w\\.-]+\\.ru', \" \", text) # удаляем сайты (4)\n",
|
1148 |
+
" text = re.sub(r'http\\S+', \" \", text) # удаляем ссылки (10/1076)\n",
|
1149 |
+
" text = re.sub(r'@\\w+',' ',text) # удаляем упоминания пользователей (1937/1923)\n",
|
1150 |
+
" text = re.sub(r'#\\w+', ' ', text) # удаляем хэштеги (10/77/1923)\n",
|
1151 |
+
" text = re.sub(r'\\d+', ' ', text) # удаляем числа()\n",
|
1152 |
+
" text = text.translate(str.maketrans('', '', string.punctuation))\n",
|
1153 |
+
" # Удаление английских слов\n",
|
1154 |
+
" text = ' '.join(re.findall(r'\\b[а-яА-ЯёЁ]+\\b', text))\n",
|
1155 |
+
" # Удаление стоп-слов\n",
|
1156 |
+
" tokens = word_tokenize(text)\n",
|
1157 |
+
" text = ' '.join([word for word in tokens if word.lower() not in stop_words_russian])\n",
|
1158 |
+
" # text = re.sub(r'<.*?>',' ', text) #\n",
|
1159 |
+
" text = re.sub(r'['u'\\U0001F600-\\U0001F64F'\n",
|
1160 |
+
" u'\\U0001F300-\\U0001F5FF'\n",
|
1161 |
+
" u'\\U0001F680-\\U0001F6FF'\n",
|
1162 |
+
" u'\\U0001F1E0-\\U0001F1FF'\n",
|
1163 |
+
" u'\\U00002500-\\U00002BEF'\n",
|
1164 |
+
" u'\\U00002702-\\U000027B0'\n",
|
1165 |
+
" u'\\U000024C2-\\U0001F251'\n",
|
1166 |
+
" u'\\U0001f926-\\U0001f937'\n",
|
1167 |
+
" u'\\U00010000-\\U0010ffff'\n",
|
1168 |
+
" ']+', '', text, flags=re.UNICODE) # удаляем эмоджи(4/1707)\n",
|
1169 |
+
" return text"
|
1170 |
+
]
|
1171 |
+
},
|
1172 |
+
{
|
1173 |
+
"cell_type": "code",
|
1174 |
+
"execution_count": 54,
|
1175 |
+
"id": "3e7d68bb-09b8-48c3-875c-eece6f9cb7c3",
|
1176 |
+
"metadata": {},
|
1177 |
+
"outputs": [
|
1178 |
+
{
|
1179 |
+
"name": "stderr",
|
1180 |
+
"output_type": "stream",
|
1181 |
+
"text": [
|
1182 |
+
"/tmp/ipykernel_3152/2295399223.py:1: SettingWithCopyWarning: \n",
|
1183 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
1184 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
1185 |
+
"\n",
|
1186 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
1187 |
+
" data_main_no_duplicates['cleaned_text'] = data_main_no_duplicates['annotation'].apply(clean)\n"
|
1188 |
+
]
|
1189 |
+
},
|
1190 |
+
{
|
1191 |
+
"data": {
|
1192 |
+
"text/plain": [
|
1193 |
+
"0 расследование жизни деяний самых опороченных в...\n",
|
1194 |
+
"1 сыщики макар илюшин сергей бабкин расследуют п...\n",
|
1195 |
+
"2 генрих самая трагическая фигура английском пре...\n",
|
1196 |
+
"3 истории трех знаменитых королей обложкой посво...\n",
|
1197 |
+
"4 первая необычном александры марининой жанре по...\n",
|
1198 |
+
" ... \n",
|
1199 |
+
"3940 ирма повести бизнесплан ас��ирантки помышляла б...\n",
|
1200 |
+
"3941 основная идея романа давление обстоятельств жи...\n",
|
1201 |
+
"3942 небольшой горный пансионат игл нест туристичес...\n",
|
1202 |
+
"3943 пола привыкла разговоры любви духовном физичес...\n",
|
1203 |
+
"3944 последняя пристройка крепости мак леннан завер...\n",
|
1204 |
+
"Name: cleaned_text, Length: 3691, dtype: object"
|
1205 |
+
]
|
1206 |
+
},
|
1207 |
+
"execution_count": 54,
|
1208 |
+
"metadata": {},
|
1209 |
+
"output_type": "execute_result"
|
1210 |
+
}
|
1211 |
+
],
|
1212 |
+
"source": [
|
1213 |
+
"data_main_no_duplicates['cleaned_text'] = data_main_no_duplicates['annotation'].apply(clean)\n",
|
1214 |
+
"data_cleaned = data_main_no_duplicates['cleaned_text']\n",
|
1215 |
+
"data_cleaned"
|
1216 |
+
]
|
1217 |
+
},
|
1218 |
+
{
|
1219 |
+
"cell_type": "code",
|
1220 |
+
"execution_count": 55,
|
1221 |
+
"id": "b7ddc1cf-6824-4b6c-9364-0f14327c96b8",
|
1222 |
+
"metadata": {},
|
1223 |
+
"outputs": [],
|
1224 |
+
"source": [
|
1225 |
+
"morph = pymorphy3.MorphAnalyzer()"
|
1226 |
+
]
|
1227 |
+
},
|
1228 |
+
{
|
1229 |
+
"cell_type": "code",
|
1230 |
+
"execution_count": 58,
|
1231 |
+
"id": "c4fc3c3e-92a6-4853-a399-f7ef4669b70c",
|
1232 |
+
"metadata": {},
|
1233 |
+
"outputs": [],
|
1234 |
+
"source": [
|
1235 |
+
"def lemmatize_batch(texts, batch_size=1000):\n",
|
1236 |
+
" \"\"\"Лемматизация текста по батчам для ускорения.\"\"\"\n",
|
1237 |
+
" lemmatized_texts = []\n",
|
1238 |
+
" for i in tqdm(range(0, len(texts), batch_size)):\n",
|
1239 |
+
" batch = texts[i:i+batch_size]\n",
|
1240 |
+
" lemmatized_batch = [' '.join([morph.parse(word)[0].normal_form for word in text.split()]) for text in batch]\n",
|
1241 |
+
" lemmatized_texts.extend(lemmatized_batch)\n",
|
1242 |
+
" return lemmatized_texts\n"
|
1243 |
+
]
|
1244 |
+
},
|
1245 |
+
{
|
1246 |
+
"cell_type": "code",
|
1247 |
+
"execution_count": 59,
|
1248 |
+
"id": "caff9227-3d13-49f4-898a-781fd3283d2a",
|
1249 |
+
"metadata": {},
|
1250 |
+
"outputs": [
|
1251 |
+
{
|
1252 |
+
"name": "stderr",
|
1253 |
+
"output_type": "stream",
|
1254 |
+
"text": [
|
1255 |
+
"100%|█████████████████████████████████████████████| 4/4 [00:20<00:00, 5.15s/it]\n",
|
1256 |
+
"/tmp/ipykernel_3152/3826416347.py:1: SettingWithCopyWarning: \n",
|
1257 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
1258 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
1259 |
+
"\n",
|
1260 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
1261 |
+
" data_main_no_duplicates['lemmatized_text'] = lemmatize_batch(data_main_no_duplicates['cleaned_text'].tolist())\n"
|
1262 |
+
]
|
1263 |
+
}
|
1264 |
+
],
|
1265 |
+
"source": [
|
1266 |
+
"data_main_no_duplicates['lemmatized_text'] = lemmatize_batch(data_main_no_duplicates['cleaned_text'].tolist())"
|
1267 |
+
]
|
1268 |
+
},
|
1269 |
+
{
|
1270 |
+
"cell_type": "code",
|
1271 |
+
"execution_count": 61,
|
1272 |
+
"id": "f9271faa-f093-4f7c-9944-f822765f538c",
|
1273 |
+
"metadata": {},
|
1274 |
+
"outputs": [
|
1275 |
+
{
|
1276 |
+
"data": {
|
1277 |
+
"text/plain": [
|
1278 |
+
"0 расследование жизнь деяние самый опорочить воз...\n",
|
1279 |
+
"1 сыщик макар илюшин сергей бабкин расследовать ...\n",
|
1280 |
+
"2 генрих самый трагический фигура английский пре...\n",
|
1281 |
+
"3 история три знаменитый король обложка посвоему...\n",
|
1282 |
+
"4 первый необычный александра маринин жанр попул...\n",
|
1283 |
+
" ... \n",
|
1284 |
+
"3940 ирма повесть бизнесплан аспирантка помышлять б...\n",
|
1285 |
+
"3941 основный идея роман давление обстоятельство жи...\n",
|
1286 |
+
"3942 небольшой горный пансионат игла несть туристич...\n",
|
1287 |
+
"3943 пол привыкнуть разговор любовь духовный физиче...\n",
|
1288 |
+
"3944 последний пристройка крепость мак леннана заве...\n",
|
1289 |
+
"Name: lemmatized_text, Length: 3691, dtype: object"
|
1290 |
+
]
|
1291 |
+
},
|
1292 |
+
"execution_count": 61,
|
1293 |
+
"metadata": {},
|
1294 |
+
"output_type": "execute_result"
|
1295 |
+
}
|
1296 |
+
],
|
1297 |
+
"source": [
|
1298 |
+
"data_main_no_duplicates['lemmatized_text']"
|
1299 |
+
]
|
1300 |
+
},
|
1301 |
+
{
|
1302 |
+
"cell_type": "code",
|
1303 |
+
"execution_count": null,
|
1304 |
+
"id": "1158703d-4ebe-4a18-93d2-ef412363deb2",
|
1305 |
+
"metadata": {},
|
1306 |
+
"outputs": [],
|
1307 |
+
"source": [
|
1308 |
+
"data_main_no_duplicates['lemmatized_text'].to_csv('lemmatized_data')"
|
1309 |
+
]
|
1310 |
+
},
|
1311 |
+
{
|
1312 |
+
"cell_type": "markdown",
|
1313 |
+
"id": "f540af02-2165-4138-b77c-88d0ef89cd3a",
|
1314 |
+
"metadata": {},
|
1315 |
+
"source": [
|
1316 |
+
"Убрать из названия знаки препинания"
|
1317 |
+
]
|
1318 |
+
},
|
1319 |
+
{
|
1320 |
+
"cell_type": "code",
|
1321 |
+
"execution_count": null,
|
1322 |
+
"id": "5cc96e83-9893-4dd7-ba86-c466d6fcebf0",
|
1323 |
+
"metadata": {},
|
1324 |
+
"outputs": [],
|
1325 |
+
"source": []
|
1326 |
+
}
|
1327 |
+
],
|
1328 |
+
"metadata": {
|
1329 |
+
"kernelspec": {
|
1330 |
+
"display_name": "Python 3 (ipykernel)",
|
1331 |
+
"language": "python",
|
1332 |
+
"name": "python3"
|
1333 |
+
},
|
1334 |
+
"language_info": {
|
1335 |
+
"codemirror_mode": {
|
1336 |
+
"name": "ipython",
|
1337 |
+
"version": 3
|
1338 |
+
},
|
1339 |
+
"file_extension": ".py",
|
1340 |
+
"mimetype": "text/x-python",
|
1341 |
+
"name": "python",
|
1342 |
+
"nbconvert_exporter": "python",
|
1343 |
+
"pygments_lexer": "ipython3",
|
1344 |
+
"version": "3.10.13"
|
1345 |
+
}
|
1346 |
+
},
|
1347 |
+
"nbformat": 4,
|
1348 |
+
"nbformat_minor": 5
|
1349 |
+
}
|