{"id":462815,"date":"2025-06-10T21:00:03","date_gmt":"2025-06-10T21:00:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=462815"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=462815","title":{"rendered":"<span>\u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0412\u043e\u043b\u043a\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e \u0447\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0432\u043e\u043b\u043a\u0438? \u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u044b \u041e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0440\u043a\u0430\u043d\u0442\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u0442\u0430\u043a \u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 (\u0441\u043f\u043e\u0439\u043b\u0435\u0440: \u0434\u0430), \u0430 \u0435\u0449\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0443\u0437\u043d\u0430\u0435\u043c, \u0432 \u0447\u0435\u043c \u0441\u043c\u044b\u0441\u043b \u0436\u0438\u0437\u043d\u0438 <span class=\"habrahidden\">(\u043d\u0435 \u0441\u0444\u0430\u043b\u044c\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u043a\u043b\u044f\u043d\u0443\u0441\u044c)<\/span>.<\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438. <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3e0\/73c\/cd1\/3e073ccd196357f59dc1245cab42dea6.png\" alt=\"\u0417\u0430\u043d\u044f\u0442\u0438\u0435 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432 \u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\" title=\"\u0417\u0430\u043d\u044f\u0442\u0438\u0435 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432 \u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\" width=\"780\" height=\"440\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/3e0\/73c\/cd1\/3e073ccd196357f59dc1245cab42dea6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3e0\/73c\/cd1\/3e073ccd196357f59dc1245cab42dea6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043d\u044f\u0442\u0438\u0435 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432 \u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043a\u0435 2022 \u0433\u043e\u0434\u0430 (\u043c\u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f).  \u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438: \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043a\u0440\u043e\u0439\u0442\u0435 \u0433\u043b\u0430\u0437\u0430.<\/p>\n<h2>\u0421\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0421\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430. \u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u0431\u043b\u043e\u0433\u0438, \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043e\u0442\u0437\u044b\u0432\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<h3>\u041f\u0430\u0440\u0441\u0438\u043d\u0433<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438\u0437 Telegram-\u043a\u0430\u043d\u0430\u043b\u0430 \u0432 Google Colab \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Python,  \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443\u00a0<code>Telethon<\/code>. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 Telegram API \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f).  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Telegram API \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f\u00a0<code>api_id<\/code>\u00a0\u0438\u00a0<code>api_hash<\/code>.<\/p>\n<ol>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u00a0<a href=\"http:\/\/my.telegram.org\" rel=\"noopener noreferrer nofollow\">my.telegram.org<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0439\u0434\u0438\u0442\u0435 \u0432 \u0441\u0432\u043e\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 Telegram.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 &#171;API development tools&#187;.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (\u043b\u044e\u0431\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442).<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435\u00a0<code>App api_id<\/code>\u00a0\u0438\u00a0<code>App api_hash<\/code>. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438\u0445.<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a Google Drive \u0438 Telegram<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import os from google.colab import drive  drive.mount('\/content\/drive')  session_path = '\/content\/drive\/MyDrive\/telethon_sessions\/'  os.makedirs(session_path, exist_ok=True)  session_name = 'my_telegram_session'  session_file_path = os.path.join(session_path, session_name)  print(f\"\u0424\u0430\u0439\u043b \u0441\u0435\u0441\u0441\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u043f\u043e \u043f\u0443\u0442\u0438: {session_file_path}.session\")<\/code><\/pre>\n<pre><code class=\"python\">!pip install telethon  from telethon.sync import TelegramClient from telethon.tl.types import Channel  # !!! \u0417\u0410\u041c\u0415\u041d\u0418\u0422\u0415 \u041d\u0410 \u0412\u0410\u0428\u0418 API ID \u0438 API Hash !!!  api_id = 0 api_hash = ''  client = TelegramClient(session_file_path, api_id, api_hash)  try: \u00a0\u00a0\u00a0 await client.start() except Exception as e: \u00a0\u00a0\u00a0 if not client.is_user_authorized(): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 phone_number = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 (\u0441 \u043a\u043e\u0434\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 +79XXXXXXXXX): ') \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await client.start(phone=phone_number)          print(f\"\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430 \u043a\u0430\u043a: {(await client.get_me()).first_name} {(await client.get_me()).last_name}\")  # client.disconnect() # \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u043e\u0432 \u043c\u043d\u043e\u0433\u043e \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0432 \u0444\u0430\u0439\u043b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u0438\u043c\u0438\u0442 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<pre><code class=\"python\">import json  async def get_channel_posts_text(channel_identifier): \u00a0\u00a0\u00a0 posts_text = [] \u00a0\u00a0\u00a0 try: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 entity = await client.get_entity(channel_identifier)  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if not isinstance(entity, (Channel)): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return []  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 async for message in client.iter_messages(entity, limit=None): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if message.text: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 posts_text.append(message.text)  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print(f\"\u0412\u0441\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e {len(posts_text)} \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u0430 '{entity.title}'.\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0          return posts_text  \u00a0\u00a0\u00a0 except Exception as e: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return []  channel_username = '@m0rtymerr_channel' parsed_posts = await get_channel_posts_text(channel_username)   if parsed_posts: \u00a0\u00a0\u00a0 safe_channel_name = channel_username.replace('@', '') \u00a0\u00a0\u00a0 output_file_name = f\"{safe_channel_name}_posts.json\" \u00a0\u00a0\u00a0 output_file_path = os.path.join(session_path, output_file_name)     with open(output_file_path, 'w', encoding='utf-8') as f: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 json.dump(parsed_posts, f, ensure_ascii=False, indent=4)<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u043a\u043e\u0434 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">!pip install numpy==1.26.4 'pandas&lt;1.8' # \u041f\u0415\u0420\u0415\u0417\u0410\u041f\u0423\u0421\u0422\u0418\u0422\u042c  import pandas as pd import re import numpy as np from matplotlib import pyplot as plt  channel_username = '@m0rtymerr_channel' safe_channel_name = channel_username.replace('@', '') output_file_name = f\"{safe_channel_name}_posts.json\" output_file_path = os.path.join(session_path, output_file_name)  df=pd.read_json(output_file_path) df.rename(columns={0:'text'}, inplace = True ) df.head()<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e <em>\u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 <\/em>\u044d\u0442\u0430\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0443. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0434\u0437\u0438, \u0446\u0438\u0444\u0440, \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0430\u043d\u0433\u043b\u0438\u0446\u0438\u0437\u043c\u044b<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e. \u0412\u043c\u0435\u0441\u0442\u0435 \u043e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p><strong>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f <\/strong>\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438. \u0422\u043e\u043a\u0435\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0444\u0440\u0430\u0437\u0430\u043c\u0438 \u0438\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u042d\u0442\u043e\u0442 \u0448\u0430\u0433 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f <\/strong>\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432 \u043a \u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 (\u043b\u0435\u043c\u043c\u0435). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u043e\u0432\u0430 &#171;\u0431\u0435\u0433\u0443&#187;, &#171;\u0431\u0435\u0436\u0438\u0442&#187; \u0438 &#171;\u0431\u0435\u0433\u0430\u043b&#187; \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a \u043b\u0435\u043c\u043c\u0435 &#171;\u0431\u0435\u0436\u0430\u0442\u044c&#187;. \u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u043b\u043e\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ad7\/371\/5a8\/ad73715a8e78bc063b47d60e9e3c9104.png\" alt=\"\u043e\u0442 \u0438 \u0434\u043e\" title=\"\u043e\u0442 \u0438 \u0434\u043e\" width=\"823\" height=\"206\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ad7\/371\/5a8\/ad73715a8e78bc063b47d60e9e3c9104.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ad7\/371\/5a8\/ad73715a8e78bc063b47d60e9e3c9104.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u043e\u0442 \u0438 \u0434\u043e<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/summary>\n<div class=\"spoiler__content\">\n<h4>\u041d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/h4>\n<pre><code class=\"python\">df[\"tokens\"] = df.text.apply(str.lower)<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0434\u0436\u0438<\/h4>\n<pre><code class=\"python\">!pip install emoji  import emoji df['tokens'] = df['tokens'].apply(lambda s: emoji.replace_emoji(s, ''))<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440<\/h4>\n<pre><code class=\"python\">df['tokens'] = df['tokens'].apply(lambda s: re.sub(r\"\\d+\", \"\", s, flags=re.UNICODE))<\/code><\/pre>\n<h4>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<pre><code class=\"python\">!pip install razdel  from razdel import tokenize def get_tokens(sentence):   return [_.text.strip() for _ in tokenize(sentence)]  df[\"tokens\"] = df.tokens.apply(get_tokens)<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0443\u043d\u043a\u0442\u0443\u0430\u0446\u0438\u0438<\/h4>\n<pre><code class=\"python\">import string  df[\"tokens\"] = df.tokens.apply(lambda row: [token for token in row if token not in string.punctuation + string.digits + '...'+'\u2014'+'\u00bb'+'\u00ab'+\"\u2013\" + '**' + '\u2043' + '=)'+'\u2022'+'-']) df[\"tokens\"] = df[\"tokens\"].apply(lambda row: [token for token in row if not re.match(r'^-+$', token)])<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0445 \u0441\u043b\u043e\u0432<\/h4>\n<pre><code class=\"python\">df['tokens'] = df['tokens'].apply( lambda row: [ token for token in row if token == \"it\" or not re.search(r\"[a-zA-Z]+\", token)])<\/code><\/pre>\n<h4>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<pre><code class=\"python\">!pip install pymorphy3 pymorphy3-dicts-ru pymorphy2  import pymorphy2 from tqdm.notebook import tqdm  # \u043d\u0443... \u0431\u044b\u0432\u0430\u0435\u0442 def pymorphy2_311_hotfix():     from inspect import getfullargspec     from pymorphy2.units.base import BaseAnalyzerUnit      def _get_param_names_311(klass):         if klass.__init__ is object.__init__:             return []         args = getfullargspec(klass.__init__).args         return sorted(args[1:])      setattr(BaseAnalyzerUnit, '_get_param_names', _get_param_names_311)  pymorphy2_311_hotfix() analyzer = pymorphy2.MorphAnalyzer()  df[\"tokens\"] = tqdm(df.tokens.apply(lambda row: [analyzer.parse(token)[0].normal_form for token in row if token]))<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043f \u0441\u043b\u043e\u0432<\/h4>\n<pre><code class=\"python\">import nltk from nltk.corpus import stopwords  nltk.download('stopwords') nltk.download('punkt')  additional_stops=[\"\u044d\u0442\u043e\", \"\u043a\u043e\u0442\u043e\u0440\u044b\u0439\", \"\u043d\u0430\u0448\", \"\u043c\u043e\u0447\u044c\", \"\u0433\u043e\u0434\",\"\u0442\u0430\u043a\u043e\u0439\", \"\u043c\u044b\", \"\u0441\u0432\u043e\u0439\", \"\u043e\u0434\u0438\u043d\", \"\u0434\u0440\u0443\u0433\u043e\u0439\", \"\u0447\u0435\u043b\u043e\u0432\u0435\u043a\", \"\u0432\u0441\u0451\", \"\u0432\u0441\u0435\", \"\u0432\u0435\u0441\u044c\", \"\u043e\u0447\u0435\u043d\u044c\", \"\u043a\u0430\u0436\u0434\u044b\u0439\", \"\u0434\u0435\u043d\u044c\", \"\u0435\u0451\", \"\u0432\u0430\u0448\", \"\u0432\u0430\u0448\u0435\", \"\u0434\u0435\u043d\u044c\", \"\u0441\u0430\u043c\u044b\u0439\", \"\u0435\u0449\u0451\",\"\u0442\u0430\u043a\u0436\u0435\", \"\u043d\u0443\u0436\u043d\u043e\",\"\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\", \"\u0432\u0435\u0449\u044c\", \"\u0445\u043e\u0440\u043e\u0448\u0438\u0439\", '\u043d\u043e\u0432\u044b\u0439', \"\u0441\u043f\u0430\u0441\u0438\u0431\u043e\", '\u0442\u0432\u043e\u0439', '\u043b\u044e\u0431\u043e\u0439','\u0447\u0442\u043e-\u0442\u043e','\u0447\u0435','\u043a\u0430\u043a\u043e\u0439-\u0442\u043e','\u043a\u0430\u043a\u043e\u0439-\u0442\u043e', '\u043f\u0440\u0438\u0432\u0435\u0442', '\u0447\u0430\u0441', '\u043c\u0435\u0441\u044f\u0446','\u043d\u0435\u0434\u0435\u043b\u044f','\u0441\u0435\u0433\u043e\u0434\u043d\u044f'] om_stops=['\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e', '\u043e\u043c', '\u0430\u043d\u0442\u043e\u043d','\u043d\u0430\u0437\u0430\u0440\u043e\u0432'] stops = list(string.ascii_lowercase) + list('\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u044f') + stopwords.words(\"russian\") + om_stops + additional_stops  df[\"tokens\"] = df.tokens.apply(lambda row: [token for token in row if token not in stops])<\/code><\/pre>\n<h4>\u0414\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<pre><code class=\"python\">all_words = [] for doc in df.tokens.tolist():   all_words.extend(doc)<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0422\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0422\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 NLP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445, \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u044c\u0438, \u0431\u043b\u043e\u0433\u0438, \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0414\u0438\u0440\u0438\u0445\u043b\u0435 (LDA). \u042d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u0441\u043c\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0435\u043c, \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0435\u043c\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0432. LDA \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0435\u043c\u044b \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445, \u043d\u043e \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043c. \u0411\u0443\u0434\u0435\u043c \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a6a\/38e\/dae\/a6a38edaec081a3b2259c7ab8b9f0d45.png\" width=\"576\" height=\"455\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/a6a\/38e\/dae\/a6a38edaec081a3b2259c7ab8b9f0d45.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a6a\/38e\/dae\/a6a38edaec081a3b2259c7ab8b9f0d45.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u043f\u043e\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043c, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u0430.<\/p>\n<\/div>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import gensim.corpora as corpora from gensim.models import LdaMulticore, CoherenceModel from tqdm import tqdm import warnings import matplotlib.pyplot as plt  id2word = corpora.Dictionary(df.tokens.tolist()) texts = df.tokens.tolist() corpus = [id2word.doc2bow(text) for text in texts]  warnings.filterwarnings(\"ignore\")  def compute_coherence_values(dictionary, corpus, texts, limit, start=2, step=3):     coherence_values = []     model_list = []     for num_topics in tqdm(range(start, limit, step)):         model=LdaMulticore(corpus=corpus,id2word=dictionary, num_topics=num_topics)         model_list.append(model)         coherencemodel = CoherenceModel(model=model, texts=texts, dictionary=dictionary, coherence='c_v')         coherence_values.append(coherencemodel.get_coherence())     return model_list, coherence_values  model_list, coherence_values = compute_coherence_values(dictionary=id2word, corpus=corpus, texts=texts, start=2, limit=20, step=1)  limit=20; start=2; step=1; x = range(start, limit, step)  plt.figure(facecolor='black') ax = plt.gca() ax.set_facecolor('black') plt.plot(x, coherence_values, color='#DEB040') plt.xlabel(\"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043c\", color='white') plt.ylabel(\"\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c\", color='white') plt.tick_params(labelcolor='white') plt.grid(color='white', linestyle='--', linewidth=0.5) plt.title(\"\u0413\u0440\u0430\u0444\u0438\u043a \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438\", color='white') plt.show()<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0435\u043c, \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c LDA \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0438 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c pyLDAvis \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043c. \u042d\u0442\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043c\u044b, \u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">lda_model = LdaMulticore(corpus=corpus, id2word=id2word, num_topics=n_topics)  pyLDAvis.enable_notebook() LDAvis_prepared = pyLDAvis.gensim.prepare(lda_model, corpus, id2word) LDAvis_prepared<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/258\/157\/9c3\/2581579c3c8d0a76ed067c3d554165a3.png\" width=\"1462\" height=\"836\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/258\/157\/9c3\/2581579c3c8d0a76ed067c3d554165a3.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/258\/157\/9c3\/2581579c3c8d0a76ed067c3d554165a3.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043c\u0430\u0445, \u043d\u043e \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435 (\u0442\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430), \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0441\u043b\u043e\u0432\u0430 \u0438 \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u0438\u0445 \u0442\u0435\u043c\u0430\u0445 \u043e\u043d\u0438 \u0447\u0430\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0442\u0435\u043c\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0415\u0441\u0442\u044c \u043b\u0438 \u0442\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435?<\/p>\n<p>\u041f\u043e\u0442\u044b\u043a\u0430\u0432 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u044f \u0432\u0438\u0434\u0435\u043b\u0430 \u0442\u0435\u043c\u044b \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439, \u043c\u0435\u043d\u0442\u043e\u0440\u043e\u0432, \u043d\u0430\u043a\u0440\u0443\u0442\u043a\u0443, \u0432\u044b\u0445\u043e\u0434 \u0440\u043e\u043b\u0438\u043a\u043e\u0432, \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e, \u0432\u0441\u044f\u043a\u043e\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u043e \u0436\u0438\u0437\u043d\u0438. \u041d\u043e \u0432 \u0441\u0430\u043c\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u0440\u0443\u0436\u043a\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439. \u0422\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">!pip install matplotlib pyLDAvis==2.1.2  from gensim.models import LdaMulticore, CoherenceModel import pyLDAvis.gensim import pickle import pyLDAvis import os  n_topics= 10 lda_model = LdaMulticore(corpus=corpus, id2word=id2word, num_topics=n_topics)  pyLDAvis.enable_notebook() LDAvis_prepared = pyLDAvis.gensim.prepare(lda_model, corpus, id2word) LDAvis_prepared<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430<\/h2>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u043a\u0440\u0430\u0441\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043b\u0438 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0433\u043e\u0434\u044b \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0441\u0442\u0430\u043b \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0440\u043e\u0441\u0442\u0430 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u043e\u0442\u0437\u044b\u0432\u0430\u0445, \u043d\u043e\u0432\u043e\u0441\u0442\u044f\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445. <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0446\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0430\u0439\u0442\u044b \u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0430\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439, \u0447\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0440\u0435\u043d\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435 \u043e \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445, \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u0441\u0442\u0430\u0434\u0438\u044f\u0445 \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. <\/p>\n<p>\u0412 2022 \u0433\u043e\u0434\u0443 \u043c\u044b \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 dostoevsky. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u044f \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>Transformers<\/code>\u00a0\u043e\u0442 Hugging Face.<\/p>\n<pre><code class=\"python\">from transformers import pipeline sentiment_pipeline = pipeline(\"sentiment-analysis\", model=\"blanchefort\/rubert-base-cased-sentiment\", tokenizer=\"blanchefort\/rubert-base-cased-sentiment\") sentiment_pipeline('\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430!')<\/code><\/pre>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fce\/024\/034\/fce024034f9e9f40eb66b5e155a21c5b.png\" width=\"594\" height=\"435\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/fce\/024\/034\/fce024034f9e9f40eb66b5e155a21c5b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fce\/024\/034\/fce024034f9e9f40eb66b5e155a21c5b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u0441 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u0431\u0435\u0437 \u043d\u0438\u0445. \u041e\u0442\u0447\u0435\u0442\u043b\u0438\u0432\u043e \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e <em>\u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 <\/em>\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 <em>\u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445<\/em>.<\/p>\n<\/div>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/df0\/7bb\/53d\/df07bb53dbad55c496074e282e4d90d2.png\" width=\"556\" height=\"404\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/df0\/7bb\/53d\/df07bb53dbad55c496074e282e4d90d2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/df0\/7bb\/53d\/df07bb53dbad55c496074e282e4d90d2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0422\u0443\u0442 \u044f \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445\\\u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0421\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u043f\u043e 100 \u0448\u0442\u0443\u043a. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u044b, \u0433\u0434\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u043a\u0430\u0447\u043a\u0438. \u041d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 <s>\u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433<\/s> \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442\u0441\u044f.<\/p>\n<\/div>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from transformers import pipeline  sentiment_pipeline = pipeline(\"sentiment-analysis\", model=\"blanchefort\/rubert-base-cased-sentiment\", tokenizer=\"blanchefort\/rubert-base-cased-sentiment\") tokens = df.tokens.tolist() messages = [\" \".join(inner_list) for inner_list in tokens] sentiment = [item['label'] for item in sentiment_pipeline(messages)]  vis = pd.DataFrame(pd.Series(sentiment).value_counts()).reset_index() vis.columns = ['sentiment', 'counts'] vis=vis.sort_values(by=\"counts\")  vis_res=vis.drop([0]) # \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f  colors = [\"#DEB040\", \"yellow\"] plt.figure(facecolor='black') ax = plt.gca() ax.set_facecolor('black') plt.tick_params(labelcolor='white') plt.grid(color='white', linestyle='--', linewidth=0.5) plt.title(\"\u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043a\u043e\u043b-\u0432\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439)\", color='white')  plt.barh(y=vis_res.sentiment, width=vis_res.counts, color=colors) plt.show()<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/p>\n<pre><code class=\"python\">from matplotlib.ticker import FuncFormatter  positive_counts = [] negative_counts = [] step = 100   for i in range(0, len(sent), step):     inner_list = sent[i:i + step]     positive_count = inner_list.count('POSITIVE')\/len(inner_list)*100     negative_count = inner_list.count('NEGATIVE')\/len(inner_list)*100          positive_counts.append(positive_count)     negative_counts.append(negative_count)  indices = np.arange(len(sent) \/ step)  plt.figure(facecolor='black') ax = plt.gca() ax.set_facecolor('black') plt.tick_params(labelcolor='white') plt.title(\"\u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043f\u043e 100 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439)\", color='white') ax.set_xticklabels([]) ax.yaxis.set_major_formatter(FuncFormatter(lambda x, pos: f'{int(x)}%')) plt.plot(indices, positive_counts, label='Positive', color='#DEB040') plt.plot(indices, negative_counts, label='Negative', color='yellow') plt.xticks(indices) plt.legend(facecolor='black', labelcolor='white') plt.show()<\/code><\/pre>\n<\/div>\n<\/details>\n<h3>\u0427\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437<\/h3>\n<p>\u041f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438, \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 (\u0447\u0430\u0441\u0442\u043e\u0442\u044b) \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0432, \u0444\u0440\u0430\u0437 \u0438\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043e\u0440\u043f\u0443\u0441\u0435. \u042d\u0442\u043e\u0442, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0434\u0432\u0435\u0440\u0438 \u0434\u043b\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430, \u0434\u043e\u043c\u0438\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u043c\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043b\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u0438.<\/p>\n<p>\u0427\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0441\u043b\u0443\u0436\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447: \u043e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u0432 \u0434\u043b\u044f SEO-\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e \u043b\u0438\u043d\u0433\u0432\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430:<\/p>\n<pre><code class=\"python\">res = pd.DataFrame(all_words, columns=[\"terms\"]) vis = pd.DataFrame(res.terms.value_counts()).reset_index() vis.columns = ['terms', 'counts'] vis=vis.sort_values(by=\"counts\")[-10:] colors = [\"#DEB040\" for _ in range(9)]+[\"yellow\"] plt.figure(facecolor='black') ax = plt.gca() ax.set_facecolor('black') plt.tick_params(labelcolor='white') plt.barh(y=vis.terms, width=vis.counts, color=colors) plt.grid(color='white', linestyle='--', linewidth=0.5) plt.title(\"\u0427\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\", color='white') plt.show()<\/code><\/pre>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ae0\/e8a\/fe3\/ae0e8afe3da69dbf7ef61094c70931b9.png\" alt=\"\" title=\"\" width=\"648\" height=\"435\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ae0\/e8a\/fe3\/ae0e8afe3da69dbf7ef61094c70931b9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ae0\/e8a\/fe3\/ae0e8afe3da69dbf7ef61094c70931b9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430, \u0432\u043e\u043f\u0440\u043e\u0441, \u043e\u043f\u044b\u0442, it, \u0441\u0442\u0430\u044f &#8212; \u0442\u043e, \u043e \u0447\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0441 \u0443\u0447\u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043a\u0446\u0435\u043d\u0442\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u044f\u0440\u043a\u043e.<\/p>\n<\/div>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0431\u043b\u0430\u043a\u0430 \u0441\u043b\u043e\u0432  \u2014 \u044d\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0434\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c: \u0447\u0435\u043c \u0447\u0430\u0449\u0435 \u0441\u043b\u043e\u0432\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f, \u0442\u0435\u043c \u043a\u0440\u0443\u043f\u043d\u0435\u0435 \u043e\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043a\u0430\u0436\u0443\u0449\u0443\u044e\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443, \u043e\u0431\u043b\u0430\u043a\u0430 \u0441\u043b\u043e\u0432 \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u044b<\/p>\n<\/li>\n<li>\n<p>\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0434\u043b\u044f \u043d\u0435\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<figure class=\"bordered full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/69c\/49f\/56f\/69c49f56f4013b4642429491e45b8944.png\" alt=\"\u0430\u0443\u0444\" title=\"\u0430\u0443\u0444\" width=\"1182\" height=\"1072\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/69c\/49f\/56f\/69c49f56f4013b4642429491e45b8944.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/69c\/49f\/56f\/69c49f56f4013b4642429491e45b8944.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0430\u0443\u0444<\/figcaption><\/div>\n<\/figure>\n<div class=\"floating-image\">\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c \u0440\u0435\u0447\u0438. \u0418\u043d\u043e\u0433\u0434\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435. \u041a\u0430\u043a \u0442\u0443\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043d\u0435\u0441\u0443\u0442 \u0441\u043c\u044b\u0441\u043b\u0430. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c.<\/p>\n<\/div>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/30b\/b5b\/d5a\/30bb5bd5a109443bb84abd9cf00efae0.png\" alt=\"\u043c\u0435\u0448\u043e\u0447\u043a\u0438 \u0441 \u0434\u0435\u043d\u044c\u0433\u0430\u043c\u0438 \u0442\u0438\u043f\u043e\" title=\"\u043c\u0435\u0448\u043e\u0447\u043a\u0438 \u0441 \u0434\u0435\u043d\u044c\u0433\u0430\u043c\u0438 \u0442\u0438\u043f\u043e\" width=\"1570\" height=\"561\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/30b\/b5b\/d5a\/30bb5bd5a109443bb84abd9cf00efae0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/30b\/b5b\/d5a\/30bb5bd5a109443bb84abd9cf00efae0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u043c\u0435\u0448\u043e\u0447\u043a\u0438 \u0441 \u0434\u0435\u043d\u044c\u0433\u0430\u043c\u0438 \u0442\u0438\u043f\u043e<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u043b\u0430\u043a\u043e\u0432 \u0441\u043b\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">!pip install wordcloud  from collections import Counter from wordcloud import WordCloud from PIL import Image import requests from io import BytesIO import numpy as np import matplotlib.pyplot as plt  words = dict(Counter(all_words))  url='\/content\/wolf.png' if os.path.exists(url):     image_pil = Image.open(url)     cloud_mask = np.array(image_pil)  wc = WordCloud(background_color=\"black\", max_words=200, mask=cloud_mask, colormap=\"Wistia_r\") wc.generate_from_frequencies(words)  plt.figure(figsize=(10, 10)) plt.imshow(wc, interpolation=\"bilinear\") plt.axis(\"off\") plt.show()<\/code><\/pre>\n<p>\u041e\u0431\u043b\u0430\u043a\u043e \u0441\u043b\u043e\u0432 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c \u0440\u0435\u0447\u0438<\/p>\n<pre><code class=\"python\">def get_words(functors_pos):   morph=pymorphy2.MorphAnalyzer()   words=[]   for word in all_words:     if morph.parse(word)[0].tag.POS in functors_pos:       words.append(word)   words = dict(Counter(words))   return words  noun = get_words({'NOUN'}) adjf = get_words({'ADJF', 'ADJS'}) verb = get_words({'VERB', 'INFN'})  url = \"https:\/\/www.pinclipart.com\/picdir\/middle\/560-5604427_money-bag-clip-art-png-download.png\" response = requests.get(url) cloud_mask = np.array(Image.open(BytesIO(response.content)))  wc = WordCloud(background_color=\"black\", max_words=200, mask=cloud_mask, colormap=\"Wistia_r\") wc.generate_from_frequencies(words)  wc.generate_from_frequencies(verb) fig, axs = plt.subplots(nrows= 1 , ncols= 3, figsize=(20, 20)) axs[0].imshow(wc, interpolation=\"bilinear\") axs[0].axis(\"off\") wc.generate_from_frequencies(adjf) axs[1].imshow(wc, interpolation=\"bilinear\") axs[1].axis(\"off\") wc.generate_from_frequencies(noun) axs[2].imshow(wc, interpolation=\"bilinear\") axs[2].axis(\"off\")<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0413\u0440\u0430\u0444<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u043e\u0432 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u043e \u0438 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043b\u0438\u043d\u0433\u0432\u0438\u0441\u0442\u0438\u043a\u0443, \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433 \u0438 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>NetworkX<\/code>\u00a0\u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u0430, \u0433\u0434\u0435 \u0443\u0437\u043b\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043b\u043e\u0432\u0430, \u0430 \u0440\u0451\u0431\u0440\u0430 \u2014 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0438\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438 (\u043f\u0430\u0440\u0430\u043c\u0438 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0441\u043b\u043e\u0432) \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432. \u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u044f\u0437\u044c, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0447\u0430\u0441\u0442\u0438 \u0440\u0435\u0447\u0438, \u043d\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/89e\/96d\/cef\/89e96dcefb8c825b77df4e04ba21dc76.jpg\" alt=\"\u0441\u043c\u044b\u0441\u043b \u0436\u0438\u0437\u043d\u0438 \u0432 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438\" title=\"\u0441\u043c\u044b\u0441\u043b \u0436\u0438\u0437\u043d\u0438 \u0432 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438\" width=\"1615\" height=\"1565\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/89e\/96d\/cef\/89e96dcefb8c825b77df4e04ba21dc76.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/89e\/96d\/cef\/89e96dcefb8c825b77df4e04ba21dc76.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption><s>\u0441\u043c\u044b\u0441\u043b \u0436\u0438\u0437\u043d\u0438 \u0432 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/s><\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0446\u0435\u043d\u0442\u0440\u0435 \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0435. \u041e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u0435\u0439 \u0443 \u0441\u043b\u043e\u0432 \u0441\u043e\u0431\u0435\u0441 &#8212; \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c &#8212; \u0440\u0430\u0431\u043e\u0442<s>\u0443<\/s>\u0430. \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u0435\u0442\u043a\u0438 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435. \u041c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043e\u0447\u0438 \u043e\u043a\u043e\u043b\u043e \u0441\u043b\u043e\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u043c\u044b \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0443\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0432\u0435\u0442\u043a\u0430\u043c\u0438: \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0443\u0441\u043f\u0435\u0445\u0430, \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0440\u043e\u0441\u0442,  \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0443\u0440\u043e\u0432\u043d\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">!pip  install  networkx\"&gt;=2.5\"  from collections import Counter import networkx as nx import sys import matplotlib.pyplot as plt import matplotlib  pairs = [] for doc in df.tokens.tolist():   if doc:     b = list((nltk.bigrams(doc)))     if b:       pairs.extend(b)  pairs = [tuple(sorted(pair)) for pair in pairs] word_pairs = dict(Counter(pairs)) word_pairs = [(pair[0], pair[1], val) for pair, val in word_pairs.items() if val &gt; 5]  G = nx.Graph() edges = word_pairs  G.add_weighted_edges_from(edges)  # \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0443\u0437\u043b\u044b \u0441 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u043c\u0435\u043d\u0435\u0435 2 remove = [node for node, degree in dict(G.degree()).items() if degree &lt; 2] G.remove_nodes_from(remove)  # \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0440\u0451\u0431\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0435 \u0443\u0437\u043b\u044b remove_edge = [pair for pair in G.edges() if pair[0] in remove and pair[1] in remove] G.remove_edges_from(remove_edge)  # \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043f\u0435\u0442\u043b\u0438 remove = [pair for pair in G.edges() if pair[0] == pair[1]] G.remove_edges_from(remove)  node_sizes = [deg*50 for node, deg in dict(G.degree()).items()]  # \u0421\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444\u0438\u043a plt.figure(figsize=(40,40)) pos = nx.layout.spring_layout(G) edges, weights = zip(*nx.get_edge_attributes(G,'weight').items()) for key in pos:     x, y = pos[key]     plt.text(x,y,key, ha=\"center\", va=\"center\", fontsize=6) nx.draw(G, pos, node_color='#DEB040', edgelist=list(G.edges()), edge_color=range(len(G.edges())), width=1.0, with_labels=False, edge_cmap=plt.cm.Blues, node_size=node_sizes) plt.show()<\/code><\/pre>\n<p>\u0413\u0440\u0430\u0444 \u0441 \u0443\u0437\u043b\u0430\u043c\u0438 \u0446\u0432\u0435\u0442\u0430 \u0442\u0435\u043c<\/p>\n<pre><code class=\"python\">def get_color(node):     color_map = {         9: '#526DC0',         8: '#FFFACD',         7: '#FFB6C1',         6: '#98FF98',         5: '#FFDAB9',         4: '#E6E6FA',         3: '#FFE5B4',         2: '#F5F5DC',         1: '#D3D3D3',         0: '#ADD8E6'     }      for topic_index, color in color_map.items():         if node in topics[topic_index][1]:             return color      return '#FFFFF0'  topics=lda_model.print_topics(num_words=100) color_map = [get_color(node) for node in G]  plt.figure(figsize=(30,30)) edges, weights = zip(*nx.get_edge_attributes(G,'weight').items()) nx.draw(G, pos, edgelist=list(G.edges()), edge_color=range(len(G.edges())), width=1.0, with_labels=False, edge_cmap=plt.cm.Blues, node_size=node_sizes, node_color=color_map) for key in pos:     x, y = pos[key]     plt.text(x,y,key, ha=\"center\", va=\"center\", fontsize=6) plt.show()<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041a\u043e\u043d\u0435\u0446<\/h2>\n<details class=\"spoiler\">\n<summary>P.S.<\/summary>\n<div class=\"spoiler__content\">\n<p>\u042f \u043d\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0430 \u041e\u041c \u0432\u0441\u0443\u0435<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/917344\/\"> https:\/\/habr.com\/ru\/articles\/917344\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e \u0447\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0432\u043e\u043b\u043a\u0438? \u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u044b \u041e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0440\u043a\u0430\u043d\u0442\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u0442\u0430\u043a \u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 (\u0441\u043f\u043e\u0439\u043b\u0435\u0440: \u0434\u0430), \u0430 \u0435\u0449\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0443\u0437\u043d\u0430\u0435\u043c, \u0432 \u0447\u0435\u043c \u0441\u043c\u044b\u0441\u043b \u0436\u0438\u0437\u043d\u0438 <span class=\"habrahidden\">(\u043d\u0435 \u0441\u0444\u0430\u043b\u044c\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u043a\u043b\u044f\u043d\u0443\u0441\u044c)<\/span>.<\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0417\u0430\u043d\u044f\u0442\u0438\u0435 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432 \u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043a\u0435 2022 \u0433\u043e\u0434\u0430 (\u043c\u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f).  \u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438: \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u043a\u0440\u043e\u0439\u0442\u0435 \u0433\u043b\u0430\u0437\u0430.<\/p>\n<h2>\u0421\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0421\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430. \u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u0431\u043b\u043e\u0433\u0438, \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043e\u0442\u0437\u044b\u0432\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<h3>\u041f\u0430\u0440\u0441\u0438\u043d\u0433<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438\u0437 Telegram-\u043a\u0430\u043d\u0430\u043b\u0430 \u0432 Google Colab \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Python,  \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443\u00a0<code>Telethon<\/code>. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 Telegram API \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f).  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Telegram API \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f\u00a0<code>api_id<\/code>\u00a0\u0438\u00a0<code>api_hash<\/code>.<\/p>\n<ol>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u00a0<a href=\"http:\/\/my.telegram.org\" rel=\"noopener noreferrer nofollow\">my.telegram.org<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0439\u0434\u0438\u0442\u0435 \u0432 \u0441\u0432\u043e\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 Telegram.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 &#171;API development tools&#187;.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (\u043b\u044e\u0431\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442).<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435\u00a0<code>App api_id<\/code>\u00a0\u0438\u00a0<code>App api_hash<\/code>. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0438\u0445.<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a Google Drive \u0438 Telegram<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import os from google.colab import drive  drive.mount('\/content\/drive')  session_path = '\/content\/drive\/MyDrive\/telethon_sessions\/'  os.makedirs(session_path, exist_ok=True)  session_name = 'my_telegram_session'  session_file_path = os.path.join(session_path, session_name)  print(f\"\u0424\u0430\u0439\u043b \u0441\u0435\u0441\u0441\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u043f\u043e \u043f\u0443\u0442\u0438: {session_file_path}.session\")<\/code><\/pre>\n<pre><code class=\"python\">!pip install telethon  from telethon.sync import TelegramClient from telethon.tl.types import Channel  # !!! \u0417\u0410\u041c\u0415\u041d\u0418\u0422\u0415 \u041d\u0410 \u0412\u0410\u0428\u0418 API ID \u0438 API Hash !!!  api_id = 0 api_hash = ''  client = TelegramClient(session_file_path, api_id, api_hash)  try: \u00a0\u00a0\u00a0 await client.start() except Exception as e: \u00a0\u00a0\u00a0 if not client.is_user_authorized(): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 phone_number = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 (\u0441 \u043a\u043e\u0434\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 +79XXXXXXXXX): ') \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 await client.start(phone=phone_number)          print(f\"\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430 \u043a\u0430\u043a: {(await client.get_me()).first_name} {(await client.get_me()).last_name}\")  # client.disconnect() # \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u043e\u0432 \u043c\u043d\u043e\u0433\u043e \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0432 \u0444\u0430\u0439\u043b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u0438\u043c\u0438\u0442 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<pre><code class=\"python\">import json  async def get_channel_posts_text(channel_identifier): \u00a0\u00a0\u00a0 posts_text = [] \u00a0\u00a0\u00a0 try: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 entity = await client.get_entity(channel_identifier)  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if not isinstance(entity, (Channel)): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return []  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 async for message in client.iter_messages(entity, limit=None): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if message.text: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 posts_text.append(message.text)  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print(f\"\u0412\u0441\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e {len(posts_text)} \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u0430 '{entity.title}'.\") \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0          return posts_text  \u00a0\u00a0\u00a0 except Exception as e: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return []  channel_username = '@m0rtymerr_channel' parsed_posts = await get_channel_posts_text(channel_username)   if parsed_posts: \u00a0\u00a0\u00a0 safe_channel_name = channel_username.replace('@', '') \u00a0\u00a0\u00a0 output_file_name = f\"{safe_channel_name}_posts.json\" \u00a0\u00a0\u00a0 output_file_path = os.path.join(session_path, output_file_name)     with open(output_file_path, 'w', encoding='utf-8') as f: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 json.dump(parsed_posts, f, ensure_ascii=False, indent=4)<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u043a\u043e\u0434 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">!pip install numpy==1.26.4 'pandas&lt;1.8' # \u041f\u0415\u0420\u0415\u0417\u0410\u041f\u0423\u0421\u0422\u0418\u0422\u042c  import pandas as pd import re import numpy as np from matplotlib import pyplot as plt  channel_username = '@m0rtymerr_channel' safe_channel_name = channel_username.replace('@', '') output_file_name = f\"{safe_channel_name}_posts.json\" output_file_path = os.path.join(session_path, output_file_name)  df=pd.read_json(output_file_path) df.rename(columns={0:'text'}, inplace = True ) df.head()<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e <em>\u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 <\/em>\u044d\u0442\u0430\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0443. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0434\u0437\u0438, \u0446\u0438\u0444\u0440, \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0430\u043d\u0433\u043b\u0438\u0446\u0438\u0437\u043c\u044b<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e. \u0412\u043c\u0435\u0441\u0442\u0435 \u043e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p><strong>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f <\/strong>\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438. \u0422\u043e\u043a\u0435\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0444\u0440\u0430\u0437\u0430\u043c\u0438 \u0438\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u042d\u0442\u043e\u0442 \u0448\u0430\u0433 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f <\/strong>\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432 \u043a \u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 (\u043b\u0435\u043c\u043c\u0435). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u043e\u0432\u0430 &#171;\u0431\u0435\u0433\u0443&#187;, &#171;\u0431\u0435\u0436\u0438\u0442&#187; \u0438 &#171;\u0431\u0435\u0433\u0430\u043b&#187; \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a \u043b\u0435\u043c\u043c\u0435 &#171;\u0431\u0435\u0436\u0430\u0442\u044c&#187;. \u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u043b\u043e\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u043e\u0442 \u0438 \u0434\u043e<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/summary>\n<div class=\"spoiler__content\">\n<h4>\u041d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/h4>\n<pre><code class=\"python\">df[\"tokens\"] = df.text.apply(str.lower)<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0434\u0436\u0438<\/h4>\n<pre><code class=\"python\">!pip install emoji  import emoji df['tokens'] = df['tokens'].apply(lambda s: emoji.replace_emoji(s, ''))<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440<\/h4>\n<pre><code class=\"python\">df['tokens'] = df['tokens'].apply(lambda s: re.sub(r\"\\d+\", \"\", s, flags=re.UNICODE))<\/code><\/pre>\n<h4>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<pre><code class=\"python\">!pip install razdel  from razdel import tokenize def get_tokens(sentence):   return [_.text.strip() for _ in tokenize(sentence)]  df[\"tokens\"] = df.tokens.apply(get_tokens)<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0443\u043d\u043a\u0442\u0443\u0430\u0446\u0438\u0438<\/h4>\n<pre><code class=\"python\">import string  df[\"tokens\"] = df.tokens.apply(lambda row: [token for token in row if token not in string.punctuation + string.digits + '...'+'\u2014'+'\u00bb'+'\u00ab'+\"\u2013\" + '**' + '\u2043' + '=)'+'\u2022'+'-']) df[\"tokens\"] = df[\"tokens\"].apply(lambda row: [token for token in row if not re.match(r'^-+$', token)])<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0445 \u0441\u043b\u043e\u0432<\/h4>\n<pre><code class=\"python\">df['tokens'] = df['tokens'].apply( lambda row: [ token for token in row if token == \"it\" or not re.search(r\"[a-zA-Z]+\", token)])<\/code><\/pre>\n<h4>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<pre><code class=\"python\">!pip install pymorphy3 pymorphy3-dicts-ru pymorphy2  import pymorphy2 from tqdm.notebook import tqdm  # \u043d\u0443... \u0431\u044b\u0432\u0430\u0435\u0442 def pymorphy2_311_hotfix():     from inspect import getfullargspec     from pymorphy2.units.base import BaseAnalyzerUnit      def _get_param_names_311(klass):         if klass.__init__ is object.__init__:             return []         args = getfullargspec(klass.__init__).args         return sorted(args[1:])      setattr(BaseAnalyzerUnit, '_get_param_names', _get_param_names_311)  pymorphy2_311_hotfix() analyzer = pymorphy2.MorphAnalyzer()  df[\"tokens\"] = tqdm(df.tokens.apply(lambda row: [analyzer.parse(token)[0].normal_form for token in row if token]))<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043f \u0441\u043b\u043e\u0432<\/h4>\n<pre><code class=\"python\">import nltk from nltk.corpus import stopwords  nltk.download('stopwords') nltk.download('punkt')  additional_stops=[\"\u044d\u0442\u043e\", \"\u043a\u043e\u0442\u043e\u0440\u044b\u0439\", \"\u043d\u0430\u0448\", \"\u043c\u043e\u0447\u044c\", \"\u0433\u043e\u0434\",\"\u0442\u0430\u043a\u043e\u0439\", \"\u043c\u044b\", \"\u0441\u0432\u043e\u0439\", \"\u043e\u0434\u0438\u043d\", \"\u0434\u0440\u0443\u0433\u043e\u0439\", \"\u0447\u0435\u043b\u043e\u0432\u0435\u043a\", \"\u0432\u0441\u0451\", \"\u0432\u0441\u0435\", \"\u0432\u0435\u0441\u044c\", \"\u043e\u0447\u0435\u043d\u044c\", \"\u043a\u0430\u0436\u0434\u044b\u0439\", \"\u0434\u0435\u043d\u044c\", \"\u0435\u0451\", \"\u0432\u0430\u0448\", \"\u0432\u0430\u0448\u0435\", \"\u0434\u0435\u043d\u044c\", \"\u0441\u0430\u043c\u044b\u0439\", \"\u0435\u0449\u0451\",\"\u0442\u0430\u043a\u0436\u0435\", \"\u043d\u0443\u0436\u043d\u043e\",\"\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\", \"\u0432\u0435\u0449\u044c\", \"\u0445\u043e\u0440\u043e\u0448\u0438\u0439\", '\u043d\u043e\u0432\u044b\u0439', \"\u0441\u043f\u0430\u0441\u0438\u0431\u043e\", '\u0442\u0432\u043e\u0439', '\u043b\u044e\u0431\u043e\u0439','\u0447\u0442\u043e-\u0442\u043e','\u0447\u0435','\u043a\u0430\u043a\u043e\u0439-\u0442\u043e','\u043a\u0430\u043a\u043e\u0439-\u0442\u043e', '\u043f\u0440\u0438\u0432\u0435\u0442', '\u0447\u0430\u0441', '\u043c\u0435\u0441\u044f\u0446','\u043d\u0435\u0434\u0435\u043b\u044f','\u0441\u0435\u0433\u043e\u0434\u043d\u044f'] om_stops=['\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e', '\u043e\u043c', '\u0430\u043d\u0442\u043e\u043d','\u043d\u0430\u0437\u0430\u0440\u043e\u0432'] stops = list(string.ascii_lowercase) + list('\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u044f') + stopwords.words(\"russian\") + om_stops + additional_stops  df[\"tokens\"] = df.tokens.apply(lambda row: [token for token in row if token not in stops])<\/code><\/pre>\n<h4>\u0414\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<pre><code class=\"python\">all_words = [] for doc in df.tokens.tolist():   all_words.extend(doc)<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0422\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0422\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 NLP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445, \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u044c\u0438, \u0431\u043b\u043e\u0433\u0438, \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0414\u0438\u0440\u0438\u0445\u043b\u0435 (LDA). \u042d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u0441\u043c\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0435\u043c, \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0435\u043c\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0432. LDA \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0435\u043c\u044b \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445, \u043d\u043e \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043c. \u0411\u0443\u0434\u0435\u043c \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u043f\u043e\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043c, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u0430.<\/p>\n<\/div>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import gensim.corpora as corpora from gensim.models import LdaMulticore, CoherenceModel from tqdm import tqdm import warnings import matplotlib.pyplot as plt  id2word = corpora.Dictionary(df.tokens.tolist()) texts = df.tokens.tolist() corpus = [id2word.doc2bow(text) for text in texts]  warnings.filterwarnings(\"ignore\")  def compute_coherence_values(dictionary, corpus, texts, limit, start=2, step=3):     coherence_values = []     model_list = []     for num_topics in tqdm(range(start, limit, step)):         model=LdaMulticore(corpus=corpus,id2word=dictionary, num_topics=num_topics)         model_list.append(model)         coherencemodel = CoherenceModel(model=model, texts=texts,<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-462815","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=462815"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462815\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=462815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=462815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=462815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}