{"id":320165,"date":"2021-03-24T09:01:10","date_gmt":"2021-03-24T09:01:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=320165"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=320165","title":{"rendered":"\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0430\u0442-\u0431\u043e\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u043e\u0441\u043e\u0432\/\u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D0%B2%D0%B8%D1%82%D0%B8%D0%B5_%D0%BA%D0%BB%D0%B8%D0%B5%D0%BD%D1%82%D0%B0\" rel=\"noopener noreferrer nofollow\">customer development<\/a> \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0434\u0435\u0439 \u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0437 \u043e \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435. \u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0443 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b &#171;\u043a\u0440\u0451\u0441\u0442\u043d\u044b\u0439 \u043e\u0442\u0435\u0446 \u041a\u0440\u0435\u043c\u043d\u0438\u0435\u0432\u043e\u0439 \u0434\u043e\u043b\u0438\u043d\u044b&#187; <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%91%D0%BB%D0%B0%D0%BD%D0%BA,_%D0%A1%D1%82%D0%B8%D0%B2\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0438\u0432 \u0411\u043b\u0430\u043d\u043a<\/a>.<br \/>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 &#171;\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432&#187; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442\u043e\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043c \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0432\u0438\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u0438\u0447\u0438\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0431\u044a\u0451\u043c\u0443 \u0431\u044e\u0434\u0436\u0435\u0442\u0430 \u0438 \u0438\u043c\u0435\u044e\u0449\u0435\u043c\u0443\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u043e \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0440\u043e\u0441\u043e\u043c. \u041f\u0440\u0438\u0447\u0451\u043c \u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0447\u0430\u0442-\u0431\u043e\u0442\u0430 \u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u044e\u0441\u044c \u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u043e\u0441\u0430. \u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0430\u0442-\u0431\u043e\u0442\u0430 \u0434\u043b\u044f VK \u043f\u0438\u0441\u0430\u043b \u0432 <a href=\"https:\/\/habr.com\/post\/429628\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b: Python, MySQL, API VK \u0438 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442 <a href=\"https:\/\/rusvectores.org\/ru\/about\/\" rel=\"noopener noreferrer nofollow\">RusVectores<\/a>. <\/p>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u043c\u0443 \u0438 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0432 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<blockquote>\n<p><strong>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440<\/strong>. \u041d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u043e\u0432\u043e\u0440\u044e \u043b\u0438\u0448\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e \u0438\u0442\u043e\u0433\u0443 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432. \u041d\u0435 \u0440\u0435\u043a\u043b\u0430\u043c\u0438\u0440\u0443\u044e \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p><a href=\"#neuronet\" rel=\"noopener noreferrer nofollow\">\u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#database\" rel=\"noopener noreferrer nofollow\">\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#algorithm\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442\u0430<\/a><\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"neuronet\" id=\"neuronet\"><\/a><\/p>\n<h2>\u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c<\/h2>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u0444\u0440\u0430\u0437\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#8212; \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0432\u0441\u0435\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435, \u043d\u043e \u044d\u0442\u043e \u0442\u0440\u0443\u0434\u043e\u0451\u043c\u043a\u043e \u0438 \u043d\u0435\u0433\u0438\u0431\u043a\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043b\u043e\u0432.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <a href=\"https:\/\/rusvectores.org\/ru\/about\/\" rel=\"noopener noreferrer nofollow\">RusVectores<\/a>, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u041d\u041a\u0420\u042f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 word2vec CBOW \u0441 \u0434\u043b\u0438\u043d\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 300.<\/p>\n<p><strong>\u041d\u041a\u0420\u042f <\/strong>\u2013 \u044d\u0442\u043e \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, <a href=\"http:\/\/ruscorpora.ru\/\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u041a\u043e\u0440\u043f\u0443\u0441 \u0420\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u042f\u0437\u044b\u043a\u0430<\/a>&nbsp;\u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043e\u0431\u044a\u0451\u043c\u0435. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 270 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0441\u043b\u043e\u0432, \u043e\u0431\u044a\u0451\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f 189 193 \u0441\u043b\u043e\u0432\u0430.<\/p>\n<p><strong>Word2vec CBOW<\/strong> \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u043e \u043d\u0430 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u0422.\u0435. \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u00ab\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443\u00bb \u0441\u043b\u043e\u0432\u0430 \u0432 \u00ab\u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u00bb. CBOW \u2013 \u044d\u0442\u043e \u0430\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440\u0430 Continuous Bag of Words. \u041e\u043d\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0432 word2vec. \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u00ab\u043c\u0435\u0448\u043a\u0430 \u0441\u043b\u043e\u0432\u00bb, \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u043e \u043f\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443. \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 word2vec &#8212; Skip-gram \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0441\u043b\u043e\u0432\u0443.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0441\u043b\u043e\u0432\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0441\u043b\u043e\u0432 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e word2vec \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 &#171;<a href=\"http:\/\/nlpx.net\/archives\/179\" rel=\"noopener noreferrer nofollow\">\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e word2vec: \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0442\u0435\u043e\u0440\u0438\u044f<\/a>&#171;.<\/p>\n<p>\u041e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u043b\u043e\u0432 (\u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0435) \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 &#171;<a href=\"https:\/\/ai-news.ru\/2020\/03\/chto_takoe_embeddingi_i_kak_oni_pomogaut_mashinam_ponimat_teksty.html\" rel=\"noopener noreferrer nofollow\">\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043c\u0430\u0448\u0438\u043d\u0430\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u044b<\/a>&#171;.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u0443\u0433\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u0438\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438. \u0427\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u043a 1 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u0443\u0433\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0441\u043b\u043e\u0432, \u0442\u0435\u043c \u043e\u043d\u0438 \u0431\u043b\u0438\u0436\u0435 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443. \u0415\u0434\u0438\u043d\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u0443\u0433\u043b\u0430 0 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u0442.&nbsp;\u0435. \u043a\u043e\u0433\u0434\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0441\u043b\u043e\u0432 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u0447\u0442\u0438 \u0434\u043b\u044f 200 000 \u0441\u043b\u043e\u0432 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0422.\u043a. \u0443 \u043c\u0435\u043d\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435\u0442, \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u043e\u043d\u043b\u0430\u0439\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c <a href=\"https:\/\/rusvectores.org\/ru\/about\/\" rel=\"noopener noreferrer nofollow\">RusVectores<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"database\" id=\"database\"><\/a><\/p>\n<h2>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u043e\u0441\u0430 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0435\u0451 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 MySQL. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u043d\u0438\u0436\u0435, \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0442\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0433\u0440\u0430\u0444\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ba\/b2c\/69f\/3bab2c69f3e0e5907e14f760d46b0ff8.png\" alt=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432\" title=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432\" width=\"1766\" height=\"1802\"><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432<\/figcaption><\/figure>\n<p>\u0412 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a (\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c35\/d9b\/3c5\/c35d9b3c5570fcb10005a12e93acd34b.PNG\" alt=\"\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438\" title=\"\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438\" width=\"606\" height=\"306\"><figcaption>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438<\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0435 <em>question_num<\/em> \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043e\u0442\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u0443\u0442\u044c \u043e\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e, \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0442\u043e\u0447\u043a\u043e\u0439.<\/p>\n<p><a class=\"anchor\" name=\"algorithm\" id=\"algorithm\"><\/a><\/p>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442\u0430<\/h2>\n<p><strong>\u041d\u0430\u0447\u0430\u043b\u043e \u043e\u043f\u0440\u043e\u0441\u0430<\/strong><\/p>\n<p>\u041f\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u043d \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u0412\u041a \u0438 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0434\u0438\u0430\u043b\u043e\u0433, \u043d\u0430\u0436\u0430\u0432 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u00bb.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5d6\/0a2\/bde\/5d60a2bdeecc8f6f7d00c74137dac472.png\" width=\"942\" height=\"569\"><figcaption><\/figcaption><\/figure>\n<p>\u0411\u043e\u0442 \u0437\u0434\u043e\u0440\u043e\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u043e\u0441. \u0422\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0432\u0430\u043b \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 &#171;\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435&#187;\u2192 &#171;\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f&#187; \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u0412\u041a.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d16\/963\/62d\/d1696362d8d893be3a4ebd14fec7b07f.png\" width=\"1009\" height=\"554\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u0447\u0442\u043e-\u0442\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0441\u043e \u0441\u043b\u043e\u0432\u043e\u043c \u00ab\u0434\u0430\u00bb, \u0442\u043e \u0431\u043e\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b.  \u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0434\u043e\u0431\u0440\u0438\u043b \u0441\u0442\u0430\u0440\u0442 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0443\u0436\u043d\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043b\u043e\u0432 \u043a \u0441\u043b\u043e\u0432\u0430\u043c: \u0434\u0430, \u043c\u043e\u0436\u0435\u043c, \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u0439, \u043e\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"https:\/\/github.com\/akutuzov\/webvectors\/blob\/master\/preprocessing\/rusvectores_tutorial.ipynb\" rel=\"noopener noreferrer nofollow\">API \u0441\u0435\u0440\u0432\u0438\u0441\u0430 RusVectores<\/a>.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u0438\u043b\u0438 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0447\u0430\u0442\u043e, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0437\u0430\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c.<\/p>\n<blockquote>\n<p>\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u0437 bot_methods.py<br \/><sub>\u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u043e\u0442\u0430<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\">def _identify_phrase(user_id, user_message):     \"\"\"     identify start question or greeting     return number of phrase in database     \"\"\"     # identification variable, on start set \"I don't know\"     identi = 'I dont know'     # find in database current position in conversation between user and chatbot     identi = get_current_position_in_conversation(user_id)     if identi != 'err':         # if the conversation has just begun         if identi == '0':             # define greetings             similarity = _get_similarity(user_message, u'\u043f\u0440\u0438\u0432\u0435\u0442 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0434\u043e\u0431\u0440\u044b\u0439')             if similarity &gt; 0.5:                 identi = \"greetings\"             else:                 # define start interview or not                 identi = _start_or_not(user_message)         # if the conversation continues         elif identi == '1':             # define start interview or not             identi = _start_or_not(user_message)         else:             pass                  return identi<\/code><\/pre>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u043e\u0441 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>_start_or_not():<\/em><\/p>\n<pre><code class=\"python\">def _start_or_not(user_message):     \"\"\"     define &lt;identi&gt;: start or don't start interview     \"\"\"     if user_message != '\u0441\u0442\u0430\u0440\u0442' or user_message != '\u0421\u0442\u0430\u0440\u0442':         _identi = 'I dont know'         # define if user agree to start interview         start = _get_similarity(user_message, u'\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0439 \u043e\u043a')         # define if user don't agree to start interview         later = _get_similarity(user_message, u'\u043d\u0435\u0442 \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u0432\u0442\u0440\u0430')         if start &gt; later and start &gt; 0.15:             _identi = 'start'         elif later &gt; start and later &gt; 0.15:             _identi = 'later'     else:         _identi = \"start\"      return _identi<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0448\u0438\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u0438 \u043f\u043e\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>_get_similarity(). <\/em>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"python\">def _get_similarity(text1, text2):     \"\"\"     Function return similarity between text1 and text2     text1 - user message     text2 - key words     \"\"\"     text1.strip()  # delete empty space on start and end of string     text2.strip()     text1_words = text1.split(' ')     text2_words = text2.split(' ')      similarity = 0.0 # init variable     try:         for word1 in text1_words:             if word1 != '':                 for word2 in text2_words:                     if word2 != '':                         # prepare url for request to API rusvectores.org                         # url example https:\/\/rusvectores.org\/ruscorpora_upos_cbow_300_20_2019\/\u0434\u0435\u043b\u043e__\u043f\u0430\u043f\u043a\u0430\/api\/similarity\/                         url = '\/'.join(['https:\/\/rusvectores.org\/ruscorpora_upos_cbow_300_20_2019',                                          word1 + '__' + word2, 'api', 'similarity\/'])                         # GET request to API rusvectores.org                         r = requests.get(url, stream=True)                         # sum similarity of couple of words                         similarity = similarity + float(r.text.split('\\t')[0])     except Exception as e:         log_exception = str(e)      # average similarity     similarity = similarity\/len(text2_words)      # return similarity between text1 and text2     return similarity<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>similarity <\/em>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0444\u0440\u0430\u0437 <em>text1 <\/em>\u0438 <em>text2<\/em>. \u0427\u0435\u043c \u0431\u043b\u0438\u0436\u0435 <em>similarity <\/em>\u043a 1, \u0442\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u0444\u0440\u0430\u0437\u044b \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <em>_identify_phrase()<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 \u0444\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0438\u0448\u0435\u0442 \u0432 \u0447\u0430\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 &#8212; \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0438 \u0441\u0442\u0430\u0440\u0442 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e, \u0442\u0430\u043a \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0432\u0438\u043b\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433. \u0422\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432 \u0431\u0435\u0441\u0435\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>get_current_position_in_conversation()<\/em><\/p>\n<blockquote>\n<p>\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0438\u0437 mysqldb_methods.py<br \/><sub>\u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MySQL \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\">def get_current_position_in_conversation(user_id):     \"\"\"     find in database current position in conversation between user and chatbot     using in bot_methods.py     \"\"\"     try:         conn = MySQLdb.connect(host=HOST, user=USER, passwd=PASSWORD,                                 db=DATABASE, charset='utf8', init_command='SET NAMES UTF8')         cursor = conn.cursor()         query = \"SELECT `question_num` FROM `conversations` WHERE `user_id`=%(user_id)s LIMIT 1\"         cursor.execute(query, {'user_id': user_id})         result = cursor.fetchone()         if result is None:             identi = '0'         else:             identi = result[0]         conn.close()     except Exception as e:         identi = 'err'          return identi<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u0440\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0447\u0430\u0442-\u0431\u043e\u0442\u043e\u043c:<br \/>&#8212; \u0441\u0442\u0430\u0440\u0442 \u043e\u043f\u0440\u043e\u0441\u0430 (\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>_start_or_not()<\/em>),<br \/>&#8212; \u043e\u0431\u043c\u0435\u043d \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0437\u0434\u043e\u0440\u043e\u0432\u0430\u043b\u0441\u044f (\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u043a \u0441\u043b\u043e\u0432\u0430\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>_get_similarity())<\/em>;<br \/>&#8212; \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>get_current_position_in_conversation() <\/em>\u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e.<\/p>\n<p><strong>\u0421\u0442\u043e\u043f-\u0441\u043b\u043e\u0432\u0430<\/strong><\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 &#171;\u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432&#187;, \u0442.\u0435. \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441 \u043b\u0451\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f. \u0412\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435:<\/p>\n<pre><code class=\"python\">stop_words = [ u'\u0430', u'\u0431\u043e\u043b\u044c\u0448\u043e\u0439',u'\u0431\u044b',u'\u0431\u044b\u0442\u044c', u'\u0432',u'\u0432\u0435\u0441\u044c',u'\u0432\u043e\u0442',u'\u0432\u0441\u0435\u0439',u'\u0432\u044b', u'\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c',u'\u0433\u043e\u0434', u'\u0434\u043b\u044f',u'\u0434\u043e', u'\u0435\u0449\u0435',u'\u0435\u0441\u043b\u0438', u'\u0436\u0435', u'\u0437\u043d\u0430\u0442\u044c', u'\u0438',u'\u0438\u0437',u'\u0438\u043b\u0438', u'\u043a',u'\u043a\u0430\u043a',u'\u043a\u043e\u0442\u043e\u0440\u044b\u0439', u'\u043c\u043e\u0447\u044c',u'\u043c\u044b',u'\u043c\u043d\u0435', u'\u043d\u0430',u'\u043d\u0430\u0448',u'\u043d\u0435\u0433\u043e',u'\u043d\u0435\u0435',u'\u043d\u0438\u0445',u'\u043d\u043e', u'\u043e',u'\u043e\u0434\u0438\u043d',u'\u043e\u043d\u0430',u'\u043e\u043d\u0438',u'\u043e\u043d\u043e',u'\u043e\u043d\u044b\u0439',u'\u043e\u0442',u'\u043e\u0442\u043e', u'\u043f\u043e', u'\u0441',u'\u0441\u0432\u043e\u0439',u'\u0441\u0435\u0431\u044f',u'\u0441\u043a\u0430\u0437\u0430\u0442\u044c', u'\u0442\u0430',u'\u0442\u0430\u043a\u043e\u0439',u'\u0442\u0430\u043a\u043e\u0435',u'\u0442\u043e\u043b\u044c\u043a\u043e',u'\u0442\u043e\u0442',u'\u0442\u044b',u'\u0442\u043e', u'\u0443', u'\u0447\u0442\u043e', u'\u044d\u0442\u043e',u'\u044d\u0442\u043e\u0442', u'\u044f' ]  stop_characters = [u'.',u',',u' - ',u'- ',u' -',u':',u';',u'?',u'\u2116',u'!',u'_',u'(', u')',u'=',u'+',u\"#\",u'$',u'@',u'%',u'*',u'   ',u'&lt;',u'&gt;','1','2','3','4','5','6', '7','8','9','0']<\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 _<em>clear_text() <\/em>\u043e\u0447\u0438\u0449\u0430\u044e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432:<\/p>\n<\/p>\n<p><strong>\u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432<\/strong><\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u043a\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043e\u043f\u0440\u043e\u0441\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442\u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <em>_define_conversation_way()<\/em>:<\/p>\n<pre><code class=\"python\">def _define_conversation_way(user_message, identi):     \"\"\"     define in which way we are goin to?     \"\"\"     # all questions, unless \u2116 3 has two ways: 'yes' (positive) or 'no' (negative)     if identi != '3' and identi != '6':         yes = _get_similarity(user_message, u'\u0434\u0430 \u0437\u0430\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0438\u0442\u044c')         no = _get_similarity(user_message, u'\u043d\u0435\u0442 \u043d\u0438\u043a\u043e\u0433\u0434\u0430')     elif identi == '6':         # the question number 6 has different ways: 'delivery' or 'self-delivery'         yes = _get_similarity(user_message, u'\u0437\u0430\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443')         no = _get_similarity(user_message, u'\u0435\u0434\u0443 \u0441\u0430\u043c \u0438\u0449\u0443 \u0430\u043d\u0430\u043b\u043e\u0433')     elif identi == '3':         # the question number 3 has different ways: 'from store' or 'delivery'         yes = _get_similarity(user_message, u'\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0441\u0430\u043c')         no = _get_similarity(user_message, u'\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u043f\u043e\u0447\u0442\u0430 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u0443\u0440\u044c\u0435\u0440 \u0434\u043e\u043c')      if yes &gt; no and yes &gt; 0.15:         _way = 'yes'     elif no &gt; yes and no &gt; 0.15:         _way = 'no'     else:         _way = 'I dont know'      return _way<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>_get_bot_answer()<\/em>. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0438\u0436\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0430 \u043c\u043e\u0434\u0443\u043b\u044c \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0431\u043e\u0442\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c:<\/p>\n<blockquote>\n<p>bot_methods.py<br \/><sub>\u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u043e\u0442\u0430<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\"># -*- coding: utf-8 -*- \"\"\" Bot methods. Realizes all what bot can do. \"3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 API \u0441\u0435\u0440\u0432\u0438\u0441\u0430 RusVectores\" https:\/\/github.com\/akutuzov\/webvectors\/blob\/master\/preprocessing\/rusvectores_tutorial.ipynb \"\"\" import re  # for work with regular expressions import requests  # for using HTTP requests  from bot_config import stop_words from bot_config import stop_characters  from mysqldb_methods import get_current_position_in_conversation from mysqldb_methods import get_question_from_DB from mysqldb_methods import write_current_question_number_for_user   def get_bot_answer(user_id, user_message):     \"\"\"     using in views.py     make answer to user     \"\"\"     answer = ''     # delete stop-words and punctuation characters in sentence     user_message = _clear_text(user_message)     # identify what to do: start or continue conversation     identi = _identify_phrase(user_id, user_message)     if identi == 'greetings':         answer = get_question_from_DB('1')         write_current_question_number_for_user(user_id, '1')     elif identi == 'start':         answer = get_question_from_DB('2')         write_current_question_number_for_user(user_id, '2')     elif identi == 'later':         answer = \"\u041a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0439\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043c\u043d\u0435 '\u0441\u0442\u0430\u0440\u0442'.\"     elif identi == 'I dont know':         answer = \"\u042f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0432\u0430\u0441 \u043f\u043e\u043d\u0438\u043c\u0430\u044e...\\n\u0423\u0442\u043e\u0447\u043d\u0438\u0442\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.\"     elif identi == 'end':         answer = \"\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e!\"     else:         # if top-level question: 1, 2 or 3 etc.         if len(identi) == 1:             # define in which way we are goin to?             way = _define_conversation_way(user_message, identi)             if way == 'yes' or way == 'no':                 if way == 'yes':                     # going to positive way                     question_num = '.'.join([identi,'1','1'])                 if way == 'no':                     # going to negative way                     question_num = '.'.join([identi,'2','1'])                  answer = get_question_from_DB(question_num)                 if answer != 'None':                     write_current_question_number_for_user(user_id, question_num)                 else:                     question_num = str(int(identi) + 1)                     answer = get_question_from_DB(question_num)                     write_current_question_number_for_user(user_id, question_num)             else:                 # if way='I dont know'                 answer = \"\u042f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0432\u0430\u0441 \u043f\u043e\u043d\u0438\u043c\u0430\u044e...\\n\u0423\u0442\u043e\u0447\u043d\u0438\u0442\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.\"         else:             # if subquestion: e.g. identi=2.1.1 or 3.2.2 etc.             identi_numbers = identi.split('.')             next_num = str(int(identi_numbers[2]) + 1)             question_num = '.'.join([identi_numbers[0],identi_numbers[1],next_num])             answer = get_question_from_DB(question_num)             # if we get end of subquestions in this top-level-question             if answer == 'None':                 # going to the next top-level question                 question_num = str(int(identi_numbers[0]) + 1)                 # checking that the question is the last                 if _is_the_last_question(question_num):                     answer = get_question_from_DB(question_num)                     question_num = 'end'                 else:                     # is not the last question                     answer = get_question_from_DB(question_num)                          write_current_question_number_for_user(user_id, question_num)              return answer   def _is_the_last_question(question_num):     \"\"\"     define is the last question?     by the condition (len(identi) == 1) of the function \"get_bot_answer\"     question_num has lenght 1     \"\"\"     is_the_last = True     question_num = str(int(question_num) + 1)     question = get_question_from_DB(question_num)     if question != 'None':         is_the_last = False      return is_the_last   def _define_conversation_way(user_message, identi):     \"\"\"     define in which way we are goin to?     \"\"\"     # all questions, unless \u2116 3 has two ways: 'yes' (positive) or 'no' (negative)     if identi != '3' and identi != '6':         yes = _get_similarity(user_message, u'\u0434\u0430 \u0437\u0430\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0438\u0442\u044c')         no = _get_similarity(user_message, u'\u043d\u0435\u0442 \u043d\u0438\u043a\u043e\u0433\u0434\u0430')     elif identi == '6':         # the question number 6 has different ways: 'delivery' or 'self-delivery'         yes = _get_similarity(user_message, u'\u0437\u0430\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443')         no = _get_similarity(user_message, u'\u0435\u0434\u0443 \u0441\u0430\u043c \u0438\u0449\u0443 \u0430\u043d\u0430\u043b\u043e\u0433')     elif identi == '3':         # the question number 3 has different ways: 'from store' or 'delivery'         yes = _get_similarity(user_message, u'\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0441\u0430\u043c')         no = _get_similarity(user_message, u'\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u043f\u043e\u0447\u0442\u0430 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u0443\u0440\u044c\u0435\u0440 \u0434\u043e\u043c')      if yes &gt; no and yes &gt; 0.15:         _way = 'yes'     elif no &gt; yes and no &gt; 0.15:         _way = 'no'     else:         _way = 'I dont know'      return _way   def _identify_phrase(user_id, user_message):     \"\"\"     identify start question or greeting     return number of phrase in database     \"\"\"     # identification variable, on start set \"I don't know\"     identi = 'I dont know'     # find in database current position in conversation between user and chatbot     identi = get_current_position_in_conversation(user_id)     if identi != 'err':         # if the conversation has just begun         if identi == '0':             # define greetings             similarity = _get_similarity(user_message, u'\u043f\u0440\u0438\u0432\u0435\u0442 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0434\u043e\u0431\u0440\u044b\u0439')             if similarity &gt; 0.5:                 identi = \"greetings\"             else:                 # define start interview or not                 identi = _start_or_not(user_message)         # if the conversation continues         elif identi == '1':             # define start interview or not             identi = _start_or_not(user_message)         else:             pass                  return identi   def _start_or_not(user_message):     \"\"\"     define &lt;identi&gt;: start or don't start interview     \"\"\"     if user_message != '\u0441\u0442\u0430\u0440\u0442' or user_message != '\u0421\u0442\u0430\u0440\u0442':         _identi = 'I dont know'         # define if user agree to start interview         start = _get_similarity(user_message, u'\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0439 \u043e\u043a')         # define if user don't agree to start interview         later = _get_similarity(user_message, u'\u043d\u0435\u0442 \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u0432\u0442\u0440\u0430')         if start &gt; later and start &gt; 0.15:             _identi = 'start'         elif later &gt; start and later &gt; 0.15:             _identi = 'later'     else:         _identi = \"start\"      return _identi   def _clear_text(sentence):     \"\"\"     delete stop-words and punctuation characters in sentence     \"\"\"     try:         # sentence to low-case         sentence = sentence.lower()         # delete stop-characters         for char in stop_characters:             sentence = sentence.replace(char, '')         # delete stop-words         words_of_sentence = sentence.split(' ')         result = ''         for word in words_of_sentence:             if word not in stop_words:                 result = result + ' ' + word      except Exception as e:         result = str(e)      return result   def _get_similarity(text1, text2):     \"\"\"     Function return similarity between text1 and text2     :param text1: user message     :param text2: key words     \"\"\"     text1.strip()  # delete empty space on start and end of string     text2.strip()     text1_words = text1.split(' ')     text2_words = text2.split(' ')      similarity = 0.0 # init variable     try:         for word1 in text1_words:             if word1 != '':                 for word2 in text2_words:                     if word2 != '':                         # prepare url for request to API rusvectores.org                         # url example http:\/\/rusvectores.org\/araneum_none_fasttextcbow_300_5_2018\/\u0434\u0435\u043b\u043e__\u043f\u0430\u043f\u043a\u0430\/api\/similarity\/                         url = '\/'.join(['http:\/\/rusvectores.org\/araneum_none_fasttextcbow_300_5_2018',                                          word1 + '__' + word2, 'api', 'similarity\/'])                         # GET request to API rusvectores.org                         r = requests.get(url, stream=True)                         # sum similarity of couple of words                         similarity = similarity + float(r.text.split('\\t')[0])     except Exception as e:         log_exception = str(e)      # average similarity     similarity = similarity\/len(text2_words)      # return similarity between text1 and text2     return similarity<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>write_current_question_number_for_user()<\/em> \u0431\u043e\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u043e\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043b \u043a\u0430\u043a\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442\u0443. <br \/>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <em>get_question_from_DB()<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u043e\u0442 \u0437\u0430\u0434\u0430\u043b \u0435\u0433\u043e \u0432 \u0447\u0430\u0442\u0435.<\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0434\u0443\u043b\u044f \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<blockquote>\n<p>mysqldb_methods.py<br \/><sub>\u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MySQL \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\"># -*- coding: utf-8 -*- \"\"\" Methods for work with MySQL database. \"\"\" import MySQLdb  # before using it do in ssh: pip install mysqlclient  \"\"\"  import configuration variables for connect to MySQL database: \"\"\" from mysqldb_config import HOST from mysqldb_config import USER from mysqldb_config import PASSWORD from mysqldb_config import DATABASE   def write_current_question_number_for_user(user_id, question_num):     \"\"\"     write question number to database for this user     \"\"\"     try:         conn = MySQLdb.connect(host=HOST, user=USER, passwd=PASSWORD,                                 db=DATABASE, charset='utf8', init_command='SET NAMES UTF8')         cursor = conn.cursor()         if question_num == '2':             query = (                 \"INSERT INTO `conversations`(`user_id`, `question_num`) \"                 \"VALUES (%s, %s)\"             )             data = (user_id, question_num)         else:             query = (                 \"UPDATE `conversations` \"                 \"SET `question_num`=%s \"                 \"WHERE `user_id`=%s \"             )             data = (question_num, user_id)          cursor.execute(query,data)         conn.commit()  # commit transaction         conn.close()     except Exception as e:         exception = str(e)   def get_current_position_in_conversation(user_id):     \"\"\"     find in database current position in conversation between user and chatbot     using in bot_methods.py     \"\"\"     try:         conn = MySQLdb.connect(host=HOST, user=USER, passwd=PASSWORD,                                 db=DATABASE, charset='utf8', init_command='SET NAMES UTF8')         cursor = conn.cursor()         query = \"SELECT `question_num` FROM `conversations` WHERE `user_id`=%(user_id)s LIMIT 1\"         cursor.execute(query, {'user_id': user_id})         result = cursor.fetchone()         if result is None:             identi = '0'         else:             identi = result[0]         conn.close()     except Exception as e:         identi = 'err'          return identi   def get_question_from_DB(question_num):     \"\"\"     return question text from database     \"\"\"     try:         conn = MySQLdb.connect(host=HOST, user=USER, passwd=PASSWORD,                                 db=DATABASE, charset='utf8', init_command='SET NAMES UTF8')         cursor = conn.cursor()         query = \"SELECT `question_text` FROM `questions` WHERE `question_num`=%(num)s LIMIT 1\"         cursor.execute(query, {'num': question_num})         result = cursor.fetchone()         if result is not None:             question_text = result[0]         else:             question_text = \"None\"         conn.close()     except Exception as e:         question_text = str(e)          return question_text<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0437\u044e\u043c\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442\u0430.<\/p>\n<blockquote>\n<p>\u0441\u043a\u0440\u0438\u043f\u0442 views.py<br \/><sub>&#171;\u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430&#187; \u0434\u043b\u044f \u043f\u0440\u0438\u0451\u043c\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0431\u043e\u0442\u0430 \u0432 \u0447\u0430\u0442<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\"># -*- coding: utf-8 -*- from __future__ import unicode_literals  import json import threading  # for async executing tasks with VK API import vk  # vk is library from VK  from django.views.decorators.csrf import csrf_exempt from django.shortcuts import render from django.http import HttpResponse  from bot_config import *  # import token, confirmation_token and over constants from bot_config.py from bot_methods import get_bot_answer   @csrf_exempt  # exempt index() function from built-in Django protection def index(request):  # requested url     if (request.method == \"POST\"):         data = json.loads(request.body)  # take POST request from auto-generated variable &lt;request.body&gt; in json format         if (data['secret'] == secret_key):  # if json request contain secret key and it's equal my secret key             if (data['type'] == 'confirmation'):  # if VK server request confirmation                 \"\"\"                 For confirmation my server (webhook) it must return                 confirmation token, which issuing in administration web-panel                 your public group in vk.com.                 Using &lt;content_type=\"text\/plain\"&gt; in HttpResponse function allows you                 response only plain text, without any format symbols.                 Parameter &lt;status=200&gt; response to VK server as VK want.                 \"\"\"                 # confirmation_token from bot_config.py                 return HttpResponse(confirmation_token,                                      content_type=\"text\/plain\",                                      status=200)             if (data['type'] == 'message_new'):  # if VK server send a message                 # t - is new thread to async execute answer_to_message()                 t = threading.Thread(target=_answer_to_message, args=(data,))                 t.start()                 return HttpResponse('ok', content_type=\"text\/plain\", status=200)     else:         return HttpResponse('see you :)')  # send anser to user message def _answer_to_message(data):     session = vk.Session()     api = vk.API(session, v=5.5)     user_id = data['object']['user_id']     user_message = data['object']['body']     # get bot answer     answer = get_bot_answer(user_id, user_message)     # token from bot_config.py     api.messages.send(access_token = token, user_id = str(user_id), message = answer)<\/code><\/pre>\n<p>\u041e \u0442\u043e\u043c \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445 \u0432 <a href=\"https:\/\/habr.com\/post\/429628\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>.<\/p>\n<h2>\u0423\u0441\u043f\u0435\u0445\u043e\u0432!<\/h2>\n<p>\u0423\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043d\u0430\u0439\u0434\u0451\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043a\u0430\u043a \u0432 \u0446\u0435\u043b\u043e\u043c, \u0442\u0430\u043a \u0438 \u0432 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u0445. <br \/>\u0416\u0435\u043b\u0430\u044e \u0432\u0441\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0443\u0441\u043f\u0435\u0445\u043e\u0432 \u0432 \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438!<\/p>\n<\/div>\n<p> \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\/post\/533098\/\"> https:\/\/habr.com\/ru\/post\/533098\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D0%B2%D0%B8%D1%82%D0%B8%D0%B5_%D0%BA%D0%BB%D0%B8%D0%B5%D0%BD%D1%82%D0%B0\" rel=\"noopener noreferrer nofollow\">customer development<\/a> \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0434\u0435\u0439 \u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0437 \u043e \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435. \u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0443 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b &#171;\u043a\u0440\u0451\u0441\u0442\u043d\u044b\u0439 \u043e\u0442\u0435\u0446 \u041a\u0440\u0435\u043c\u043d\u0438\u0435\u0432\u043e\u0439 \u0434\u043e\u043b\u0438\u043d\u044b&#187; <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%91%D0%BB%D0%B0%D0%BD%D0%BA,_%D0%A1%D1%82%D0%B8%D0%B2\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0438\u0432 \u0411\u043b\u0430\u043d\u043a<\/a>.<br \/>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 &#171;\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432&#187; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442\u043e\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043c \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0432\u0438\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u0438\u0447\u0438\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0431\u044a\u0451\u043c\u0443 \u0431\u044e\u0434\u0436\u0435\u0442\u0430 \u0438 \u0438\u043c\u0435\u044e\u0449\u0435\u043c\u0443\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u043e \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0440\u043e\u0441\u043e\u043c. \u041f\u0440\u0438\u0447\u0451\u043c \u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0447\u0430\u0442-\u0431\u043e\u0442\u0430 \u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0435\u043d\u0442 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u044e\u0441\u044c \u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u043e\u0441\u0430. \u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0430\u0442-\u0431\u043e\u0442\u0430 \u0434\u043b\u044f VK \u043f\u0438\u0441\u0430\u043b \u0432 <a href=\"https:\/\/habr.com\/post\/429628\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b: Python, MySQL, API VK \u0438 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442 <a href=\"https:\/\/rusvectores.org\/ru\/about\/\" rel=\"noopener noreferrer nofollow\">RusVectores<\/a>. <\/p>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u043c\u0443 \u0438 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0432 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<blockquote>\n<p><strong>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440<\/strong>. \u041d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u043e\u0432\u043e\u0440\u044e \u043b\u0438\u0448\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e \u0438\u0442\u043e\u0433\u0443 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432. \u041d\u0435 \u0440\u0435\u043a\u043b\u0430\u043c\u0438\u0440\u0443\u044e \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p><a href=\"#neuronet\" rel=\"noopener noreferrer nofollow\">\u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#database\" rel=\"noopener noreferrer nofollow\">\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#algorithm\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442\u0430<\/a><\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"neuronet\" id=\"neuronet\"><\/a><\/p>\n<h2>\u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c<\/h2>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u0444\u0440\u0430\u0437\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#8212; \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0432\u0441\u0435\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435, \u043d\u043e \u044d\u0442\u043e \u0442\u0440\u0443\u0434\u043e\u0451\u043c\u043a\u043e \u0438 \u043d\u0435\u0433\u0438\u0431\u043a\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u0430 \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043b\u043e\u0432.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <a href=\"https:\/\/rusvectores.org\/ru\/about\/\" rel=\"noopener noreferrer nofollow\">RusVectores<\/a>, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u041d\u041a\u0420\u042f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 word2vec CBOW \u0441 \u0434\u043b\u0438\u043d\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 300.<\/p>\n<p><strong>\u041d\u041a\u0420\u042f <\/strong>\u2013 \u044d\u0442\u043e \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, <a href=\"http:\/\/ruscorpora.ru\/\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u041a\u043e\u0440\u043f\u0443\u0441 \u0420\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u042f\u0437\u044b\u043a\u0430<\/a>&nbsp;\u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043e\u0431\u044a\u0451\u043c\u0435. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 270 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0441\u043b\u043e\u0432, \u043e\u0431\u044a\u0451\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f 189 193 \u0441\u043b\u043e\u0432\u0430.<\/p>\n<p><strong>Word2vec CBOW<\/strong> \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u043e \u043d\u0430 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u0422.\u0435. \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u00ab\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443\u00bb \u0441\u043b\u043e\u0432\u0430 \u0432 \u00ab\u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u00bb. CBOW \u2013 \u044d\u0442\u043e \u0430\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440\u0430 Continuous Bag of Words. \u041e\u043d\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0432 word2vec. \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u00ab\u043c\u0435\u0448\u043a\u0430 \u0441\u043b\u043e\u0432\u00bb, \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u043e \u043f\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443. \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 word2vec &#8212; Skip-gram \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0441\u043b\u043e\u0432\u0443.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0441\u043b\u043e\u0432\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0441\u043b\u043e\u0432 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e word2vec \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 &#171;<a href=\"http:\/\/nlpx.net\/archives\/179\" rel=\"noopener noreferrer nofollow\">\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e word2vec: \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0442\u0435\u043e\u0440\u0438\u044f<\/a>&#171;.<\/p>\n<p>\u041e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u043b\u043e\u0432 (\u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0435) \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 &#171;<a href=\"https:\/\/ai-news.ru\/2020\/03\/chto_takoe_embeddingi_i_kak_oni_pomogaut_mashinam_ponimat_teksty.html\" rel=\"noopener noreferrer nofollow\">\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043c\u0430\u0448\u0438\u043d\u0430\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u044b<\/a>&#171;.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u0443\u0433\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u0438\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438. \u0427\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u043a 1 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u0443\u0433\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0441\u043b\u043e\u0432, \u0442\u0435\u043c \u043e\u043d\u0438 \u0431\u043b\u0438\u0436\u0435 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443. \u0415\u0434\u0438\u043d\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u0443\u0433\u043b\u0430 0 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u0442.&nbsp;\u0435. \u043a\u043e\u0433\u0434\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0441\u043b\u043e\u0432 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u0447\u0442\u0438 \u0434\u043b\u044f 200 000 \u0441\u043b\u043e\u0432 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0422.\u043a. \u0443 \u043c\u0435\u043d\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435\u0442, \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u043e\u043d\u043b\u0430\u0439\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c <a href=\"https:\/\/rusvectores.org\/ru\/about\/\" rel=\"noopener noreferrer nofollow\">RusVectores<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"database\" id=\"database\"><\/a><\/p>\n<h2>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u043e\u0441\u0430 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0435\u0451 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 MySQL. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u043d\u0438\u0436\u0435, \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0442\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0433\u0440\u0430\u0444\u0430.<\/p>\n<figure class=\"full-width\"><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432<\/figcaption><\/figure>\n<p>\u0412 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a (\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442):<\/p>\n<figure class=\"full-width\"><figcaption>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438<\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0435 <em>question_num<\/em> \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043e\u0442\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u0443\u0442\u044c \u043e\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e, \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0442\u043e\u0447\u043a\u043e\u0439.<\/p>\n<p><a class=\"anchor\" name=\"algorithm\" id=\"algorithm\"><\/a><\/p>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0430\u0442-\u0431\u043e\u0442\u0430<\/h2>\n<p><strong>\u041d\u0430\u0447\u0430\u043b\u043e \u043e\u043f\u0440\u043e\u0441\u0430<\/strong><\/p>\n<p>\u041f\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u043d \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u0412\u041a \u0438 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0434\u0438\u0430\u043b\u043e\u0433, \u043d\u0430\u0436\u0430\u0432 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u00bb.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0411\u043e\u0442 \u0437\u0434\u043e\u0440\u043e\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u043e\u0441. \u0422\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0432\u0430\u043b \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 &#171;\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435&#187;\u2192 &#171;\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f&#187; \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u0412\u041a.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u0447\u0442\u043e-\u0442\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0441\u043e \u0441\u043b\u043e\u0432\u043e\u043c \u00ab\u0434\u0430\u00bb, \u0442\u043e \u0431\u043e\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b.  \u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0434\u043e\u0431\u0440\u0438\u043b \u0441\u0442\u0430\u0440\u0442 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0443\u0436\u043d\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043b\u043e\u0432 \u043a \u0441\u043b\u043e\u0432\u0430\u043c: \u0434\u0430, \u043c\u043e\u0436\u0435\u043c, \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u0439, \u043e\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"https:\/\/github.com\/akutuzov\/webvectors\/blob\/master\/preprocessing\/rusvectores_tutorial.ipynb\" rel=\"noopener noreferrer nofollow\">API \u0441\u0435\u0440\u0432\u0438\u0441\u0430 RusVectores<\/a>.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u0438\u043b\u0438 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0447\u0430\u0442\u043e, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0437\u0430\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c.<\/p>\n<blockquote>\n<p>\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u0437 bot_methods.py<br \/><sub>\u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u043e\u0442\u0430<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\">def _identify_phrase(user_id, user_message):     \"\"\"     identify start question or greeting     return number of phrase in database     \"\"\"     # identification variable, on start set \"I don't know\"     identi = 'I dont know'     # find in database current position in conversation between user and chatbot     identi = get_current_position_in_conversation(user_id)     if identi != 'err':         # if the conversation has just begun         if identi == '0':             # define greetings             similarity = _get_similarity(user_message, u'\u043f\u0440\u0438\u0432\u0435\u0442 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0434\u043e\u0431\u0440\u044b\u0439')             if similarity &gt; 0.5:                 identi = \"greetings\"             else:                 # define start interview or not                 identi = _start_or_not(user_message)         # if the conversation continues         elif identi == '1':             # define start interview or not             identi = _start_or_not(user_message)         else:             pass                  return identi<\/code><\/pre>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u043e\u0441 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>_start_or_not():<\/em><\/p>\n<pre><code class=\"python\">def _start_or_not(user_message):     \"\"\"     define &lt;identi&gt;: start or don't start interview     \"\"\"     if user_message != '\u0441\u0442\u0430\u0440\u0442' or user_message != '\u0421\u0442\u0430\u0440\u0442':         _identi = 'I dont know'         # define if user agree to start interview         start = _get_similarity(user_message, u'\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0439 \u043e\u043a')         # define if user don't agree to start interview         later = _get_similarity(user_message, u'\u043d\u0435\u0442 \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u0432\u0442\u0440\u0430')         if start &gt; later and start &gt; 0.15:             _identi = 'start'         elif later &gt; start and later &gt; 0.15:             _identi = 'later'     else:         _identi = \"start\"      return _identi<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0448\u0438\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u0438 \u043f\u043e\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u0443\u044e \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>_get_similarity(). <\/em>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"python\">def _get_similarity(text1, text2):     \"\"\"     Function return similarity between text1 and text2     text1 - user message     text2 - key words     \"\"\"     text1.strip()  # delete empty space on start and end of string     text2.strip()     text1_words = text1.split(' ')     text2_words = text2.split(' ')      similarity = 0.0 # init variable     try:         for word1 in text1_words:             if word1 != '':                 for word2 in text2_words:                     if word2 != '':                         # prepare url for request to API rusvectores.org                         # url example https:\/\/rusvectores.org\/ruscorpora_upos_cbow_300_20_2019\/\u0434\u0435\u043b\u043e__\u043f\u0430\u043f\u043a\u0430\/api\/similarity\/                         url = '\/'.join(['https:\/\/rusvectores.org\/ruscorpora_upos_cbow_300_20_2019',                                          word1 + '__' + word2, 'api', 'similarity\/'])                         # GET request to API rusvectores.org                         r = requests.get(url, stream=True)                         # sum similarity of couple of words                         similarity = similarity + float(r.text.split('\\t')[0])     except Exception as e:         log_exception = str(e)      # average similarity     similarity = similarity\/len(text2_words)      # return similarity between text1 and text2     return similarity<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>similarity <\/em>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u043e\u0439 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0444\u0440\u0430\u0437 <em>text1 <\/em>\u0438 <em>text2<\/em>. \u0427\u0435\u043c \u0431\u043b\u0438\u0436\u0435 <em>similarity <\/em>\u043a 1, \u0442\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u0444\u0440\u0430\u0437\u044b \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <em>_identify_phrase()<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 \u0444\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0438\u0448\u0435\u0442 \u0432 \u0447\u0430\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 &#8212; \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0438 \u0441\u0442\u0430\u0440\u0442 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e, \u0442\u0430\u043a \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0432\u0438\u043b\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433. \u0422\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432 \u0431\u0435\u0441\u0435\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <em>get_current_position_in_conversation()<\/em><\/p>\n<blockquote>\n<p>\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0438\u0437 mysqldb_methods.py<br \/><sub>\u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MySQL \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445<\/sub><\/p>\n<\/blockquote>\n<pre><code class=\"python\">def get_current_position_in_conversation(user_id):     \"\"\"     find in database current position in conversation between user and chatbot     using in bot_methods.py     \"\"\"     try:         conn = MySQLdb.connect(host=HOST, user=USER, passwd=PASSWORD,                                 db=DATABASE, charset='utf8', init_command='SET NAMES UTF8')         cursor = conn.cursor()         query = \"SELECT `question_num` FROM `conversations` WHERE `user_id`=%(user_id)s LIMIT 1\"         cursor.execute(query, {'user_id': user_id})         result = cursor.fetchone()         if result is None:             identi = '0'         else:             identi = result[0]         conn.close()     except Exception as e:         identi = 'err'          return identi<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u0440\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0447\u0430\u0442-\u0431\u043e\u0442\u043e\u043c:<br \/>&#8212; \u0441\u0442\u0430\u0440\u0442 \u043e\u043f\u0440\u043e\u0441\u0430 (\u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>_start_or_not()<\/em>),<br \/>&#8212; \u043e\u0431\u043c\u0435\u043d \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f\u043c\u0438, \u0435\u0441\u043b\u0438<\/br><\/br><\/p>\n<\/blockquote>\n<\/blockquote>\n<p><\/br><\/br><\/p>\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-320165","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320165","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=320165"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320165\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}