{"id":367709,"date":"2024-05-21T03:26:49","date_gmt":"2024-05-21T03:26:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=367709"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=367709","title":{"rendered":"<span>\u041f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0432 80 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 Python<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/374\/438\/b7a\/374438b7a30ad7aad20ebff7ca293e41.png\" width=\"1880\" height=\"938\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/374\/438\/b7a\/374438b7a30ad7aad20ebff7ca293e41.png\"\/><\/figure>\n<p>\u0412 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u0435 \u044f \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0441\u0430\u0435\u043d\u0442\u0438\u0441\u0442\u0430 \u0438 \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0438\u0445 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <a href=\"https:\/\/solr.apache.org\/\" rel=\"noopener noreferrer nofollow\">Solr<\/a> \u2014 \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/lucene.apache.org\/\" rel=\"noopener noreferrer nofollow\">Lucene<\/a>. \u042f \u0437\u043d\u0430\u043b \u043e\u0441\u043d\u043e\u0432\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430, \u043d\u043e \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0437\u0430\u043a\u0430\u0442\u0430\u043b \u0440\u0443\u043a\u0430\u0432\u0430 \u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0446\u0435\u043b\u044f\u0445. \u0421\u043b\u044b\u0448\u0430\u043b\u0438 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e \u00ab\u043a\u0440\u0438\u0437\u0438\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u043e\u0432\u00bb? \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c. \u0447\u0442\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u044b \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u043c\u043e\u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Google \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430. \u041a\u0430\u043a\u043e\u0432\u0430 \u0436\u0435 \u043c\u043e\u044f \u043c\u0438\u0441\u0441\u0438\u044f? \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u0440\u043e\u0448\u0435\u0447\u043d\u044b\u0435 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0435\u043b\u0438\u043a\u0438\u043c\u0438. \u042f \u0432\u0435\u0440\u044e \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u043b\u0430\u0432\u044b \u044d\u0442\u0438\u0445 \u043c\u0430\u043b\u044b\u0448\u0435\u0439 \u0432\u0434\u0430\u043b\u0438 \u043e\u0442 SEO-\u0431\u0435\u0437\u0443\u043c\u0438\u044f Google.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 Python. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0432\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043c\u043e\u0451\u043c GitHub (<a href=\"https:\/\/github.com\/alexmolas\/microsearch\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 microsearch<\/a>). \u042d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0442\u0432\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c, \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043f\u043e\u0441\u0442\u0430 \u044f \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0440\u0435\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b. \u0414\u0430, \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 80 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 Python, \u043d\u043e \u044f \u0435\u0449\u0451 \u0438 \u043f\u0438\u0441\u0430\u043b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 (\u043a\u0440\u0430\u0443\u043b\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, API, HTML-\u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u043c \u0434\u0432\u0438\u0436\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043c\u0435\u043d\u0435\u0435 \u0447\u0435\u043c 80 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>P.S. \u041d\u0430\u043f\u0438\u0441\u0430\u0432 \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u0438 <code>microsearch<\/code>, \u044f \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 <a href=\"https:\/\/github.com\/bartdegoede\/python-searchengine\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435<\/a>\u00a0\u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0411\u0430\u0440\u0442 \u0434\u0435 \u0413\u0451\u0434\u0435. \u041c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0411\u0430\u0440\u0442\u0430, \u043d\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0447\u0442\u043e \u043a\u043e\u0435-\u0447\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043b, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438: (1) \u043c\u043e\u0439 \u043a\u0440\u0430\u0443\u043b\u0435\u0440 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, (2) \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c.<\/p>\n<h2>microsearch<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 <code>microsearch<\/code>, \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u0438\u0437\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442: (1) \u043a\u0440\u0430\u0443\u043b\u0435\u0440, (2) \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, (3) \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, (4) \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432 \u043c\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439.<\/p>\n<h3>\u041a\u0440\u0430\u0443\u043b\u0435\u0440<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433 \u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 <a href=\"https:\/\/developers.google.com\/search\/docs\/crawling-indexing\/overview-google-crawlers\" rel=\"noopener noreferrer nofollow\">Google<\/a>), \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 Wallapop \u0438 \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0435 \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0438\/\u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u044b).<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043c\u043e\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u00ab\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e Google\u00bb, \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u043b\u043e\u0433\u043e\u0432, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u043e\u0433\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0442\u043e\u0432 \u0431\u043b\u043e\u0433\u043e\u0432 \u0441 RSS. [\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u0433, \u043d\u043e \u043d\u0435\u0442 RSS-\u0444\u0438\u0434\u0430, \u0442\u043e \u043f\u0440\u0435\u0440\u0432\u0438\u0442\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e. \u042f \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u043f\u0438\u0448\u0443\u0441\u044c \u043d\u0430 \u0432\u0430\u0448 \u0431\u043b\u043e\u0433 \u0438 \u0431\u0443\u0434\u0443 \u0447\u0438\u0442\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 Google \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438.] \u0410 \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0435\u0433\u043e, \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Python <code>asyncio<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433\u0430 \u0441 20 \u043c\u0438\u043d\u0443\u0442 \u0434\u043e 20 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<p>\u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 642 RSS-\u0444\u0438\u0434\u043e\u0432. \u0418\u0437 \u044d\u0442\u0438\u0445 \u0444\u0438\u0434\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u0442\u043e \u044f \u0447\u0438\u0442\u0430\u043b (\u0431\u043b\u043e\u0433\u0438 \u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438, data science, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u044f\u0442\u044c\u0441\u043e\u0442 \u044f \u0441\u043e\u0441\u043a\u0440\u0435\u0439\u043f\u0438\u043b \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/surprisetalk\/blogs.hn\" rel=\"noopener noreferrer nofollow\">surprisetalk blogs.hn<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u0440\u0430\u0443\u043b\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import argparse import aiohttp import asyncio import feedparser import pandas as pd from bs4 import BeautifulSoup import logging  logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__)   def parse_feed(feed_url):     try:         feed = feedparser.parse(feed_url)         return [entry.link for entry in feed.entries]     except Exception as e:         print(f\"Error parsing feed {feed_url}: {e}\")         return []   async def fetch_content(session, url):     async with session.get(url) as response:         return await response.text()   async def process_feed(feed_url, session, loop):     try:         post_urls = await loop.run_in_executor(None, parse_feed, feed_url)         tasks = [fetch_content(session, post_url) for post_url in post_urls]         post_contents = await asyncio.gather(*tasks)         cleaned_contents = [clean_content(content) for content in post_contents]         return list(zip(post_urls, cleaned_contents))     except Exception as e:         print(f\"Error processing feed {feed_url}: {e}\")         return []   def clean_content(html_content):     soup = BeautifulSoup(html_content, \"html.parser\")     for script in soup([\"script\", \"style\"]):         script.extract()     text = soup.get_text()     lines = (line.strip() for line in text.splitlines())     chunks = (phrase.strip() for line in lines for phrase in line.split(\"  \"))     cleaned_text = \" \".join(chunk for chunk in chunks if chunk)     return cleaned_text   def parse_args():     parser = argparse.ArgumentParser()     parser.add_argument(\"--feed-path\")     return parser.parse_args()   async def main(feed_file):     async with aiohttp.ClientSession() as session:         loop = asyncio.get_event_loop()         with open(feed_file, \"r\") as file:             feed_urls = [line.strip() for line in file]          tasks = [process_feed(feed_url, session, loop) for feed_url in feed_urls]         results = await asyncio.gather(*tasks)      flattened_results = [item for sublist in results for item in sublist]     df = pd.DataFrame(flattened_results, columns=[\"URL\", \"content\"])     df.to_parquet(\"output.parquet\", index=False)   if __name__ == \"__main__\":     args = parse_args()     asyncio.run(main(args.feed_path))<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441<\/h3>\n<p>\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u043c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <code>defaultdict<\/code>\u00a0\u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 <code>dict[str, dict[str, int]]<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c, \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0435 \u0434\u043b\u044f \u0441\u043b\u043e\u0432\u0430 (<code>str<\/code>) \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 URL (<code>str<\/code>) \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0432 URL (<code>int<\/code>). \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 URL \u0432 <code>0<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0432 URL, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u043e\u043b\u044c.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>SearchEngine<\/code>. \u041c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u0432\u0443\u043c\u044f \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c\u0438.<\/p>\n<pre><code class=\"python\">class SearchEngine:     def __init__(self):         self._index: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))         self._documents: dict[str, str] = {}<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>index<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 URL \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 (\u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0443\u043d\u043a\u0442\u0443\u0430\u0446\u0438\u044e, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0432\u0441\u0451 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<pre><code class=\"python\">def index(self, url: str, content: str) -> None:     self._documents[url] = content     words = normalize_string(content).split(\" \")     for word in words:         self._index[word][url] += 1<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e \u043e\u0431\u0449\u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a URL \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0438\u0445.<\/p>\n<pre><code class=\"python\">def bulk_index(self, documents: list[tuple[str, str]]):     for url, content in documents:         self.index(url, content)<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>get_url<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0433\u043e \u0432\u0441\u0435 URL, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u044d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<pre><code class=\"python\">def get_urls(self, keyword: str) -> dict[str, int]:     keyword = normalize_string(keyword)     return self._index[keyword]<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 <code>Foo<\/code>\u00a0\u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c <code>Hello, World! My name is Foo!<\/code> \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 <code>Bar<\/code>\u00a0\u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c <code>Hello, World! My name is Bar, I'm not Foo!<\/code>\u00a0\u0441 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0441\u043b\u043e\u0432\u0430 <code>Foo<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"python\">>>> from microsearch.engine import engine >>> engine.index(\"Foo\", \"Hello, World! My name is Foo!\") >>> engine.index(\"Bar\", \"Hello, World! My name is Bar, I'm not Foo!\") >>> engine.get_urls(\"foo\") defaultdict(&lt;class 'int'>, {'Foo': 1, 'Bar': 1}) >>> engine.get_urls(\"Foo\") defaultdict(&lt;class 'int'>, {'Foo': 1, 'Bar': 1})<\/code><\/pre>\n<h3>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/PageRank\" rel=\"noopener noreferrer nofollow\">PageRank<\/a> Google, \u0440\u0430\u043d\u0436\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0441\u044b\u043b\u043e\u043a. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Okapi_BM25\" rel=\"noopener noreferrer nofollow\">BM25<\/a>, \u0440\u0430\u043d\u0436\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u042f \u0440\u0435\u0448\u0438\u043b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c BM25. \u0412\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043e\u0446\u0435\u043d\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c <strong><em>Q<\/em><\/strong> \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043c <strong><em>D<\/em><\/strong> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{i=1}^n \\text{IDF}(q_i) \\frac{f(q_i, D)\\times(k_1 + 1)}{f(q_i, D) + k_1 \\left(1 - b + b \\frac{|D|}{\\text{avgdl}}\\right)}\" alt=\"\\sum_{i=1}^n \\text{IDF}(q_i) \\frac{f(q_i, D)\\times(k_1 + 1)}{f(q_i, D) + k_1 \\left(1 - b + b \\frac{|D|}{\\text{avgdl}}\\right)}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/362\/8b7\/b08\/3628b7b08fa4dd38a5cf18eff5eadf48.svg\" width=\"349\" height=\"68\"\/><\/p>\n<p>\u0433\u0434\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 <strong><em>Q<\/em><\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <strong><em>q<sub>1<\/sub><\/em><\/strong>,\u00a0<strong><em>q<sub>2<\/sub><\/em><\/strong>, \u2026,\u00a0<strong><em>q<\/em><\/strong><em><sub>n<\/sub><\/em>, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 <strong><em>D<\/em><\/strong>\u00a0\u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 |<strong><em>D<\/em><\/strong>|, \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043a\u0430\u043a <strong><em>avgdl<\/em><\/strong>,\u00a0<strong><em>k<sub>1<\/sub><\/em><\/strong>\u00a0\u0438 <strong><em>b<\/em><\/strong>\u00a0\u2014 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b,\u00a0<strong><em>f(q<sub>i<\/sub>, D)<\/em><\/strong>\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <strong><em>q<sub>i<\/sub><\/em><\/strong>\u00a0\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 <strong><em>D<\/em><\/strong> \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, <strong><em>IDF(q<sub>i<\/sub>)<\/em><\/strong>\u00a0\u2014 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u0430\u044f \u0442\u0430\u043a:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\text{IDF}(q_i) = \\ln \\left(1 + \\frac{N - n(q_i) + 0.5}{ n(q_i) + 0.5}\\right)\" alt=\"\\text{IDF}(q_i) = \\ln \\left(1 + \\frac{N - n(q_i) + 0.5}{ n(q_i) + 0.5}\\right)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/389\/a66\/f1b\/389a66f1b23a602fe61b78fda24039ca.svg\" width=\"306\" height=\"50\"\/><\/p>\n<p>\u0433\u0434\u0435 <strong><em>N<\/em><\/strong>\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 <strong><em>n(q<sub>i<\/sub>)<\/em><\/strong>\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 <strong><em>q<sub>i<\/sub><\/em><\/strong>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <strong><em>IDF<\/em><\/strong>, \u043d\u043e \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 <code>SearchEngine<\/code>. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b <strong><em>k<sub>1<\/sub><\/em><\/strong>\u00a0\u0438 <strong><em>d<\/em><\/strong>\u00a0\u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"python\">class SearchEngine:     def __init__(self, k1: float = 1.5, b: float = 0.75):         self._index: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))         self._documents: dict[str, str] = {}         self.k1 = k1         self.b = b<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0440\u0430\u0441\u043a\u0440\u043e\u0435\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435:<\/p>\n<pre><code class=\"python\">@property def posts(self) -> list[str]:     return list(self._documents.keys())  @property def number_of_documents(self) -> int:     return len(self._documents)  @property def avdl(self) -> float:      return sum(len(d) for d in self._documents.values()) \/ len(self._documents)<\/code><\/pre>\n<p>\u0418\u043c\u0435\u044f \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0446\u0435\u043d\u043e\u043a BM25. \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\">def idf(self, kw: str) -> float:     N = self.number_of_documents     n_kw = len(self.get_urls(kw))     return log((N - n_kw + 0.5) \/ (n_kw + 0.5) + 1)<\/code><\/pre>\n<p>\u0418 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0446\u0435\u043d\u043e\u043a BM. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0432\u0441\u0435\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u044d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e URL \u0441 \u0438\u0445 \u043e\u0446\u0435\u043d\u043a\u043e\u0439.<\/p>\n<pre><code class=\"python\">def bm25(self, kw: str) -> dict[str, float]:     result = {}     idf_score = self.idf(kw)     avdl = self.avdl     for url, freq in self.get_urls(kw).items():         numerator = freq * (self.k1 + 1)         denominator = freq + self.k1 * (1 - self.b + self.b * len(self._documents[url]) \/ avdl)         result[url] = idf_score * numerator \/ denominator     return result<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043e\u0446\u0435\u043d\u043a\u0443 BM25 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430. \u0418\u043c\u0435\u044f \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>search<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u043c\u0443 \u0434\u0432\u0438\u0436\u043a\u0443.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>search<\/code>\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0435\u0433\u043e, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c), \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043e\u0446\u0435\u043d\u043a\u0438 BM25 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c URL \u0441 \u0438\u0445 \u043e\u0431\u0449\u0435\u0439 \u043e\u0446\u0435\u043d\u043a\u043e\u0439.<\/p>\n<pre><code class=\"python\">def search(self, query: str) -> dict[str, float]:     keywords = normalize_string(query).split(\" \")     url_scores: dict[str, float] = {}     for kw in keywords:         kw_urls_score = self.bm25(kw)         url_scores = update_url_scores(url_scores, kw_urls_score)     return url_scores<\/code><\/pre>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0432\u0437\u044f\u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">>>> from microsearch.engine import engine >>> engine.index(\"Foo\", \"Hello, World! My name is Foo!\") >>> engine.index(\"Bar\", \"Hello, World! My name is Bar, I'm not Foo!\") >>> engine.search(\"foo\") {'Foo': 0.19869271730423296, 'Bar': 0.16844281759753774} >>> engine.search(\"foo bar\") {'Foo': 0.19869271730423296, 'Bar': 0.8088260293054897}<\/code><\/pre>\n<p>\u0421\u043e\u0435\u0434\u0438\u043d\u0438\u0432 \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0435\u043d\u0435\u0435 \u0447\u0435\u043c 80 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u0432 80 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from collections import defaultdict from math import log import string   def update_url_scores(old: dict[str, float], new: dict[str, float]):     for url, score in new.items():         if url in old:             old[url] += score         else:             old[url] = score     return old  def normalize_string(input_string: str) -> str:     translation_table = str.maketrans(string.punctuation, ' ' * len(string.punctuation))     string_without_punc = input_string.translate(translation_table)     string_without_double_spaces = ' '.join(string_without_punc.split())     return string_without_double_spaces.lower()   class SearchEngine:     def __init__(self, k1: float = 1.5, b: float = 0.75):         self._index: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))         self._documents: dict[str, str] = {}         self.k1 = k1         self.b = b      @property     def posts(self) -> list[str]:         return list(self._documents.keys())      @property     def number_of_documents(self) -> int:         return len(self._documents)      @property     def avdl(self) -> float:         # todo: refactor this. it can be slow to compute it every time. compute it once and cache it         return sum(len(d) for d in self._documents.values()) \/ len(self._documents)      def idf(self, kw: str) -> float:         N = self.number_of_documents         n_kw = len(self.get_urls(kw))         return log((N - n_kw + 0.5) \/ (n_kw + 0.5) + 1)      def bm25(self, kw: str) -> dict[str, float]:         result = {}         idf_score = self.idf(kw)         avdl = self.avdl         for url, freq in self.get_urls(kw).items():             numerator = freq * (self.k1 + 1)             denominator = freq + self.k1 * (                 1 - self.b + self.b * len(self._documents[url]) \/ avdl             )             result[url] = idf_score * numerator \/ denominator         return result      def search(self, query: str) -> dict[str, float]:         keywords = normalize_string(query).split(\" \")         url_scores: dict[str, float] = {}         for kw in keywords:             kw_urls_score = self.bm25(kw)             url_scores = update_url_scores(url_scores, kw_urls_score)         return url_scores      def index(self, url: str, content: str) -> None:         self._documents[url] = content         words = normalize_string(content).split(\" \")         for word in words:             self._index[word][url] += 1      def bulk_index(self, documents: list[tuple[str, str]]):         for url, content in documents:             self.index(url, content)      def get_urls(self, keyword: str) -> dict[str, int]:         keyword = normalize_string(keyword)         return self._index[keyword]<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a, \u043d\u043e \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c. \u042f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 FastAPI, \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u044f\u0449\u0435\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435, \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0445\u043d\u0438\u0435 N URL.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 FastAPI<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import argparse from fastapi import FastAPI, Form, Path, Request from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates import pandas as pd from uvicorn import run  from microsearch.engine import SearchEngine   app = FastAPI() engine = SearchEngine() templates = Jinja2Templates(directory=\"templates\") app.mount(\"\/static\", StaticFiles(directory=\"static\"), name=\"static\")   def get_top_urls(scores_dict: dict, n: int):     sorted_urls = sorted(scores_dict.items(), key=lambda x: x[1], reverse=True)     top_n_urls = sorted_urls[:n]     top_n_dict = dict(top_n_urls)     return top_n_dict   @app.get(\"\/\", response_class=HTMLResponse) async def search(request: Request):     posts = engine.posts     return templates.TemplateResponse(         \"search.html\", {\"request\": request, \"posts\": posts}     )   @app.get(\"\/results\/{query}\", response_class=HTMLResponse) async def search_results(request: Request, query: str = Path(...)):     results = engine.search(query)     results = get_top_urls(results, n=5)     return templates.TemplateResponse(         \"results.html\", {\"request\": request, \"results\": results, \"query\": query}     )   @app.get(\"\/about\") def read_about(request: Request):     return templates.TemplateResponse(\"about.html\", {\"request\": request})   def parse_args():     parser = argparse.ArgumentParser()     parser.add_argument(\"--data-path\")     return parser.parse_args()   if __name__ == \"__main__\":     args = parse_args()     data = pd.read_parquet(args.data_path)     content = list(zip(data[\"URL\"].values, data[\"content\"].values))     engine.bulk_index(content)     run(app, host=\"127.0.0.1\", port=8000)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e25\/e28\/46c\/e25e2846c01c0451786a9da69d66e065.png\" alt=\"Search Engine interface.\" title=\"\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430\" width=\"2298\" height=\"980\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e25\/e28\/46c\/e25e2846c01c0451786a9da69d66e065.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c <code>how to build a search engine?<\/code><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/73f\/6f8\/0b9\/73f6f80b9ed11bad7aa221cb6885a4cb.png\" alt=\"Search results for the query `how to build a search engine`.\" title=\"\u041f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 &quot;how to build a search engine&quot;.\" width=\"1880\" height=\"938\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/73f\/6f8\/0b9\/73f6f80b9ed11bad7aa221cb6885a4cb.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 &#171;how to build a search engine&#187;.<\/figcaption><\/div>\n<\/figure>\n<p>\u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 UI, \u0438 \u0447\u0442\u043e UX \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u0432\u0438\u0436\u043e\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432\u044b\u0434\u0430\u0451\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435, \u044f \u0441\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u043b \u0435\u0433\u043e \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c, \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c\u0438 \u0434\u0432\u0438\u0436\u043a\u0430\u043c\u0438, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0451\u0442. \u0412\u043e\u0442 \u043d\u0435\u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<ul>\n<li>\n<p>\u0423 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0442 <strong>\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0437\u0430\u0433\u0443\u0433\u043b\u0438\u0442\u044c <code>how to build a search engine -solr<\/code>, \u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0441\u043b\u043e\u0432\u043e <code>solr<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 n-\u0433\u0440\u0430\u043c\u043c<\/strong>. Google \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a <code>\"search engine\"<\/code>\u00a0(\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0434\u0432\u043e\u0439\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438), \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u0438 \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0442 <strong>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u043b\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c <code>engine<\/code>, \u0442\u043e \u0432\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e \u0441\u043b\u043e\u0432\u043e\u043c <code>engines<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 <strong>\u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433\u0430 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430<\/strong>, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0438\u0436\u043e\u043a \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c. \u042d\u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u044d\u0442\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c. \u041e\u043d \u043f\u043e\u043c\u043e\u0433 \u043c\u043d\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 Solr, \u0438 \u0445\u043e\u0442\u044f \u043c\u043d\u0435 \u043c\u043d\u043e\u0433\u043e\u043c\u0443 \u0435\u0449\u0451 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044f \u0442\u0430\u043a\u0436\u0435 \u0443\u0437\u043d\u0430\u043b, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u2014 \u044d\u0442\u043e \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434. \u041c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0440\u0430\u0443\u043b\u0435\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e, \u0430 \u043f\u0440\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0437\u0430 \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u043c\u043e\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. \u042f \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u043e\u0432 \u0438 ANN, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0432 microsearch \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/p>\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\/792452\/\"> https:\/\/habr.com\/ru\/articles\/792452\/<\/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<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u0435 \u044f \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0441\u0430\u0435\u043d\u0442\u0438\u0441\u0442\u0430 \u0438 \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0438\u0445 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <a href=\"https:\/\/solr.apache.org\/\" rel=\"noopener noreferrer nofollow\">Solr<\/a> \u2014 \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/lucene.apache.org\/\" rel=\"noopener noreferrer nofollow\">Lucene<\/a>. \u042f \u0437\u043d\u0430\u043b \u043e\u0441\u043d\u043e\u0432\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430, \u043d\u043e \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0437\u0430\u043a\u0430\u0442\u0430\u043b \u0440\u0443\u043a\u0430\u0432\u0430 \u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0446\u0435\u043b\u044f\u0445. \u0421\u043b\u044b\u0448\u0430\u043b\u0438 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e \u00ab\u043a\u0440\u0438\u0437\u0438\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u043e\u0432\u00bb? \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c. \u0447\u0442\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u044b \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u043c\u043e\u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Google \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430. \u041a\u0430\u043a\u043e\u0432\u0430 \u0436\u0435 \u043c\u043e\u044f \u043c\u0438\u0441\u0441\u0438\u044f? \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u0440\u043e\u0448\u0435\u0447\u043d\u044b\u0435 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0435\u043b\u0438\u043a\u0438\u043c\u0438. \u042f \u0432\u0435\u0440\u044e \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u043b\u0430\u0432\u044b \u044d\u0442\u0438\u0445 \u043c\u0430\u043b\u044b\u0448\u0435\u0439 \u0432\u0434\u0430\u043b\u0438 \u043e\u0442 SEO-\u0431\u0435\u0437\u0443\u043c\u0438\u044f Google.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 Python. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0432\u0435\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043c\u043e\u0451\u043c GitHub (<a href=\"https:\/\/github.com\/alexmolas\/microsearch\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 microsearch<\/a>). \u042d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0442\u0432\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c, \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043f\u043e\u0441\u0442\u0430 \u044f \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0440\u0435\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b. \u0414\u0430, \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 80 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 Python, \u043d\u043e \u044f \u0435\u0449\u0451 \u0438 \u043f\u0438\u0441\u0430\u043b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 (\u043a\u0440\u0430\u0443\u043b\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, API, HTML-\u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u043c \u0434\u0432\u0438\u0436\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043c\u0435\u043d\u0435\u0435 \u0447\u0435\u043c 80 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>P.S. \u041d\u0430\u043f\u0438\u0441\u0430\u0432 \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u0438 <code>microsearch<\/code>, \u044f \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 <a href=\"https:\/\/github.com\/bartdegoede\/python-searchengine\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435<\/a>\u00a0\u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0411\u0430\u0440\u0442 \u0434\u0435 \u0413\u0451\u0434\u0435. \u041c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0411\u0430\u0440\u0442\u0430, \u043d\u043e \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0447\u0442\u043e \u043a\u043e\u0435-\u0447\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043b, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438: (1) \u043c\u043e\u0439 \u043a\u0440\u0430\u0443\u043b\u0435\u0440 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, (2) \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c.<\/p>\n<h2>microsearch<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 <code>microsearch<\/code>, \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u0438\u0437\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442: (1) \u043a\u0440\u0430\u0443\u043b\u0435\u0440, (2) \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, (3) \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, (4) \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432 \u043c\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439.<\/p>\n<h3>\u041a\u0440\u0430\u0443\u043b\u0435\u0440<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433 \u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 <a href=\"https:\/\/developers.google.com\/search\/docs\/crawling-indexing\/overview-google-crawlers\" rel=\"noopener noreferrer nofollow\">Google<\/a>), \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 Wallapop \u0438 \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0435 \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0438\/\u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u044b).<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043c\u043e\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u00ab\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e Google\u00bb, \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u043b\u043e\u0433\u043e\u0432, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0431\u043b\u043e\u0433\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0442\u043e\u0432 \u0431\u043b\u043e\u0433\u043e\u0432 \u0441 RSS. [\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u0433, \u043d\u043e \u043d\u0435\u0442 RSS-\u0444\u0438\u0434\u0430, \u0442\u043e \u043f\u0440\u0435\u0440\u0432\u0438\u0442\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e. \u042f \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u043f\u0438\u0448\u0443\u0441\u044c \u043d\u0430 \u0432\u0430\u0448 \u0431\u043b\u043e\u0433 \u0438 \u0431\u0443\u0434\u0443 \u0447\u0438\u0442\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 Google \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438.] \u0410 \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0435\u0433\u043e, \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Python <code>asyncio<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043a\u0440\u0430\u0443\u043b\u0438\u043d\u0433\u0430 \u0441 20 \u043c\u0438\u043d\u0443\u0442 \u0434\u043e 20 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<p>\u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 642 RSS-\u0444\u0438\u0434\u043e\u0432. \u0418\u0437 \u044d\u0442\u0438\u0445 \u0444\u0438\u0434\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u0442\u043e \u044f \u0447\u0438\u0442\u0430\u043b (\u0431\u043b\u043e\u0433\u0438 \u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438, data science, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u044f\u0442\u044c\u0441\u043e\u0442 \u044f \u0441\u043e\u0441\u043a\u0440\u0435\u0439\u043f\u0438\u043b \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/surprisetalk\/blogs.hn\" rel=\"noopener noreferrer nofollow\">surprisetalk blogs.hn<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u0440\u0430\u0443\u043b\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import argparse import aiohttp import asyncio import feedparser import pandas as pd from bs4 import BeautifulSoup import logging  logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__)   def parse_feed(feed_url):     try:         feed = feedparser.parse(feed_url)         return [entry.link for entry in feed.entries]     except Exception as e:         print(f\"Error parsing feed {feed_url}: {e}\")         return []   async def fetch_content(session, url):     async with session.get(url) as response:         return await response.text()   async def process_feed(feed_url, session, loop):     try:         post_urls = await loop.run_in_executor(None, parse_feed, feed_url)         tasks = [fetch_content(session, post_url) for post_url in post_urls]         post_contents = await asyncio.gather(*tasks)         cleaned_contents = [clean_content(content) for content in post_contents]         return list(zip(post_urls, cleaned_contents))     except Exception as e:         print(f\"Error processing feed {feed_url}: {e}\")         return []   def clean_content(html_content):     soup = BeautifulSoup(html_content, \"html.parser\")     for script in soup([\"script\", \"style\"]):         script.extract()     text = soup.get_text()     lines = (line.strip() for line in text.splitlines())     chunks = (phrase.strip() for line in lines for phrase in line.split(\"  \"))     cleaned_text = \" \".join(chunk for chunk in chunks if chunk)     return cleaned_text   def parse_args():     parser = argparse.ArgumentParser()     parser.add_argument(\"--feed-path\")     return parser.parse_args()   async def main(feed_file):     async with aiohttp.ClientSession() as session:         loop = asyncio.get_event_loop()         with open(feed_file, \"r\") as file:             feed_urls = [line.strip() for line in file]          tasks = [process_feed(feed_url, session, loop) for feed_url in feed_urls]         results = await asyncio.gather(*tasks)      flattened_results = [item for sublist in results for item in sublist]     df = pd.DataFrame(flattened_results, columns=[\"URL\", \"content\"])     df.to_parquet(\"output.parquet\", index=False)   if __name__ == \"__main__\":     args = parse_args()     asyncio.run(main(args.feed_path))<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441<\/h3>\n<p>\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u043c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <code>defaultdict<\/code>\u00a0\u0441 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 <code>dict[str, dict[str, int]]<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c, \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0435 \u0434\u043b\u044f \u0441\u043b\u043e\u0432\u0430 (<code>str<\/code>) \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 URL (<code>str<\/code>) \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0432 URL (<code>int<\/code>). \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 URL \u0432 <code>0<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0432 URL, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u043e\u043b\u044c.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>SearchEngine<\/code>. \u041c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u0432\u0443\u043c\u044f \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c\u0438.<\/p>\n<pre><code class=\"python\">class SearchEngine:     def __init__(self):         self._index: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))         self._documents: dict[str, str] = {}<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>index<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 URL \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 (\u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0443\u043d\u043a\u0442\u0443\u0430\u0446\u0438\u044e, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0432\u0441\u0451 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<pre><code class=\"python\">def index(self, url: str, content: str) -> None:     self._documents[url] = content     words = normalize_string(content).split(\" \")     for word in words:         self._index[word][url] += 1<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e \u043e\u0431\u0449\u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a URL \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0438\u0445.<\/p>\n<pre><code class=\"python\">def bulk_index(self, documents: list[tuple[str, str]]):     for url, content in documents:         self.index(url, content)<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>get_url<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0433\u043e \u0432\u0441\u0435 URL, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u044d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<pre><code class=\"python\">def get_urls(self, keyword: str) -> dict[str, int]:     keyword = normalize_string(keyword)     return self._index[keyword]<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 <code>Foo<\/code>\u00a0\u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c <code>Hello, World! My name is Foo!<\/code> \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 <code>Bar<\/code>\u00a0\u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c <code>Hello, World! My name is Bar, I'm not Foo!<\/code>\u00a0\u0441 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0441\u043b\u043e\u0432\u0430 <code>Foo<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"python\">>>> from microsearch.engine import engine >>> engine.index(\"Foo\", \"Hello, World! My name is Foo!\") >>> engine.index(\"Bar\", \"Hello, World! My name is Bar, I'm not Foo!\") >>> engine.get_urls(\"foo\") defaultdict(&lt;class 'int'>, {'Foo': 1, 'Bar': 1}) >>> engine.get_urls(\"Foo\") defaultdict(&lt;class 'int'>, {'Foo': 1, 'Bar': 1})<\/code><\/pre>\n<h3>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/PageRank\" rel=\"noopener noreferrer nofollow\">PageRank<\/a> Google, \u0440\u0430\u043d\u0436\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0441\u044b\u043b\u043e\u043a. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Okapi_BM25\" rel=\"noopener noreferrer nofollow\">BM25<\/a>, \u0440\u0430\u043d\u0436\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u042f \u0440\u0435\u0448\u0438\u043b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c BM25. \u0412\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043e\u0446\u0435\u043d\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c <strong><em>Q<\/em><\/strong> \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043c <strong><em>D<\/em><\/strong> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>\u0433\u0434\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 <strong><em>Q<\/em><\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <strong><em>q<sub>1<\/sub><\/em><\/strong>,\u00a0<strong><em>q<sub>2<\/sub><\/em><\/strong>, \u2026,\u00a0<strong><em>q<\/em><\/strong><em><sub>n<\/sub><\/em>, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 <strong><em>D<\/em><\/strong>\u00a0\u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 |<strong><em>D<\/em><\/strong>|, \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0434\u043b\u0438\u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043a\u0430\u043a <strong><em>avgdl<\/em><\/strong>,\u00a0<strong><em>k<sub>1<\/sub><\/em><\/strong>\u00a0\u0438 <strong><em>b<\/em><\/strong>\u00a0\u2014 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b,\u00a0<strong><em>f(q<sub>i<\/sub>, D)<\/em><\/strong>\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <strong><em>q<sub>i<\/sub><\/em><\/strong>\u00a0\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 <strong><em>D<\/em><\/strong> \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, <strong><em>IDF(q<sub>i<\/sub>)<\/em><\/strong>\u00a0\u2014 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u0430\u044f \u0442\u0430\u043a:<\/p>\n<p>\u0433\u0434\u0435 <strong><em>N<\/em><\/strong>\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 <strong><em>n(q<sub>i<\/sub>)<\/em><\/strong>\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 <strong><em>q<sub>i<\/sub><\/em><\/strong>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <strong><em>IDF<\/em><\/strong>, \u043d\u043e \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 <code>SearchEngine<\/code>. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b <strong><em>k<sub>1<\/sub><\/em><\/strong>\u00a0\u0438 <strong><em>d<\/em><\/strong>\u00a0\u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"python\">class SearchEngine:     def __init__(self, k1: float = 1.5, b: float = 0.75):         self._index: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))         self._documents: dict[str, str] = {}         self.k1 = k1         self.b = b<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0440\u0430\u0441\u043a\u0440\u043e\u0435\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435:<\/p>\n<pre><code class=\"python\">@property def posts(self) -> list[str]:     return list(self._documents.keys())  @property def number_of_documents(self) -> int:     return len(self._documents)  @property def avdl(self) -> float:      return sum(len(d) for d in self._documents.values()) \/ len(self._documents)<\/code><\/pre>\n<p>\u0418\u043c\u0435\u044f \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0446\u0435\u043d\u043e\u043a BM25. \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\">def idf(self, kw: str) -> float:     N = self.number_of_documents     n_kw = len(self.get_urls(kw))     return log((N -<\/code><\/pre>\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-367709","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/367709","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=367709"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/367709\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=367709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=367709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=367709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}