{"id":297865,"date":"2020-01-29T09:00:19","date_gmt":"2020-01-29T09:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297865"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297865","title":{"rendered":"\u0410\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 Node.js"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486036\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ib\/_g\/vg\/ib_gvg4f3vdu0wiwjyhrjctmd8g.jpeg\"><\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0422\u0435\u043c\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u043e \u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0445\u043e\u0447\u0443 \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c\u0443 \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u044f\u0441\u044c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c &quot;\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441&quot; \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u0435\u043d\u0442\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \/ \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. \u0410 \u043f\u043e\u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430, \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0421\u043a\u0430\u0439\u043d\u0435\u0442\u0443.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3 id=\"intro\">\u0418\u043d\u0442\u0440\u043e<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430\u0447\u0435\u043c? \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0443\u043c\u043d\u0435\u0435\u043c \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c?<\/p>\n<p>  <\/p>\n<blockquote><p>\u0410\u043d\u0430\u0301\u043b\u0438\u0437 \u0442\u043e\u043d\u0430\u0301\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0301\u043a\u0441\u0442\u0430 (\u0441\u0435\u043d\u0442\u0438\u043c\u0435\u043d\u0442-\u0430\u043d\u0430\u043b\u0438\u0437, \u0430\u043d\u0433\u043b. Sentiment analysis, \u0430\u043d\u0433\u043b. Opinion mining) \u2014 \u043a\u043b\u0430\u0441\u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043d\u0442-\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0439 \u043b\u0438\u043d\u0433\u0432\u0438\u0441\u0442\u0438\u043a\u0435, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445 \u044d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043e\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u043e\u0439 \u043b\u0435\u043a\u0441\u0438\u043a\u0438 \u0438 \u044d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 (\u043c\u043d\u0435\u043d\u0438\u0439) \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0440\u0435\u0447\u044c \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0434\u0451\u0442 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<p>  \u0422\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u044d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0440\u0430 \u0432\u044b\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 (\u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0438\u0440\u0430, \u0441\u043e\u0431\u044b\u0442\u0438\u044e, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0438\u043b\u0438 \u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\/\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c), \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u043e\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u042d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043b\u0435\u043a\u0441\u0435\u043c\u044b \u0438\u043b\u0438 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e (\u0438\u043b\u0438 \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0435\u043d\u0442\u0438\u043c\u0435\u043d\u0442\u043e\u043c). \u0422\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0432 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0443\u043c\u043c\u0443) \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0435\u0433\u043e \u0435\u0434\u0438\u043d\u0438\u0446 (\u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439) \u0438 \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0445 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u044f.<\/p><\/blockquote>\n<p>by wikipedia<\/p>\n<p>  <\/p>\n<h3 id=\"zachem\">\u0417\u0430\u0447\u0435\u043c?<\/h3>\n<p>  <\/p>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0447\u0430\u0441\u0442\u0435\u043d\u044c\u043a\u043e \u043e\u0442 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0447\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u2014 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e &quot;\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430&quot;. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &quot;\u0430 \u043d\u0443 \u0438\u0434\u0438 \u0441\u044e\u0434\u0430 \u043c\u0430\u0442\u044c \u0442\u0432\u043e\u044e&#8230;&quot; \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0443 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f. &quot;\u0414\u043e\u0440\u043e\u0433\u043e\u0439, \u044f \u0434\u043e\u043c\u0430&quot; \u2014 \u0447\u0443\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u043f\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/5s\/xz\/dl\/5sxzdlj-cbh9r3axka1xf0lmcwq.gif\"><\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043c\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439, \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043f\u043e \u043e\u0442\u0437\u044b\u0432\u0430\u043c \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u042f \u0434\u0443\u043c\u0430\u044e \u043e\u0431\u0449\u0430\u044f \u0438\u0434\u0435\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"ustanavlivaem-neobhodimoe\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435<\/h3>\n<p>  <\/p>\n<p>\u0420\u0430\u0437 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Node.js, \u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f Express. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e, Express \u0430\u043b\u044f low level \u0438 \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npm install -g express-generator<\/code><\/pre>\n<p>  <\/p>\n<p><code>[express-generator](https:\/\/expressjs.com\/en\/starter\/generator.html)<\/code> \u2014 \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 <a href=\"https:\/\/reactjs.org\/docs\/create-a-new-react-app.html\">create-react-app<\/a> \u0434\u043b\u044f Express \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 <code>node_nlp<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">express node_nlp --no-view<\/code><\/pre>\n<p>  <\/p>\n<p>\u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0435 \u043f\u0440\u043e\u0448\u043b\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f npx:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npx express-generator node_nlp --no-view<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443, \u043a\u0430\u0447\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">cd node_nlp npm install npm start<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c <code>nodemon<\/code>: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npm install --save nodemon<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u0432 package.json:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">&quot;dev&quot;: &quot;nodemon .\/bin\/www&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npm run dev<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043e\u0445\u0430\u043f\u043a\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430. \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0430\u0447\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043d\u043e\u0440\u043e\u0432\u0438\u0442\u044c \u0431\u044b\u0442\u044c \u0441\u0435\u0442\u0430\u043f\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u044f \u0443\u0436\u0435 \u0437\u0430\u0431\u044b\u043b \u043e \u0447\u0435\u043c \u043f\u0438\u0448\u0443 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u044d\u0442\u0438\u043c\u0438 <code>npm install<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npm install --save natural apos-to-lex-form spelling-corrector stopword<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yd\/q5\/6y\/ydq56yhahqjyit4dpuqgntr0s2i.png\"><\/p>\n<p>  <\/p>\n<h3 id=\"routing\">\u0420\u043e\u0443\u0442\u0438\u043d\u0433<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0435\u043d\u0434\u043f\u043e\u0438\u043d\u0442, \u0432 \u043f\u0430\u043f\u043a\u0435 <code>.\/routers<\/code>, \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b <code>index.js<\/code> \u0435\u0433\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043a\u0440\u043e\u043c\u0441\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const express = require('express'); const natural = require('natural');  const router = express.Router();  router.post('\/', function(req, res, next) {   const { text } = req.body; });  module.exports = router;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 <code>POST<\/code> \u0435\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>body<\/code> \u0441 \u043f\u043e\u043b\u0435\u043c <code>text<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"processing\">\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043a\u0430\u043a \u0438 \u044f, \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0441\u043e\u043f\u0440\u0438\u043a\u0430\u0441\u0430\u043b\u0438\u0441\u044c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c <del>\u0441\u043a\u0430\u0439\u043d\u0435\u0442\u0430<\/del>, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0442\u0430\u043a \u0436\u0435 \u0432\u0430\u0436\u0435\u043d, \u043a\u0430\u043a \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0439 \u0448\u0443\u043c \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0447\u0442\u043e \u0431\u044b \u0432\u044b \u043d\u0435 \u043f\u043e\u0448\u043b\u0438 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0435\u0433\u043e &quot;\u0430 \u043d\u0443 \u0438\u0434\u0438 \u0441\u044e\u0434\u0430 \u043c\u0430\u0442\u044c \u0442\u0432\u043e\u044e&#8230;&quot;.<\/p>\n<p>  <\/p>\n<h3 id=\"izbavlyaemsya-ot-sokrascheniy\">\u0418\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0439<\/h3>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p6\/bf\/b4\/p6bfb4bi1gveyau9ek44ed7hxhc.gif\"><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a &quot;\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441&quot; \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u0430\u043a I\u2019m, you\u2019re \u0432 I am, you are.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.npmjs.com\/package\/apos-to-lex-form\">apos-to-lex-form<\/a><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const express = require('express'); const natural = require('natural'); const aposToLexForm = require('apos-to-lex-form')  const router = express.Router();  router.post('\/', function(req, res, next) {   const { text } = req.body;   const lexedText = aposToLexForm(text); });  module.exports = router;<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"konvertiruem-tekst-v-lowercase-nizhniy-registr\">\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0432 lowercase (\u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440)<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0441\u043b\u043e\u0432\u0430 \u0418\u0414\u0418 \u0421\u042e\u0414\u0410 \u0438 \u0438\u0434\u0438 \u0441\u044e\u0434\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u043d\u0430\u0434\u043e \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u043e\u0434\u043d\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const casedReview = lexedText.toLowerCase();<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"udalyaem-lishnie-simvoly\">\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043b\u0438\u0448\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043c\u043d\u0435 \u0442\u0440\u0443\u0434\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 @#$%^# \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u043a\u0432\u044b.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e JavaScript \u2014 <code>replace()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const alphaOnlyReview = casedReview.replace(\/[^a-zA-Z\\s]+\/g, '')<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"tokenizaciya\">\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0422\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u043e\u0432\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430.<\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0430 \u0441\u0446\u0435\u043d\u0443 \u0432\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043b\u043e\u0448\u0430\u0434\u043a\u0430 <a href=\"https:\/\/www.npmjs.com\/package\/natural\">Natural<\/a>.<br \/>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u0438 <code>WordTokenizer<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">...  const { WordTokenizer } = natural; const tokenizer = new WordTokenizer(); const tokenizedReview = tokenizer.tokenize(alphaOnlyReview);  ...<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"ispravlyaem-oshibki\">\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438<\/h3>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0439\u0442\u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0443\u0433\u043e\u0434\u043d\u043e, \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0438\u0445 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0421 \u044d\u0442\u0438\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/www.npmjs.com\/package\/spelling-corrector\">spelling-corrector<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const express = require('express'); const natural = require('natural'); const aposToLexForm = require('apos-to-lex-form'); const SpellCorrector = require('spelling-corrector');  const router = express.Router();  const spellCorrector = new SpellCorrector(); spellCorrector.loadDictionary();  router.post('\/', function(req, res, next) {   const { text } = req.body;   const lexedText = aposToLexForm(text);   const casedReview = lexedText.toLowerCase();   const alphaOnlyReview = casedReview.replace(\/[^a-zA-Z\\s]+\/g, '')    const { WordTokenizer } = natural;   const tokenizer = new WordTokenizer();   const tokenizedReview = tokenizer.tokenize(alphaOnlyReview);    tokenizedReview.forEach((word, index) =&gt; {     tokenizedReview[index] = spellCorrector.correct(word);   }); });  module.exports = router;<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"udalyaem-stop-slova\">\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0442\u043e\u043f \u0441\u043b\u043e\u0432\u0430<\/h3>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lp\/5r\/_u\/lp5r_uo_fh_dra2is3ct56ufrzq.gif\"><\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u043e\u043f \u0441\u043b\u043e\u0432\u0430, \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u0441\u043b\u043e\u0432\u0430 \u043f\u0430\u0440\u0430\u0437\u0438\u0442\u044b. \u041d\u0443 \u043a\u0430\u043a \u0431\u044b, \u044d\u044d\u044d, \u0443\u0443\u0443, \u0445\u044b\u044b \u043d\u0435, \u0447\u0442\u043e \u0431\u044b \u043f\u0440\u044f\u043c\u043e \u0442\u0430\u043a\u0438\u0435 \u043f\u0430\u0440\u0430\u0437\u0438\u0442\u044b, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0433\u043e\u0434\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u0438\u043a\u0430. \u0421 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/www.npmjs.com\/package\/stopword\">stopword<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const SW = require('stopword');  ...  const filteredReview = SW.removeStopwords(tokenizedReview);<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"stemming-stemming\">\u0421\u0442\u0435\u043c\u043c\u0438\u043d\u0433 (Stemming)<\/h3>\n<p>  <\/p>\n<p>\u0421\u0442\u0435\u043c\u043c\u0438\u043d\u0433, \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u201cgiving,\u201d \u201cgave,\u201d and \u201cgiver\u201d \u0432 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u201cgive\u201d.<br \/>  \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u0442\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0433, \u0442\u0430\u043a \u043a\u0430\u043a <code>SentimentAnalyzer<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0430\u043a\u0435\u0442 <code>Natural<\/code>, \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<p>  <\/p>\n<h3 id=\"tonalnyy-analiz-teksta-s-pomoschyu-natural\">\u0422\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Natural<\/h3>\n<p>  <\/p>\n<p>\u0412\u0441\u0435! \u041c\u044b \u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0443 \u0437\u0430\u044f\u0432\u0443 \u043f\u0440\u0438\u043c\u0435\u0442 \u0421\u043a\u0430\u0439\u043d\u0435\u0442 \u0438 \u0432\u0441\u0435 \u043f\u043e\u0439\u043c\u0435\u0442. \u041f\u043e\u0440\u0430 \u0441\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 <code>SentimentAnalyzer<\/code> \u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u043e \u043b\u0438 \u043c\u044b \u0437\u0432\u0443\u0447\u0438\u043c \u0432 \u0441\u0442\u043e\u043b\u044c \u0442\u043e\u043b\u0435\u0440\u0430\u043d\u0442\u043d\u043e\u043c \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0422\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u043e. \u041f\u0430\u043a\u0435\u0442 Natural \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043b\u043e\u0432 \u0441 &quot;\u043f\u043e\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c\u044e&quot; \u0441\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u043e\u0432\u043e &quot;good&quot; \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c 3, \u0430 \u0441\u043b\u043e\u0432\u043e &quot;bad&quot; -3. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u0432\u0441\u0435 \u044d\u0442\u0438\u0445 &quot;\u043e\u0447\u043a\u0438&quot; \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0447\u0438\u0441\u0442\u043a\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043d\u0435\u0447\u0435\u0433\u043e \u043c\u0435\u0448\u0430\u043b\u043e \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443.<br \/>  \u0422\u0435\u043a\u0441\u0442 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0435\u0441\u043b\u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f, \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0435\u0441\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 0.<\/p>\n<p>  <\/p>\n<p><code>SentimentAnalyzer<\/code> <a href=\"https:\/\/www.npmjs.com\/package\/natural#sentiment-analysis\">\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/a>:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u042f\u0437\u044b\u043a \u0442\u0435\u043a\u0441\u0442\u0430<\/li>\n<li>\u0421\u0442\u0440\u0438\u043c\u0438\u0442\u0438\u0442\u044c \u0438\u043b\u0438 \u043d\u0435 \u0441\u0442\u0440\u0438\u043c\u0438\u0442\u044c<\/li>\n<li>\u0421\u043b\u043e\u0432\u0430\u0440\u044c (AFINN, Senticon, Pattern), \u044d\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0435\u0441\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0441 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const express = require('express'); const natural = require('natural'); const aposToLexForm = require('apos-to-lex-form'); const SpellCorrector = require('spelling-corrector'); const SW = require('stopword');  const router = express.Router();  const spellCorrector = new SpellCorrector(); spellCorrector.loadDictionary();  router.post('\/', function(req, res, next) {   const { text } = req.body;   const lexedText = aposToLexForm(text);   const casedReview = lexedText.toLowerCase();   const alphaOnlyReview = casedReview.replace(\/[^a-zA-Z\\s]+\/g, '')    const { WordTokenizer } = natural;   const tokenizer = new WordTokenizer();   const tokenizedReview = tokenizer.tokenize(alphaOnlyReview);    tokenizedReview.forEach((word, index) =&gt; {     tokenizedReview[index] = spellCorrector.correct(word);   });    const filteredReview = SW.removeStopwords(tokenizedReview);    const { SentimentAnalyzer, PorterStemmer } = natural;   const analyzer = new SentimentAnalyzer('English', PorterStemmer, 'afinn');   const analysis = analyzer.getSentiment(filteredReview);    res.status(200).json({ analysis }); });  module.exports = router;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>natural<\/code>, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043d\u0430\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>analysis<\/code>.<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>SentimentAnalyzer<\/code>, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435. \u042f\u0437\u044b\u043a \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439 \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c. C\u0442\u0435\u043c\u043f\u0438\u043d\u0433 \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435 \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u043c <code>Natrual<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043c\u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c UI \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430, \u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0432 \u043a\u043e\u043d\u0441\u043a\u043e\u043b\u044c\u043a\u0435 DevTools:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">fetch('\/',   {    method: 'POST',    headers: {      'Content-Type': 'application\/json'    },    body: JSON.stringify({text: 'hey'}) })  \/\/ {&quot;analysis&quot;:0}  fetch('\/',   {    method: 'POST',    headers: {      'Content-Type': 'application\/json'    },    body: JSON.stringify({text: 'hey f*** you'}) })  \/\/ {&quot;analysis&quot;:-2}  fetch('\/',   {    method: 'POST',    headers: {      'Content-Type': 'application\/json'    },    body: JSON.stringify({text: 'hey love you'}) })  \/\/ {&quot;analysis&quot;:1}<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \ud83d\ude42<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/DmitryOlkhovoi\/sentiment-analysis-nodejs\">Github repo<\/a><\/p>\n<p>  <\/p>\n<h3 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 &quot;\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441&quot; \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0430. \u0411\u0435\u0440\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u043b\u044e\u0431\u044b\u0435 \u0440\u0430\u0437\u0431\u043e\u0440\u043a\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u0422\u0430\u043a \u0436\u0435 \u043c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b\u0438 \u0442\u0435\u043c\u0443 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0442\u043e\u043d\u043d\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p>  <\/p>\n<p>\u0427\u0438\u0442\u0430\u0439\u0442\u0435 \u0442\u0430\u043a \u0436\u0435<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/485768\/\">\u0412\u0435\u0431 \u0442\u0440\u0435\u043d\u0434\u044b 2020, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/485562\/\">\u0421\u0435\u0440\u0444\u0438\u043d\u0433 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0433\u0435\u0439\u043c\u043f\u0430\u0434\u043e\u043c (Javascript)<\/a><\/li>\n<\/ul>\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\/486036\/\"> https:\/\/habr.com\/ru\/post\/486036\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486036\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ib\/_g\/vg\/ib_gvg4f3vdu0wiwjyhrjctmd8g.jpeg\"><\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0422\u0435\u043c\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u043e \u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0445\u043e\u0447\u0443 \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c\u0443 \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u044f\u0441\u044c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c &quot;\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441&quot; \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u0435\u043d\u0442\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \/ \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0430. \u0410 \u043f\u043e\u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430, \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0421\u043a\u0430\u0439\u043d\u0435\u0442\u0443.<\/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-297865","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297865","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=297865"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297865\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}