{"id":373899,"date":"2024-05-21T05:47:11","date_gmt":"2024-05-21T05:47:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=373899"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=373899","title":{"rendered":"<span>\u041f\u044f\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u0445 NLP \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043d\u0430 Python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u044f\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Python, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 NLP. \u041e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u0434\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<h2>Natasha<\/h2>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Natasha \u0438\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044e, \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u043e\u043a\u0435\u043d\u044b \u0432 Natasha \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Razdel:<\/p>\n<pre><code class=\"python\">from razdel import tokenize, sentenize text = \"\u0422\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430.\" tokens = list(tokenize(text)) sents = list(sentenize(text))<\/code><\/pre>\n<p>\u041c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 Natasha, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 Slovnet, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0431\u043e\u0433\u0430\u0442\u0443\u044e \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u043e\u043a\u0435\u043d\u0435, \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0447\u0438, \u0440\u043e\u0434, \u0447\u0438\u0441\u043b\u043e \u0438 \u043f\u0430\u0434\u0435\u0436:<\/p>\n<pre><code class=\"python\">from natasha import MorphVocab, Doc  morph_vocab = MorphVocab() doc = Doc(text) doc.segment(segmenter) doc.tag_morph(morph_tagger)  for token in doc.tokens:     print(token.text, token.pos, token.feats)<\/code><\/pre>\n<p>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Natasha \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Pymorphy \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432 \u043a \u0438\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435:<\/p>\n<pre><code class=\"python\">for token in doc.tokens:     token.lemmatize(morph_vocab)     print(token.text, token.lemma)<\/code><\/pre>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 Natasha \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 Slovnet \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">doc.parse_syntax(syntax_parser) for sent in doc.sents:     sent.syntax.print()<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u0430, \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">doc.tag_ner(ner_tagger) for span in doc.spans:     print(span.text, span.type)<\/code><\/pre>\n<h2>DeepPavlov   <\/h2>\n<p>DeepPavlov \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 NLP, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0431\u0430\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 BERT.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 DeepPavlov \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, Python API, REST API \u0438 \u0434\u0430\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 Docker.<\/p>\n<p>DeepPavlov \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GPU.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p><strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0439<\/strong> \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u0432\u043e\u0434\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0447\u0430\u0442-\u0431\u043e\u0442\u0430. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">from deeppavlov import build_model, configs  # \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0439 intent_model = build_model(configs.classifiers.intents_snips, download=True)  # \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 intent_predictions = intent_model(['Book a flight from New York to San Francisco']) print(intent_predictions)<\/code><\/pre>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435:<\/p>\n<pre><code class=\"python\">ner_model = build_model(configs.ner.ner_ontonotes_bert_mult, download=True)  # \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 ner_results = ner_model(['John works at Disney in California']) print(ner_results)<\/code><\/pre>\n<p><strong>\u041c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435:<\/p>\n<pre><code class=\"python\">qa_model = build_model(configs.squad.squad_bert, download=True)  # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438\u0437 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 qa_result = qa_model([\"What is the capital of France?\", \"The capital of France is Paris.\"]) print(qa_result)<\/code><\/pre>\n<h2>mystem \u0438 pymorphy2<\/h2>\n<p><strong>MyStem<\/strong> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043e\u0442 \u042f\u043d\u0434\u0435\u043a\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c (Windows, Linux, MacOS). MyStem \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0441\u043b\u043e\u0432\u0430 \u0438 \u0435\u0433\u043e \u0433\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437:  <\/p>\n<pre><code class=\"python\">from pymystem3 import Mystem  m = Mystem() text = \"\u041c\u0430\u043c\u0430 \u043c\u044b\u043b\u0430 \u0440\u0430\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0435\u0447\u0435\u0440 \u043f\u0435\u0440\u0435\u0434 \u0441\u043d\u043e\u043c.\" lemmas = m.lemmatize(text) print(''.join(lemmas))  analyzed = m.analyze(text) for word_info in analyzed:     if 'analysis' in word_info and word_info['analysis']:         gr = word_info['analysis'][0]['gr']         print(f\"{word_info['text']} - {gr}\")<\/code><\/pre>\n<p><strong>PyMorphy2<\/strong> \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u043d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 MyStem, PyMorphy2 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0438 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 <a href=\"https:\/\/opencorpora.org\/\">OpenCorpora <\/a>\u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u0438 \u0443\u043a\u0440\u0430\u0438\u043d\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c. PyMorphy2 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 API.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0440\u0435\u0447\u0438 \u0438 \u0444\u043e\u0440\u043c \u0441\u043b\u043e\u0432\u0430:<\/p>\n<pre><code class=\"python\">import pymorphy2  morph = pymorphy2.MorphAnalyzer() word = '\u0441\u0442\u0430\u043b\u0438' parsed_word = morph.parse(word)[0] print(f\"\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430: {parsed_word.normal_form}\") print(f\"\u0427\u0430\u0441\u0442\u044c \u0440\u0435\u0447\u0438: {parsed_word.tag.POS}\") print(f\"\u041f\u043e\u043b\u043d\u043e\u0435 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435: {parsed_word.tag}\")<\/code><\/pre>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c:<\/p>\n<pre><code class=\"python\">word = '\u043a\u043d\u0438\u0433\u0430' parsed_word = morph.parse(word)[0] plural = parsed_word.make_agree_with_number(5).word print(f\"\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043b\u043e\u0432\u0430 '{word}': {plural}\")<\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0430\u0434\u0435\u0436\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">word = '\u0433\u043e\u0440\u043e\u0434' parsed_word = morph.parse(word)[0] for case in ['nomn', 'gent', 'datv', 'accs', 'ablt', 'loct']:     form = parsed_word.inflect({case}).word     print(f\"{case}: {form}\")<\/code><\/pre>\n<h4>\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u044d\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430<\/p>\n<\/th>\n<th>\n<p>MyStem<\/p>\n<\/th>\n<th>\n<p>PyMorphy2<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u043a\u0440\u044b\u0442\u044b\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u041e\u0421<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">Windows, Linux, MacOS<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u042f\u0437\u044b\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421++ (\u043e\u0431\u0435\u0440\u0442\u043a\u0430 Python)<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u044f<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">MIT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u044f\u0437\u044b\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e \u0440\u0443\u0441\u0441\u043a\u0438\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u0438 \u0443\u043a\u0440\u0430\u0438\u043d\u0441\u043a\u0438\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c MyStem<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>RuBERT<\/h2>\n<p>RuBERT \u043e\u0442 DeepPavlov \u2014 \u044d\u0442\u043e \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b BERT, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430. \u041c\u043e\u0434\u0435\u043b\u044c \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u043c \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u0443\u044e \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044e \u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. RuBERT \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e BERT-base \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f RuBERT, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u0435\u043a\u0441\u0442 \u043a \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0442\u0437\u044b\u0432\u0443:<\/p>\n<pre><code class=\"python\">from transformers import BertTokenizer, BertForSequenceClassification from torch.nn.functional import softmax  # \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 tokenizer = BertTokenizer.from_pretrained('DeepPavlov\/rubert-base-cased') model = BertForSequenceClassification.from_pretrained('DeepPavlov\/rubert-base-cased', num_labels=2)  # \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 text = \"\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0431\u044b\u043b \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c!\"  # \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 inputs = tokenizer(text, return_tensors=\"pt\", padding=True, truncation=True, max_length=512)  # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 outputs = model(**inputs) predictions = softmax(outputs.logits, dim=-1)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Conversational RuBERT, \u043e\u0431\u0443\u0447\u0438\u0432 \u0435\u0433\u043e \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 NER:<\/p>\n<pre><code class=\"python\">from transformers import BertTokenizer, BertForTokenClassification import torch  tokenizer = BertTokenizer.from_pretrained('DeepPavlov\/rubert-base-cased-conversational') model = BertForTokenClassification.from_pretrained('DeepPavlov\/rubert-base-cased-conversational', num_labels=9)  # \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c 9 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439  text = \"\u0410\u043d\u043d\u0430 \u043f\u043e\u0435\u0445\u0430\u043b\u0430 \u0432 \u041c\u043e\u0441\u043a\u0432\u0443 \u043d\u0430 \u0432\u044b\u0441\u0442\u0430\u0432\u043a\u0443.\"  inputs = tokenizer(text, return_tensors=\"pt\", padding=True, truncation=True, max_length=512)  # \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 with torch.no_grad():     outputs = model(**inputs) predictions = torch.argmax(outputs.logits, dim=-1)  # \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438 tokens = tokenizer.convert_ids_to_tokens(inputs['input_ids'][0]) for token, prediction in zip(tokens, predictions[0]):     print(f\"{token} - {model.config.id2label[prediction.item()]}\")<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c:<\/p>\n<p><strong>MyStem<\/strong>:<br \/>&#8212; <a href=\"https:\/\/yandex.ru\/dev\/mystem\/\">MyStem \u043d\u0430 GitHub<\/a><\/p>\n<p><strong>PyMorphy2<\/strong>:<br \/>&#8212; <a href=\"https:\/\/github.com\/kmike\/pymorphy2\">PyMorphy2 \u043d\u0430 GitHub<\/a><\/p>\n<p><strong>RuBERT \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 DeepPavlov<\/strong>:<br \/>&#8212; <a href=\"https:\/\/huggingface.co\/DeepPavlov\/rubert-base-cased\">RuBERT \u043d\u0430 Hugging Face<\/a><br \/>&#8212; <a href=\"https:\/\/huggingface.co\/DeepPavlov\/rubert-base-cased-conversational\">Conversational RuBERT \u043d\u0430 Hugging Face<\/a><br \/>&#8212; <a href=\"https:\/\/github.com\/deeppavlov\/DeepPavlov\">DeepPavlov \u043d\u0430 GitHub<\/a><\/p>\n<hr\/>\n<p>\u041f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 NLP, \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/otus.pw\/Nfrd\/\">\u043d\u0430 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0435<\/a> \u043e\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043e\u0432-\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/808435\/\"> https:\/\/habr.com\/ru\/articles\/808435\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u044f\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Python, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 NLP. \u041e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u0434\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<h2>Natasha<\/h2>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Natasha \u0438\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044e, \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437, \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u043e\u043a\u0435\u043d\u044b \u0432 Natasha \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Razdel:<\/p>\n<pre><code class=\"python\">from razdel import tokenize, sentenize text = \"\u0422\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430.\" tokens = list(tokenize(text)) sents = list(sentenize(text))<\/code><\/pre>\n<p>\u041c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 Natasha, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 Slovnet, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0431\u043e\u0433\u0430\u0442\u0443\u044e \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u043e\u043a\u0435\u043d\u0435, \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0447\u0438, \u0440\u043e\u0434, \u0447\u0438\u0441\u043b\u043e \u0438 \u043f\u0430\u0434\u0435\u0436:<\/p>\n<pre><code class=\"python\">from natasha import MorphVocab, Doc  morph_vocab = MorphVocab() doc = Doc(text) doc.segment(segmenter) doc.tag_morph(morph_tagger)  for token in doc.tokens:     print(token.text, token.pos, token.feats)<\/code><\/pre>\n<p>\u041b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Natasha \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Pymorphy \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432 \u043a \u0438\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435:<\/p>\n<pre><code class=\"python\">for token in doc.tokens:     token.lemmatize(morph_vocab)     print(token.text, token.lemma)<\/code><\/pre>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 Natasha \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 Slovnet \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">doc.parse_syntax(syntax_parser) for sent in doc.sents:     sent.syntax.print()<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u0430, \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">doc.tag_ner(ner_tagger) for span in doc.spans:     print(span.text, span.type)<\/code><\/pre>\n<h2>DeepPavlov   <\/h2>\n<p>DeepPavlov \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 NLP, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0431\u0430\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 BERT.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 DeepPavlov \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, Python API, REST API \u0438 \u0434\u0430\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 Docker.<\/p>\n<p>DeepPavlov \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GPU.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p><strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0439<\/strong> \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u0432\u043e\u0434\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0447\u0430\u0442-\u0431\u043e\u0442\u0430. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">from deeppavlov import build_model, configs  # \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0439 intent_model = build_model(configs.classifiers.intents_snips, download=True)  # \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 intent_predictions = intent_model(['Book a flight from New York to San Francisco']) print(intent_predictions)<\/code><\/pre>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435:<\/p>\n<pre><code class=\"python\">ner_model = build_model(configs.ner.ner_ontonotes_bert_mult, download=True)  # \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 ner_results = ner_model(['John works at Disney in California']) print(ner_results)<\/code><\/pre>\n<p><strong>\u041c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435:<\/p>\n<pre><code class=\"python\">qa_model = build_model(configs.squad.squad_bert, download=True)  # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438\u0437 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 qa_result = qa_model([\"What is the capital of France?\", \"The capital of France is Paris.\"]) print(qa_result)<\/code><\/pre>\n<h2>mystem \u0438 pymorphy2<\/h2>\n<p><strong>MyStem<\/strong> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043e\u0442 \u042f\u043d\u0434\u0435\u043a\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c (Windows, Linux, MacOS). MyStem \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0441\u043b\u043e\u0432\u0430 \u0438 \u0435\u0433\u043e \u0433\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043b\u0435\u043c\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437:  <\/p>\n<pre><code class=\"python\">from pymystem3 import Mystem  m = Mystem() text = \"\u041c\u0430\u043c\u0430 \u043c\u044b\u043b\u0430 \u0440\u0430\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0435\u0447\u0435\u0440 \u043f\u0435\u0440\u0435\u0434 \u0441\u043d\u043e\u043c.\" lemmas = m.lemmatize(text) print(''.join(lemmas))  analyzed = m.analyze(text) for word_info in analyzed:     if 'analysis' in word_info and word_info['analysis']:         gr = word_info['analysis'][0]['gr']         print(f\"{word_info['text']} - {gr}\")<\/code><\/pre>\n<p><strong>PyMorphy2<\/strong> \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u043d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 MyStem, PyMorphy2 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0438 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 <a href=\"https:\/\/opencorpora.org\/\">OpenCorpora <\/a>\u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u0438 \u0443\u043a\u0440\u0430\u0438\u043d\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c. PyMorphy2 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 API.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0440\u0435\u0447\u0438 \u0438 \u0444\u043e\u0440\u043c \u0441\u043b\u043e\u0432\u0430:<\/p>\n<pre><code class=\"python\">import pymorphy2  morph = pymorphy2.MorphAnalyzer() word = '\u0441\u0442\u0430\u043b\u0438' parsed_word = morph.parse(word)[0] print(f\"\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430: {parsed_word.normal_form}\") print(f\"\u0427\u0430\u0441\u0442\u044c \u0440\u0435\u0447\u0438: {parsed_word.tag.POS}\") print(f\"\u041f\u043e\u043b\u043d\u043e\u0435 \u043c\u043e\u0440\u0444\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435: {parsed_word.tag}\")<\/code><\/pre>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c:<\/p>\n<pre><code class=\"python\">word = '\u043a\u043d\u0438\u0433\u0430' parsed_word = morph.parse(word)[0] plural = parsed_word.make_agree_with_number(5).word print(f\"\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043b\u043e\u0432\u0430 '{word}': {plural}\")<\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0430\u0434\u0435\u0436\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">word = '\u0433\u043e\u0440\u043e\u0434' parsed_word = morph.parse(word)[0] for case in ['nomn', 'gent', 'datv', 'accs', 'ablt', 'loct']:     form = parsed_word.inflect({case}).word     print(f\"{case}: {form}\")<\/code><\/pre>\n<h4>\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u044d\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>\u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430<\/p>\n<\/th>\n<th>\n<p>MyStem<\/p>\n<\/th>\n<th>\n<p>PyMorphy2<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0417\u0430\u043a\u0440\u044b\u0442\u044b\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u041e\u0421<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">Windows, Linux, MacOS<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u042f\u0437\u044b\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421++ (\u043e\u0431\u0435\u0440\u0442\u043a\u0430 Python)<\/p>\n<\/td>\n<td>\n<p align=\"left\">Python<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u044f<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">MIT<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u044f\u0437\u044b\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e \u0440\u0443\u0441\u0441\u043a\u0438\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u0438 \u0443\u043a\u0440\u0430\u0438\u043d\u0441\u043a\u0438\u0439<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u043c MyStem<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>RuBERT<\/h2>\n<p>RuBERT \u043e\u0442 DeepPavlov \u2014 \u044d\u0442\u043e \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b BERT, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430. \u041c\u043e\u0434\u0435\u043b\u044c \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u043c \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u0443\u044e \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044e \u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. RuBERT \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e BERT-base \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f RuBERT, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u0435\u043a\u0441\u0442 \u043a \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0442\u0437\u044b\u0432\u0443:<\/p>\n<pre><code class=\"python\">from transformers import BertTokenizer, BertForSequenceClassification from torch.nn.functional import softmax  # \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 tokenizer = BertTokenizer.from_pretrained('DeepPavlov\/rubert-base-cased') model = BertForSequenceClassification.from_pretrained('DeepPavlov\/rubert-base-cased', num_labels=2)  # \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 text = \"\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u0431\u044b\u043b \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c!\"  # \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 inputs = tokenizer(text, return_tensors=\"pt\", padding=True, truncation=True, max_length=512)  # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 outputs = model(**inputs) predictions = softmax(outputs.logits, dim=-1)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Conversational RuBERT, \u043e\u0431\u0443\u0447\u0438\u0432 \u0435\u0433\u043e \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 NER:<\/p>\n<pre><code class=\"python\">from transformers import BertTokenizer, BertForTokenClassification import torch  tokenizer = BertTokenizer.from_pretrained('DeepPavlov\/rubert-base-cased-conversational') model = BertForTokenClassification.from_pretrained('DeepPavlov\/rubert-base-cased-conversational', num_labels=9)  # \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c 9 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439  text = \"\u0410\u043d\u043d\u0430 \u043f\u043e\u0435\u0445\u0430\u043b\u0430 \u0432 \u041c\u043e\u0441\u043a\u0432\u0443 \u043d\u0430 \u0432\u044b\u0441\u0442\u0430\u0432\u043a\u0443.\"  inputs = tokenizer(text, return_tensors=\"pt\", padding=True, truncation=True, max_length=512)  # \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 with torch.no_grad():     outputs = model(**inputs) predictions = torch.argmax(outputs.logits, dim=-1)  # \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438 tokens = tokenizer.convert_ids_to_tokens(inputs['input_ids'][0]) for token, prediction in zip(tokens, predictions[0]):     print(f\"{token} - {model.config.id2label[prediction.item()]}\")<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c:<\/p>\n<p><strong>MyStem<\/strong>:<br \/>&#8212; <a href=\"https:\/\/yandex.ru\/dev\/mystem\/\">MyStem \u043d\u0430 GitHub<\/a><\/p>\n<p><strong>PyMorphy2<\/strong>:<br \/>&#8212; <a href=\"https:\/\/github.com\/kmike\/pymorphy2\">PyMorphy2 \u043d\u0430 GitHub<\/a><\/p>\n<p><strong>RuBERT \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 DeepPavlov<\/strong>:<br \/>&#8212; <a href=\"https:\/\/huggingface.co\/DeepPavlov\/rubert-base-cased\">RuBERT \u043d\u0430 Hugging Face<\/a><br \/>&#8212; <a href=\"https:\/\/huggingface.co\/DeepPavlov\/rubert-base-cased-conversational\">Conversational RuBERT \u043d\u0430 Hugging Face<\/a><br \/>&#8212; <a href=\"https:\/\/github.com\/deeppavlov\/DeepPavlov\">DeepPavlov \u043d\u0430 GitHub<\/a><\/p>\n<hr\/>\n<p>\u041f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 NLP, \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/otus.pw\/Nfrd\/\">\u043d\u0430 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0435<\/a> \u043e\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043e\u0432-\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/808435\/\"> https:\/\/habr.com\/ru\/articles\/808435\/<\/a><br \/><\/br><\/br><\/p>\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-373899","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373899","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=373899"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373899\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}