{"id":499840,"date":"2026-10-22T18:48:47","date_gmt":"2026-10-22T15:48:47","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=499840"},"modified":"2026-10-22T18:48:47","modified_gmt":"2026-10-22T15:48:47","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=499840","title":{"rendered":"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c ONNX-\u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u0430 email-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043a HTTP API \u043d\u0430 TypeScript"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/1091696\/\" rel=\"noopener nofollow\">\u0427\u0430\u0441\u0442\u044c 1. \u0423\u0447\u0438\u043c\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 email-\u0430\u0434\u0440\u0435\u0441\u0430 \u043e\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441 CatBoost<\/a><\/p>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u0431\u0443\u0447\u0438\u043b CatBoost \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 email-\u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c, \u043e\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445. \u041d\u0430 <code>ivan.ivanov@gmail.com<\/code> \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0434\u0430\u0451\u0442 \u043e\u043a\u043e\u043b\u043e 0.99, \u043d\u0430 <code>xnjjeka.2.e.2.2@gmail.com<\/code> &#8212; \u043d\u043e\u043b\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0451 \u043d\u0430\u0434\u043e \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 CleanContact. \u0417\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0436\u0438\u0432\u0451\u0442 \u0432 Python, \u0430 \u0431\u044d\u043a\u0435\u043d\u0434 \u0443 \u043c\u0435\u043d\u044f \u043d\u0430 Node.js.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u044f \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u043b \u0432 ONNX \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0447\u0435\u0440\u0435\u0437 <code>onnxruntime-node<\/code>. \u0412\u0435\u0441\u0438\u0442 \u043e\u043d\u0430 \u043f\u0430\u0440\u0443 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438. \u0414\u0435\u0440\u0435\u0432\u044c\u044f CatBoost \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u0440\u0430\u0444\u0430 &#8212; \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>TreeEnsembleClassifier<\/code>.<\/p>\n<p>\u0421\u0430\u043c\u0430\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0436\u0434\u0451\u0442 \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c, \u0430 \u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438. \u0412\u0441\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 TypeScript, \u0438 \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439. \u041f\u0440\u0438\u0447\u0435\u043c, \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 &#8212; \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0441\u043a\u043e\u0440\u0438\u043d\u0433 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439. HTTP-\u0447\u0430\u0441\u0442\u044c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u044d\u0442\u0438\u043c \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0437\u0430\u043d\u044f\u043b\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0422\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043b\u044e\u0431\u043e\u0439 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 HTTP \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0440\u0443\u0442\u0438\u043d\u0443.<\/p>\n<h3>TypeScript \u0431\u0435\u0437 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<p>\u0421\u0442\u0435\u043a: Node.js 24, Hono \u0441 <code>@hono\/node-server<\/code> \u0438 <code>onnxruntime-node<\/code>. \u0422\u0435\u0441\u0442\u044b \u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 <code>node:test<\/code> \u0438 <code>node:assert<\/code>. TypeScript \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>tsc --noEmit<\/code>, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>Node.js \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e <code>.ts<\/code> \u0441\u0430\u043c \u0431\u0435\u0437 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 &#8212; \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432. \u041d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445. <code>enum<\/code>, <code>namespace<\/code> \u0441 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438 parameter properties \u0442\u0430\u043a \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u0438\u0445 \u043d\u0430\u0434\u043e \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 JS, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0445 \u043d\u0435\u0442.<\/p>\n<pre><code class=\"json\">{  \"compilerOptions\": {    \"target\": \"es2024\",    \"module\": \"nodenext\",    \"moduleResolution\": \"nodenext\",    \"strict\": true,    \"noEmit\": true,    \"allowImportingTsExtensions\": true,    \"erasableSyntaxOnly\": true,    \"verbatimModuleSyntax\": true  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p><code>erasableSyntaxOnly<\/code> \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u044b\u0448\u0435. <code>verbatimModuleSyntax<\/code> \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c <code>import type<\/code> \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u0443\u0442\u0435\u043a\u0430\u043b\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c.<\/p>\n<pre><code class=\"json\">{  \"type\": \"module\",  \"scripts\": {    \"start\": \"node src\/server.ts\",    \"dev\": \"node --watch src\/server.ts\",    \"test\": \"node --test 'test\/**\/*.test.ts'\",    \"typecheck\": \"tsc --noEmit\"  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>\u0427\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0438\u0437 Python-\u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>\u041a\u0440\u043e\u043c\u0435 ONNX-\u0444\u0430\u0439\u043b\u0430 \u043d\u0443\u0436\u043d\u044b \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0430\u0441\u0442\u043e\u0442\u044b n-\u0433\u0440\u0430\u043c\u043c \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438\u043c\u0451\u043d. \u042d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u044f \u0440\u0430\u0437\u0431\u0438\u043b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439:<\/p>\n<pre><code>email-human-ml-ts\/- models\/-- email-pattern-v1.onnx-- email-pattern-v1.meta.json-- email-pattern-v1.ngrams.json-- first_names.txt-- last_names.txt- scripts\/-- sync-model.sh- src\/-- normalize.ts-- features\/-- model.ts-- app.ts-- server.ts- test\/-- fixtures\/parity.json-- features.test.ts-- model.test.ts-- app.test.ts<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435 \u043d\u043e\u0441\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 <code>scripts\/sync-model.sh<\/code>. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u0438\u043c\u0435\u043d\u0430 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 <code>meta.json<\/code> (\u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0442\u0443\u0442 \u043e\u0431\u0440\u0435\u0437\u0430\u043d).<\/p>\n<pre><code>SRC=\"${ML_REPO:-..\/email-validator-ml}\"VERSION=\"${MODEL_VERSION:-email-pattern-v1}\"cp \"$SRC\/models\/$VERSION.onnx\" \"$SRC\/models\/$VERSION.meta.json\" \"$SRC\/models\/$VERSION.ngrams.json\" models\/cp \"$SRC\/data\/dictionaries\/first_names.txt\" \"$SRC\/data\/dictionaries\/last_names.txt\" models\/cp \"$SRC\/tests\/fixtures\/parity.json\" test\/fixtures\/parity.json<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code class=\"json\">{  \"version\": \"email-pattern-v1\",  \"feature_order\": [\"length\", \"letter_count\", \"digit_count\", \"...\", \"longest_keyboard_run\"],  \"input\": { \"name\": \"features\", \"dtype\": \"float32\", \"shape\": [\"N\", 38] },  \"output\": { \"name\": \"probabilities\", \"shape\": [\"N\", 2], \"score_column\": 1 },  \"files\": { \"ngrams\": \"email-pattern-v1.ngrams.json\" }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>TypeScript \u0431\u0435\u0440\u0451\u0442 <code>feature_order<\/code> \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442 \u0438 \u043c\u043e\u043b\u0447\u0430 \u043d\u0430\u0447\u043d\u0451\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0440\u0443\u043d\u0434\u0443. \u0412 <code>parity.json<\/code> Python-\u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u043b\u0430\u0434\u0451\u0442 \u043f\u0440\u043e\u0431\u043d\u044b\u0435 \u0438 \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430, \u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0441\u043a\u043e\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u044f \u0438 \u0441\u0432\u0435\u0440\u044f\u043b TypeScript-\u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<h3>\u0413\u0434\u0435 \u0440\u0430\u0437\u043e\u0448\u043b\u0438\u0441\u044c Python \u0438 JavaScript<\/h3>\n<p>\u0421\u0430\u043c\u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0435: \u0434\u043b\u0438\u043d\u0430, \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u043a\u0432 \u0438 \u0446\u0438\u0444\u0440, \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f, \u0447\u0430\u0441\u0442\u043e\u0442\u044b n-\u0433\u0440\u0430\u043c\u043c, \u043f\u043e\u0438\u0441\u043a \u0438\u043c\u0451\u043d \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438\u0441\u044c \u0432 \u043c\u0435\u043b\u043e\u0447\u0430\u0445, \u0433\u0434\u0435 \u044f\u0437\u044b\u043a\u0438 \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443.<\/p>\n<h4>\u0414\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438<\/h4>\n<p>\u0412 Python <code>len()<\/code> \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 Unicode, \u0430 <code>.length<\/code> \u0432 JavaScript &#8212; \u0435\u0434\u0438\u043d\u0438\u0446\u044b UTF-16. \u0414\u043b\u044f <code>\"\ud83d\ude00\"<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f 1 \u0438 2. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <code>[...local]<\/code>:<\/p>\n<pre><code class=\"typescript\">export function lexicalFeatures(local: string): Record&lt;string, number&gt; {  \/\/ \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043a\u0430\u043a len() \u0432 Python  const chars = [...local];  const n = chars.length;  const denom = Math.max(n, 1);  const letters = chars.filter((c) =&gt; LETTERS.includes(c)).length;  const digits = chars.filter((c) =&gt; DIGITS.includes(c)).length;  const unique = new Set(chars).size;  \/\/ ...}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h4>\\d \u0432 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0430\u0445<\/h4>\n<p>\u0412 Python <code>\\d<\/code> \u043b\u043e\u0432\u0438\u0442 \u043b\u044e\u0431\u044b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u044b Unicode, \u0432 JavaScript &#8212; \u0442\u043e\u043b\u044c\u043a\u043e <code>0-9<\/code>. \u0414\u043b\u044f <code>has_year<\/code> \u044f \u043f\u0438\u0448\u0443 <code>[0-9]<\/code> \u044f\u0432\u043d\u043e. \u041d\u0430 \u044d\u043a\u0437\u043e\u0442\u0438\u043a\u0435 \u0432\u0440\u043e\u0434\u0435 \u0430\u0440\u0430\u0431\u0441\u043a\u043e-\u0438\u043d\u0434\u0438\u0439\u0441\u043a\u0438\u0445 \u0446\u0438\u0444\u0440 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0440\u0430\u0437\u043e\u0439\u0434\u0443\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 Python \u043e\u0441\u0442\u0430\u043b\u0441\u044f <code>\\d<\/code>.<\/p>\n<h4>\u041a\u043b\u044e\u0447\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f<\/h4>\n<p>\u0427\u0430\u0441\u0442\u043e\u0442\u044b n-\u0433\u0440\u0430\u043c\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0438\u0437 JSON. \u0423 Python-\u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u043e\u0432 \u043d\u0435\u0442, \u0430 \u0443 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 JS \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f: <code>table[\"constructor\"]<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0411\u0438\u0433\u0440\u0430\u043c\u043c \u0438 \u0442\u0440\u0438\u0433\u0440\u0430\u043c\u043c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043d\u0435\u0442, \u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <code>Object.hasOwn<\/code> \u0441\u0442\u043e\u0438\u0442 \u043a\u043e\u043f\u0435\u0439\u043a\u0438:<\/p>\n<pre><code class=\"typescript\">function stats(grams: string[], table: Record&lt;string, number&gt;, unknown: number, rare: number) {  if (grams.length === 0) return { avg: 0, min: 0, rareRatio: 0 };  const values = grams.map((g) =&gt; (Object.hasOwn(table, g) ? table[g]! : unknown));  return {    avg: values.reduce((a, b) =&gt; a + b, 0) \/ values.length,    min: Math.min(...values),    rareRatio: values.filter((v) =&gt; v &lt; rare).length \/ values.length,  };}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h4>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438<\/h4>\n<p>\u0421 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u043b\u044b\u0442\u044c \u043c\u043b\u0430\u0434\u0448\u0438\u0435 \u0440\u0430\u0437\u0440\u044f\u0434\u044b. \u0412 Python \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u0442 <code>Counter<\/code>, \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f. <code>Map<\/code> \u0432 JS \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442:<\/p>\n<pre><code class=\"typescript\">export function entropy(chars: string[]): number {  if (chars.length === 0) return 0;  const counts = new Map&lt;string, number&gt;();  for (const ch of chars) counts.set(ch, (counts.get(ch) ?? 0) + 1);  const n = chars.length;  let sum = 0;  for (const c of counts.values()) sum += (c \/ n) * Math.log2(c \/ n);  return -sum;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h4>\u0418 \u043e\u0434\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u043b\u043e\u0432\u0443\u0448\u043a\u0430<\/h4>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u044f\u0437\u044b\u043a\u0430\u043c\u0438, \u0430 \u0433\u0440\u0430\u0431\u043b\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0432 \u043e\u0431\u043e\u0438\u0445. <code>\"0123456789\".includes(\"\")<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>true<\/code>, \u0438 \u0432 Python <code>\"\" in \"0123456789\"<\/code> \u0442\u043e\u0436\u0435 <code>True<\/code>. \u0415\u0441\u043b\u0438 \u0443 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0437\u044f\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043a\u0430\u043a <code>\"\"<\/code>, \u043f\u0440\u0438\u0437\u043d\u0430\u043a <code>starts_with_digit<\/code> \u0441\u0442\u0430\u043d\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0443 \u043c\u0435\u043d\u044f &#8212; \u044d\u0442\u043e <code>undefined<\/code>:<\/p>\n<pre><code class=\"typescript\">export const isIn = (charset: string, ch: string | undefined): boolean =&gt;  ch !== undefined &amp;&amp; charset.includes(ch);starts_with_digit: Number(isIn(DIGITS, first))<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440 \u0438 \u0441\u0432\u0435\u0440\u044f\u0435\u043c \u0441 Python<\/h3>\n<p>\u042d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 \u043e\u0442\u0434\u0430\u0451\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u043e \u0438\u043c\u0435\u043d\u0430\u043c, \u0430 <code>extract<\/code> \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0437 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432 <code>meta.json<\/code> \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043f\u0430\u0434\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443:<\/p>\n<pre><code class=\"typescript\">export function extract(local: string, ctx: FeatureContext, featureOrder: string[]): number[] {  const values = extractDict(local, ctx);  return featureOrder.map((name) =&gt; {    const v = values[name];    if (v === undefined) throw new Error(`unknown feature in meta.json: ${name}`);    return v;  });}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u042d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 <code>parity.json<\/code> \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a <code>float32<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 JS \u043f\u0435\u0440\u0435\u0434 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e \u0447\u0435\u0440\u0435\u0437 <code>Math.fround<\/code>:<\/p>\n<pre><code class=\"typescript\">test(\"feature vectors match Python fixtures\", () =&gt; {  for (const c of fixtures.cases) {    const got = extract(c.local, ctx, fixtures.feature_order);    got.forEach((value, i) =&gt; {      assert.equal(        Math.fround(value),        c.features[i],        `${c.email}: ${fixtures.feature_order[i]} ts=${value} py=${c.features[i]}`,      );    });  }});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0432\u0441\u0451 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u043e\u0434\u0438\u043d \u0432 \u043e\u0434\u0438\u043d. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043a\u043e\u0440\u0438\u043d\u0433 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u043e\u043c <code>1e-5<\/code>.<\/p>\n<h3>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 ONNX \u0438 \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u0441\u043a\u043e\u0440\u0438\u043d\u0433<\/h3>\n<p>\u041f\u0440\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0431\u044b\u043b <code>ZipMap<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0434\u0430\u0451\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u042f \u0443\u0431\u0440\u0430\u043b \u0435\u0433\u043e \u0432 Python-\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043d\u0437\u043e\u0440 \u0441 \u0434\u0432\u0443\u043c\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441. \u041d\u043e\u043c\u0435\u0440 \u043d\u0443\u0436\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043b\u0435\u0436\u0438\u0442 \u0432 <code>meta.output.score_column<\/code>.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435. \u0410\u0434\u0440\u0435\u0441\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u0432 \u0442\u0435\u043d\u0437\u043e\u0440 <code>[N, 38]<\/code> \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e \u043e\u0434\u043d\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>session.run<\/code>:<\/p>\n<pre><code class=\"typescript\">export async function loadModel(dir: string, version: string): Promise&lt;Model&gt; {  const meta = JSON.parse(readFileSync(join(dir, `${version}.meta.json`), \"utf8\")) as ModelMeta;  const session = await ort.InferenceSession.create(join(dir, `${meta.version}.onnx`));  const ctx: FeatureContext = {    vocab: loadVocab(join(dir, meta.files.ngrams)),    names: loadNames(dir),  };  const width = meta.feature_order.length;  async function score(emails: string[]): Promise&lt;ScoreResult[]&gt; {    if (emails.length === 0) return [];    const locals = emails.map((e) =&gt; splitEmail(e)[0]);    const data = new Float32Array(emails.length * width);    locals.forEach((local, row) =&gt; data.set(extract(local, ctx, meta.feature_order), row * width));    const input = new ort.Tensor(\"float32\", data, [emails.length, width]);    const output = await session.run({ [meta.input.name]: input });    const probs = output[meta.output.name]!.data as Float32Array;    return emails.map((email, row) =&gt; ({      email,      local: locals[row]!,      score: probs[row * 2 + meta.output.score_column]!,    }));  }  return { meta, ctx, score };}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>HTTP API \u043d\u0430 Hono<\/h3>\n<p><code>createApp<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<pre><code class=\"typescript\">export function createApp(model: Model, maxBatch = 1000) {  const app = new Hono();  app.get(\"\/health\", (c) =&gt;    c.json({ status: \"ok\", model: model.meta.version, features: model.meta.feature_order.length }),  );  app.get(\"\/score\", async (c) =&gt; {    const email = c.req.query(\"email\");    if (!email) return c.json({ error: \"query parameter 'email' is required\" }, 400);    const [result] = await model.score([email]);    return c.json({ ...result!, score: round(result!.score) });  });  app.post(\"\/score\", async (c) =&gt; {    const body = await c.req.json().catch(() =&gt; null);    const emails: unknown = body?.emails;    if (!Array.isArray(emails) || !emails.every((e) =&gt; typeof e === \"string\" &amp;&amp; e !== \"\")) {      return c.json({ error: \"body must be {\\\"emails\\\": string[]}\" }, 400);    }    if (emails.length &gt; maxBatch) {      return c.json({ error: `at most ${maxBatch} emails per request` }, 400);    }    const results = await model.score(emails);    return c.json({      model: model.meta.version,      results: results.map((r) =&gt; ({ ...r, score: round(r.score) })),    });  });  return app;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>GET \/score<\/code> \u0431\u0435\u0440\u0451\u0442 \u043e\u0434\u0438\u043d \u0430\u0434\u0440\u0435\u0441, <code>POST \/score<\/code> &#8212; \u043c\u0430\u0441\u0441\u0438\u0432, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043e 1000 \u0448\u0442\u0443\u043a. \u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0443\u043a\u0430\u043c\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430\u0445 &#8212; \u0442\u0430\u0449\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441\u0445\u0435\u043c \u0440\u0430\u0434\u0438 \u0434\u0432\u0443\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412 <code>server.ts<\/code> \u043f\u043e\u0440\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"typescript\">const port = Number(process.env.PORT ?? 3000);const modelDir = process.env.MODEL_DIR ?? \"models\";const modelVersion = process.env.MODEL_VERSION ?? \"email-pattern-v1\";const maxBatch = Number(process.env.MAX_BATCH ?? 1000);const model = await loadModel(modelDir, modelVersion);const app = createApp(model, maxBatch);serve({ fetch: app.fetch, port }, (info) =&gt; {  console.log(`${model.meta.version} listening on http:\/\/localhost:${info.port}`);});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"bash\">npm installnpm start# email-pattern-v1 listening on http:\/\/localhost:3000<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code class=\"bash\">curl localhost:3000\/health# {\"status\":\"ok\",\"model\":\"email-pattern-v1\",\"features\":38}curl \"localhost:3000\/score?email=ivan.ivanov@gmail.com\"# {\"email\":\"ivan.ivanov@gmail.com\",\"local\":\"ivan.ivanov\",\"score\":0.9942}curl -X POST localhost:3000\/score \\  -H 'content-type: application\/json' \\  -d '{\"emails\":[\"xnjjeka.2.e.2.2@gmail.com\",\"kenji.tanaka@yahoo.co.jp\",\"hans.mueller@gmx.de\"]}'# {\"model\":\"email-pattern-v1\",\"results\":[#   {\"email\":\"xnjjeka.2.e.2.2@gmail.com\",\"local\":\"xnjjeka.2.e.2.2\",\"score\":0},#   {\"email\":\"kenji.tanaka@yahoo.co.jp\",\"local\":\"kenji.tanaka\",\"score\":0.994},#   {\"email\":\"hans.mueller@gmx.de\",\"local\":\"hans.mueller\",\"score\":0.9883}]}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0417\u0430\u043c\u0435\u0440\u044f\u043b \u043d\u0430 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0435 \u0441 Apple M4, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441, \u0431\u0435\u0437 HTTP.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0410\u0434\u0440\u0435\u0441\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041e\u0434\u0438\u043d \u0430\u0434\u0440\u0435\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">0,09 \u043c\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043e\u043a\u043e\u043b\u043e 11 500<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0411\u0430\u0442\u0447 \u0438\u0437 1000 \u0430\u0434\u0440\u0435\u0441\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">25 \u043c\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043e\u043a\u043e\u043b\u043e 40 000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">170 \u043c\u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0411\u0430\u0442\u0447 \u0434\u0430\u0451\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 3,5 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0418 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u044a\u0435\u0434\u0430\u0435\u0442 \u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u044c, \u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438: \u043f\u043e\u0438\u0441\u043a \u0438\u043c\u0451\u043d \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0438\u0437 130 \u0442\u044b\u0441\u044f\u0447 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c, \u0442\u043e \u0435\u0433\u043e.<\/p>\n<h3>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f <code>email-pattern-v2<\/code>:<\/p>\n<pre><code class=\"bash\">MODEL_VERSION=email-pattern-v2 sh scripts\/sync-model.shnpm testMODEL_VERSION=email-pattern-v2 npm start<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0430\u0432\u043b\u044e \u044d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 &#8212; \u0438\u043d\u0430\u0447\u0435 parity-\u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0443\u0442.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1098050\/\">https:\/\/habr.com\/ru\/articles\/1098050\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0427\u0430\u0441\u0442\u044c 1. \u0423\u0447\u0438\u043c\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 email-\u0430\u0434\u0440\u0435\u0441\u0430 \u043e\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441 CatBoost\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u0431\u0443\u0447\u0438\u043b CatBoost \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 email-\u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c, \u043e\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445. \u041d\u0430 ivan.ivanov@gmail.com \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0434\u0430\u0451\u0442 \u043e\u043a\u043e\u043b\u043e 0.99, \u043d\u0430 xnjjeka.2.e.2.2@gmail.com &#8212; \u043d\u043e\u043b\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0451 \u043d\u0430\u0434\u043e \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 CleanContact. \u0417\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0436\u0438\u0432\u0451\u0442 \u0432 Python, \u0430 \u0431\u044d\u043a\u0435\u043d\u0434 \u0443 \u043c\u0435\u043d\u044f \u043d\u0430 Node.js.\u041c\u043e\u0434\u0435\u043b\u044c \u044f \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u043b \u0432 ONNX \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0447\u0435\u0440\u0435\u0437 onnxruntime-node. \u0412\u0435\u0441\u0438\u0442 \u043e\u043d\u0430 \u043f\u0430\u0440\u0443 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438. \u0414\u0435\u0440\u0435\u0432\u044c\u044f CatBoost \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u0440\u0430\u0444\u0430 &#8212; \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 TreeEnsembleClassifier.\u0421\u0430\u043c\u0430\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0436\u0434\u0451\u0442 \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c, \u0430 \u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438. \u0412\u0441\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 TypeScript, \u0438 \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439. \u041f\u0440\u0438\u0447\u0435\u043c, \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 &#8212; \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0441\u043a\u043e\u0440\u0438\u043d\u0433 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439. HTTP-\u0447\u0430\u0441\u0442\u044c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u044d\u0442\u0438\u043c \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0437\u0430\u043d\u044f\u043b\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0422\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043b\u044e\u0431\u043e\u0439 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 HTTP \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0440\u0443\u0442\u0438\u043d\u0443.TypeScript \u0431\u0435\u0437 \u0441\u0431\u043e\u0440\u043a\u0438\u0421\u0442\u0435\u043a: Node.js 24, Hono \u0441 @hono\/node-server \u0438 onnxruntime-node. \u0422\u0435\u0441\u0442\u044b \u043d\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 node:test \u0438 node:assert. TypeScript \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 tsc &#8212;noEmit, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f.Node.js \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e .ts \u0441\u0430\u043c \u0431\u0435\u0437 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 &#8212; \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432. \u041d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445. enum, namespace \u0441 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438 parameter properties \u0442\u0430\u043a \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u0438\u0445 \u043d\u0430\u0434\u043e \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 JS, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0445 \u043d\u0435\u0442.{  &#171;compilerOptions&#187;: {    &#171;target&#187;: &#171;es2024&#187;,    &#171;module&#187;: &#171;nodenext&#187;,    &#171;moduleResolution&#187;: &#171;nodenext&#187;,    &#171;strict&#187;: true,    &#171;noEmit&#187;: true,    &#171;allowImportingTsExtensions&#187;: true,    &#171;erasableSyntaxOnly&#187;: true,    &#171;verbatimModuleSyntax&#187;: true  }}erasableSyntaxOnly \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u044b\u0448\u0435. verbatimModuleSyntax \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c import type \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u0443\u0442\u0435\u043a\u0430\u043b\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c.{  &#171;type&#187;: &#171;module&#187;,  &#171;scripts&#187;: {    &#171;start&#187;: &#171;node src\/server.ts&#187;,    &#171;dev&#187;: &#171;node &#8212;watch src\/server.ts&#187;,    &#171;test&#187;: &#171;node &#8212;test &#8216;test\/**\/*.test.ts'&#187;,    &#171;typecheck&#187;: &#171;tsc &#8212;noEmit&#187;  }}\u0427\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0438\u0437 Python-\u043f\u0440\u043e\u0435\u043a\u0442\u0430\u041a\u0440\u043e\u043c\u0435 ONNX-\u0444\u0430\u0439\u043b\u0430 \u043d\u0443\u0436\u043d\u044b \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0430\u0441\u0442\u043e\u0442\u044b n-\u0433\u0440\u0430\u043c\u043c \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438\u043c\u0451\u043d. \u042d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u044f \u0440\u0430\u0437\u0431\u0438\u043b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439:email-human-ml-ts\/- models\/&#8212; email-pattern-v1.onnx&#8212; email-pattern-v1.meta.json&#8212; email-pattern-v1.ngrams.json&#8212; first_names.txt&#8212; last_names.txt- scripts\/&#8212; sync-model.sh- src\/&#8212; normalize.ts&#8212; features\/&#8212; model.ts&#8212; app.ts&#8212; server.ts- test\/&#8212; fixtures\/parity.json&#8212; features.test.ts&#8212; model.test.ts&#8212; app.test.ts\u0427\u0442\u043e\u0431\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435 \u043d\u043e\u0441\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 scripts\/sync-model.sh. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u0438\u043c\u0435\u043d\u0430 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 meta.json (\u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0442\u0443\u0442 \u043e\u0431\u0440\u0435\u0437\u0430\u043d).SRC=&#187;${ML_REPO:-..\/email-validator-ml}&#187;VERSION=&#187;${MODEL_VERSION:-email-pattern-v1}&#187;cp &#171;$SRC\/models\/$VERSION.onnx&#187; &#171;$SRC\/models\/$VERSION.meta.json&#187; &#171;$SRC\/models\/$VERSION.ngrams.json&#187; models\/cp &#171;$SRC\/data\/dictionaries\/first_names.txt&#187; &#171;$SRC\/data\/dictionaries\/last_names.txt&#187; models\/cp &#171;$SRC\/tests\/fixtures\/parity.json&#187; test\/fixtures\/parity.json{  &#171;version&#187;: &#171;email-pattern-v1&#187;,  &#171;feature_order&#187;: [&#171;length&#187;, &#171;letter_count&#187;, &#171;digit_count&#187;, &#171;&#8230;&#187;, &#171;longest_keyboard_run&#187;],  &#171;input&#187;: { &#171;name&#187;: &#171;features&#187;, &#171;dtype&#187;: &#171;float32&#187;, &#171;shape&#187;: [&#171;N&#187;, 38] },  &#171;output&#187;: { &#171;name&#187;: &#171;probabilities&#187;, &#171;shape&#187;: [&#171;N&#187;, 2], &#171;score_column&#187;: 1 },  &#171;files&#187;: { &#171;ngrams&#187;: &#171;email-pattern-v1.ngrams.json&#187; }}TypeScript \u0431\u0435\u0440\u0451\u0442 feature_order \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442 \u0438 \u043c\u043e\u043b\u0447\u0430 \u043d\u0430\u0447\u043d\u0451\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0440\u0443\u043d\u0434\u0443. \u0412 parity.json Python-\u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u043b\u0430\u0434\u0451\u0442 \u043f\u0440\u043e\u0431\u043d\u044b\u0435 \u0438 \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430, \u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0441\u043a\u043e\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u044f \u0438 \u0441\u0432\u0435\u0440\u044f\u043b TypeScript-\u0432\u0435\u0440\u0441\u0438\u044e.\u0413\u0434\u0435 \u0440\u0430\u0437\u043e\u0448\u043b\u0438\u0441\u044c Python \u0438 JavaScript\u0421\u0430\u043c\u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0435: \u0434\u043b\u0438\u043d\u0430, \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u043a\u0432 \u0438 \u0446\u0438\u0444\u0440, \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f, \u0447\u0430\u0441\u0442\u043e\u0442\u044b n-\u0433\u0440\u0430\u043c\u043c, \u043f\u043e\u0438\u0441\u043a \u0438\u043c\u0451\u043d \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438\u0441\u044c \u0432 \u043c\u0435\u043b\u043e\u0447\u0430\u0445, \u0433\u0434\u0435 \u044f\u0437\u044b\u043a\u0438 \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443.\u0414\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438\u0412 Python len() \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 Unicode, \u0430 .length \u0432 JavaScript &#8212; \u0435\u0434\u0438\u043d\u0438\u0446\u044b UTF-16. \u0414\u043b\u044f &#171;\ud83d\ude00&#187; \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f 1 \u0438 2. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 [&#8230;local]:export function lexicalFeatures(local: string): Record&lt;string, number&gt; {  \/\/ \u043a\u043e\u0434\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043a\u0430\u043a len() \u0432 Python  const chars = [&#8230;local];  const n = chars.length;  const denom = Math.max(n, 1);  const letters = chars.filter((c) =&gt; LETTERS.includes(c)).length;  const digits = chars.filter((c) =&gt; DIGITS.includes(c)).length;  const unique = new Set(chars).size;  \/\/ &#8230;}\\d \u0432 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0430\u0445\u0412 Python \\d \u043b\u043e\u0432\u0438\u0442 \u043b\u044e\u0431\u044b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u044b Unicode, \u0432 JavaScript &#8212; \u0442\u043e\u043b\u044c\u043a\u043e 0-9. \u0414\u043b\u044f has_year \u044f \u043f\u0438\u0448\u0443 [0-9] \u044f\u0432\u043d\u043e. \u041d\u0430 \u044d\u043a\u0437\u043e\u0442\u0438\u043a\u0435 \u0432\u0440\u043e\u0434\u0435 \u0430\u0440\u0430\u0431\u0441\u043a\u043e-\u0438\u043d\u0434\u0438\u0439\u0441\u043a\u0438\u0445 \u0446\u0438\u0444\u0440 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0440\u0430\u0437\u043e\u0439\u0434\u0443\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 Python \u043e\u0441\u0442\u0430\u043b\u0441\u044f \\d.\u041a\u043b\u044e\u0447\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u0427\u0430\u0441\u0442\u043e\u0442\u044b n-\u0433\u0440\u0430\u043c\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0438\u0437 JSON. \u0423 Python-\u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u043e\u0432 \u043d\u0435\u0442, \u0430 \u0443 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 JS \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f: table[&#171;constructor&#187;] \u0432\u0435\u0440\u043d\u0451\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0411\u0438\u0433\u0440\u0430\u043c\u043c \u0438 \u0442\u0440\u0438\u0433\u0440\u0430\u043c\u043c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043d\u0435\u0442, \u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 Object.hasOwn \u0441\u0442\u043e\u0438\u0442 \u043a\u043e\u043f\u0435\u0439\u043a\u0438:function stats(grams: string[], table: Record&lt;string, number&gt;, unknown: number, rare: number) {  if (grams.length === 0) return { avg: 0, min: 0, rareRatio: 0 };  const values = grams.map((g) =&gt; (Object.hasOwn(table, g) ? table[g]! : unknown));  return {    avg: values.reduce((a, b) =&gt; a + b, 0) \/ values.length,    min: Math.min(&#8230;values),    rareRatio: values.filter((v) =&gt; v &lt; rare).length \/ values.length,  };}\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438\u0421 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u043b\u044b\u0442\u044c \u043c\u043b\u0430\u0434\u0448\u0438\u0435 \u0440\u0430\u0437\u0440\u044f\u0434\u044b. \u0412 Python \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u0442 Counter, \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f. Map \u0432 JS \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442:export function entropy(chars: string[]): number {  if (chars.length === 0) return 0;  const counts = new Map&lt;string, number&gt;();  for (const ch of chars) counts.set(ch, (counts.get(ch) ?? 0) + 1);  const n = chars.length;  let sum = 0;  for (const c of counts.values()) sum += (c \/ n) * Math.log2(c \/ n);  return -sum;}\u0418 \u043e\u0434\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u043b\u043e\u0432\u0443\u0448\u043a\u0430\u042d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u044f\u0437\u044b\u043a\u0430\u043c\u0438, \u0430 \u0433\u0440\u0430\u0431\u043b\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0432 \u043e\u0431\u043e\u0438\u0445. &#171;0123456789&#187;.includes(&#171;&#187;) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0438 \u0432 Python &#171;&#187; in &#171;0123456789&#187; \u0442\u043e\u0436\u0435 True. \u0415\u0441\u043b\u0438 \u0443 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0437\u044f\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043a\u0430\u043a &#171;&#187;, \u043f\u0440\u0438\u0437\u043d\u0430\u043a starts_with_digit \u0441\u0442\u0430\u043d\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0443 \u043c\u0435\u043d\u044f &#8212; \u044d\u0442\u043e undefined:export const isIn = (charset: string, ch: string | undefined): boolean =&gt;  ch !== undefined &amp;&amp; charset.includes(ch);starts_with_digit: Number(isIn(DIGITS, first))\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440 \u0438 \u0441\u0432\u0435\u0440\u044f\u0435\u043c \u0441 Python\u042d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 \u043e\u0442\u0434\u0430\u0451\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u043e \u0438\u043c\u0435\u043d\u0430\u043c, \u0430 extract \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0437 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432 meta.json \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u043a\u0441\u0442\u0440\u0430\u043a\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043f\u0430\u0434\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443:export function extract(local: string, ctx: FeatureContext, featureOrder: string[]): number[] {  const values = extractDict(local, ctx);  return featureOrder.map((name) =&gt; {    const v = values[name];    if (v === undefined) throw new Error(`unknown feature in meta.json: ${name}`);    return v;  });}\u042d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 parity.json \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a float32, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 JS \u043f\u0435\u0440\u0435\u0434 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e \u0447\u0435\u0440\u0435\u0437 Math.fround:test(&#171;feature vectors match Python fixtures&#187;, () =&gt; {  for (const c of fixtures.cases) {    const got = extract(c.local, ctx, fixtures.feature_order);    got.forEach((value, i) =&gt; {      assert.equal(        Math.fround(value),        c.features[i],        `${c.email}: ${fixtures.feature_order[i]} ts=${value} py=${c.features[i]}`,      );    });  }});\u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0432\u0441\u0451 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u043e\u0434\u0438\u043d \u0432 \u043e\u0434\u0438\u043d. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043a\u043e\u0440\u0438\u043d\u0433 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u043e\u043c 1e-5.\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 ONNX \u0438 \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u041f\u0440\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0431\u044b\u043b ZipMap, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0434\u0430\u0451\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u042f \u0443\u0431\u0440\u0430\u043b \u0435\u0433\u043e \u0432 Python-\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0435\u043d\u0437\u043e\u0440 \u0441 \u0434\u0432\u0443\u043c\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441. \u041d\u043e\u043c\u0435\u0440 \u043d\u0443\u0436\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043b\u0435\u0436\u0438\u0442 \u0432 meta.output.score_column.\u041c\u043e\u0434\u0435\u043b\u044c \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435. \u0410\u0434\u0440\u0435\u0441\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u0432 \u0442\u0435\u043d\u0437\u043e\u0440 [N, 38] \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e \u043e\u0434\u043d\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c session.run:export async function loadModel(dir: string, version: string): Promise&lt;Model&gt; {  const meta = JSON.parse(readFileSync(join(dir, `${version}.meta.json`), &#171;utf8&#187;)) as ModelMeta;  const session = await ort.InferenceSession.create(join(dir, `${meta.version}.onnx`));  const ctx: FeatureContext = {    vocab: loadVocab(join(dir, meta.files.ngrams)),    names: loadNames(dir),  };  const width = meta.feature_order.length;  async function score(emails: string[]): Promise&lt;ScoreResult[]&gt; {    if (emails.length === 0) return [];    const locals = emails.map((e) =&gt; splitEmail(e)[0]);    const data = new Float32Array(emails.length * width);    locals.forEach((local, row) =&gt; data.set(extract(local, ctx, meta.feature_order), row * width));    const input = new ort.Tensor(&#171;float32&#187;, data, [emails.length, width]);    const output = await session.run({ [meta.input.name]: input });    const probs = output[meta.output.name]!.data as Float32Array;    return emails.map((email, row) =&gt; ({      email,      local: locals[row]!,      score: probs[row * 2 + meta.output.score_column]!,    }));  }  return { meta, ctx, score };}HTTP API \u043d\u0430 HonocreateApp \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430.export function createApp(model: Model, maxBatch = 1000) {  const app = new Hono();  app.get(&#171;\/health&#187;, (c) =&gt;    c.json({ status: &#171;ok&#187;, model: model.meta.version, features: model.meta.feature_order.length }),  );  app.get(&#171;\/score&#187;, async (c) =&gt; {    const email = c.req.query(&#171;email&#187;);    if (!email) return c.json({ error: &#171;query parameter &#8217;email&#8217; is required&#187; }, 400);    const [result] = await model.score([email]);    return c.json({ &#8230;result!, score: round(result!.score) });  });  app.post(&#171;\/score&#187;, async (c) =&gt; {    const body = await c.req.json().catch(() =&gt; null);    const emails: unknown = body?.emails;    if (!Array.isArray(emails) || !emails.every((e) =&gt; typeof e === &#171;string&#187; &amp;&amp; e !== &#171;&#187;)) {      return c.json({ error: &#171;body must be {\\&#187;emails\\&#187;: string[]}&#187; }, 400);    }    if (emails.length &gt; maxBatch) { &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-499840","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/499840","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=499840"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/499840\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=499840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=499840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=499840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}