kyn-lang 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. kyn/__init__.py +653 -0
  2. kyn/__main__.py +21 -0
  3. kyn/_version.py +22 -0
  4. kyn/ai.py +595 -0
  5. kyn/bench.py +454 -0
  6. kyn/cache.py +686 -0
  7. kyn/cli.py +1165 -0
  8. kyn/crypto.py +740 -0
  9. kyn/crypto_aead.py +209 -0
  10. kyn/dataframe.py +662 -0
  11. kyn/db_vn.py +113 -0
  12. kyn/diagnostics.py +295 -0
  13. kyn/doctor.py +344 -0
  14. kyn/fixes.py +1429 -0
  15. kyn/formatter.py +451 -0
  16. kyn/graph_vn.py +124 -0
  17. kyn/gui.py +452 -0
  18. kyn/html_exporter.py +542 -0
  19. kyn/importer.py +301 -0
  20. kyn/lexicon.py +843 -0
  21. kyn/lexicon_data.json +1456 -0
  22. kyn/lexicon_data.toml +1331 -0
  23. kyn/lexicon_files/algorithms.json +169 -0
  24. kyn/lexicon_files/asyncio.json +148 -0
  25. kyn/lexicon_files/collections.json +705 -0
  26. kyn/lexicon_files/core.json +3131 -0
  27. kyn/lexicon_files/database.json +229 -0
  28. kyn/lexicon_files/en.json +78 -0
  29. kyn/lexicon_files/exceptions.json +1078 -0
  30. kyn/lexicon_files/extra.json +1612 -0
  31. kyn/lexicon_files/grammar.json +5977 -0
  32. kyn/lexicon_files/logging.json +187 -0
  33. kyn/lexicon_files/math.json +940 -0
  34. kyn/lexicon_files/network.json +198 -0
  35. kyn/lexicon_files/operators.json +475 -0
  36. kyn/lexicon_files/pathlib.json +355 -0
  37. kyn/lexicon_files/stdlib.json +6461 -0
  38. kyn/lexicon_files/str.json +727 -0
  39. kyn/lexicon_files/system.json +210 -0
  40. kyn/lexicon_files/threading.json +147 -0
  41. kyn/lexicon_files/typing.json +197 -0
  42. kyn/lexicon_files/utilities.json +222 -0
  43. kyn/linter.py +661 -0
  44. kyn/lsp.py +646 -0
  45. kyn/ml/__init__.py +366 -0
  46. kyn/ml/activations.py +160 -0
  47. kyn/ml/advanced.py +722 -0
  48. kyn/ml/backend.py +480 -0
  49. kyn/ml/classical.py +1318 -0
  50. kyn/ml/data.py +744 -0
  51. kyn/ml/gradcheck.py +152 -0
  52. kyn/ml/llm.py +289 -0
  53. kyn/ml/losses.py +467 -0
  54. kyn/ml/metrics.py +277 -0
  55. kyn/ml/metrics_extra.py +57 -0
  56. kyn/ml/nn.py +1710 -0
  57. kyn/ml/optim.py +788 -0
  58. kyn/ml/random.py +95 -0
  59. kyn/ml/serialization.py +554 -0
  60. kyn/ml/tensor.py +2170 -0
  61. kyn/ml/trainer.py +572 -0
  62. kyn/optimizer.py +324 -0
  63. kyn/profiler.py +606 -0
  64. kyn/py.typed +1 -0
  65. kyn/regex_vn.py +62 -0
  66. kyn/repl.py +250 -0
  67. kyn/rules.py +1170 -0
  68. kyn/runtime.py +691 -0
  69. kyn/sandbox.py +348 -0
  70. kyn/scaffold.py +106 -0
  71. kyn/scope.py +190 -0
  72. kyn/shield.py +413 -0
  73. kyn/super_ast.py +380 -0
  74. kyn/super_runtime.py +1185 -0
  75. kyn/super_syntax.py +684 -0
  76. kyn/tensor.py +621 -0
  77. kyn/terminal.py +150 -0
  78. kyn/transpiler.py +2041 -0
  79. kyn/trie.py +270 -0
  80. kyn/web_framework.py +399 -0
  81. kyn/web_server.py +542 -0
  82. kyn_lang-1.0.0.dist-info/METADATA +132 -0
  83. kyn_lang-1.0.0.dist-info/RECORD +87 -0
  84. kyn_lang-1.0.0.dist-info/WHEEL +5 -0
  85. kyn_lang-1.0.0.dist-info/entry_points.txt +2 -0
  86. kyn_lang-1.0.0.dist-info/licenses/LICENSE +21 -0
  87. kyn_lang-1.0.0.dist-info/top_level.txt +1 -0
kyn/__init__.py ADDED
@@ -0,0 +1,653 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Package `kyn` — Trình biên dịch chuyển đổi (Transpiler) và thông dịch song ngữ Việt - Anh cho Python.
4
+ Phiên bản 1.0.0 — Đột phá hiệu năng, bộ từ vựng siêu dày, tự sửa toàn bộ lỗi ngớ ngẩn Python,
5
+ tích hợp bộ công cụ kiểm thử, định dạng mã nguồn (formatter) và phân tích hiệu suất (profiler).
6
+
7
+ Lazy-loading (PEP 562, Kyn 1.0.0):
8
+ `import kyn` chỉ nạp `._version` (nhẹ, <10ms). Mọi API nặng
9
+ (transpiler/trie 71k nhánh, lexicon 21k từ, ml+Tensor/Autograd,
10
+ dataframe, ai, gui, web...) được nạp lười qua `__getattr__` khi
11
+ truy cập lần đầu, rồi cache vào `globals()`. Giúp `import kyn`
12
+ nhanh từ ~1.3s xuống <0.3s và tránh kéo `numpy` khi không dùng ML.
13
+ API công khai giữ nguyên 100% (303 exports, `from kyn import *` đầy đủ).
14
+ """
15
+
16
+ import importlib as _importlib
17
+
18
+ from ._version import __version__ # single source of truth (kyn/_version.py)
19
+
20
+ __all__: list[str] = [
21
+ '__version__',
22
+ 'ASTSanitizeResult',
23
+ 'BASE_PHRASE_FLAGS',
24
+ 'BASE_VIETNAMESE_DICTIONARY',
25
+ 'BiếnAnToàn',
26
+ 'Bộ',
27
+ 'BộGiáTrịĐặtTên',
28
+ 'BộKiểmThử',
29
+ 'BộĐếm',
30
+ 'BáoCáoHiệuSuất',
31
+ 'Bất_Kỳ',
32
+ 'Chuỗi_Ký_Tự',
33
+ 'Chung',
34
+ 'ContextFlags',
35
+ 'Có_Thể_Lặp',
36
+ 'DEFAULT_DOT_METHOD_TRIE',
37
+ 'DEFAULT_KEYWORD_TRIE',
38
+ 'DEFAULT_SOURCE_REGISTRY',
39
+ 'DEFAULT_TRACEBACK_FORMATTER',
40
+ 'DEFAULT_TRANSPILER',
41
+ 'DOT_METHOD_DICTIONARY',
42
+ 'DOT_PHRASE_FLAGS',
43
+ 'Danh_Sách',
44
+ 'GLOBAL_DOT_METHOD_TRIE',
45
+ 'GLOBAL_KEYWORD_TRIE',
46
+ 'GLOBAL_TRANSPILER',
47
+ 'Giao_Thức',
48
+ 'Giá_Trị_Logic',
49
+ 'HàngĐợiHaiĐầu',
50
+ 'HàngĐợiUT',
51
+ 'Hợp',
52
+ 'KhóaLuồng',
53
+ 'Không_Có',
54
+ 'LEXICON_ENTRIES',
55
+ 'LexicalScopeManager',
56
+ 'LexiconAuditReport',
57
+ 'LexiconEntry',
58
+ 'Luồng',
59
+ 'LớpCơSởTrừuTượng',
60
+ 'NgănXếp',
61
+ 'PYTHON_FIX_HELPERS',
62
+ 'PhânTíchBộNhớ',
63
+ 'PhânTíchThờiGian',
64
+ 'PhraseTrie',
65
+ 'PhraseTrieNode',
66
+ 'PhươngThứcTrừuTượng',
67
+ 'KynASTSanitizer',
68
+ 'KynFormatter',
69
+ 'KynMetaPathFinder',
70
+ 'KynProfiler',
71
+ 'KynLSP',
72
+ 'KynSmartREPL',
73
+ 'start_lsp_server',
74
+ 'KynSourceFileLoader',
75
+ 'KynTranspiler',
76
+ 'python_to_pyvn',
77
+ 'PythonBugFixer',
78
+ 'ScopeFrame',
79
+ 'SourceMap',
80
+ 'SourceRegistry',
81
+ 'StyleReport',
82
+ 'Số_Nguyên',
83
+ 'Số_Thực',
84
+ 'SựKiệnLuồng',
85
+ 'TranspileContext',
86
+ 'Trình_Tạo',
87
+ 'Tùy_Chọn',
88
+ 'Tập_Hợp',
89
+ 'TừĐiểnMặcĐịnh',
90
+ 'Từ_Điển',
91
+ 'VietnameseTracebackFormatter',
92
+ 'apply_python_bug_fixes',
93
+ 'audit_lexicon',
94
+ 'bình_phương',
95
+ 'bội_chung_nhỏ_nhất',
96
+ 'bộ_nhớ_đệm_lru',
97
+ 'build_phrase_trie',
98
+ 'băm_chuỗi',
99
+ 'check_pyvn_source',
100
+ 'check_pyvn_style',
101
+ 'chia_an_toàn',
102
+ 'chuyển_ngày_an_toàn',
103
+ 'chuyển_số_an_toàn',
104
+ 'chạy_bất_đồng_bộ',
105
+ 'chặn_giá_trị',
106
+ 'căn_bậc_hai',
107
+ 'cắt_chuỗi_an_toàn',
108
+ 'cộng_chính_xác',
109
+ 'execute_kyn_source',
110
+ 'fibonacci',
111
+ 'format_pyvn_file',
112
+ 'giai_thừa',
113
+ 'giải_mã_base64',
114
+ 'gần_bằng',
115
+ 'ghi_csv',
116
+ 'ghi_json',
117
+ 'ghi_nhớ',
118
+ 'ghi_nhật_ký',
119
+ 'ghi_thêm_tệp',
120
+ 'ghi_tệp',
121
+ 'gộp_từ_điển',
122
+ 'gửi_yêu_cầu_http',
123
+ 'in_an_toàn',
124
+ 'inject_runtime_helpers',
125
+ 'install_pyvn_import_hook',
126
+ 'khẳng_định_bằng',
127
+ 'khẳng_định_đúng',
128
+ 'khẳng_định_ném_lỗi',
129
+ 'khẳng_định_sai',
130
+ 'kiểm_tra_nguyên_tố',
131
+ 'kết_nối_cơ_sở_dữ_liệu',
132
+ 'load_lexicon_file',
133
+ 'load_topic_lexicon_files',
134
+ 'loại_bỏ_trùng',
135
+ 'làm_tròn',
136
+ 'làm_tròn_số_thực',
137
+ 'lấy_an_toàn',
138
+ 'lọc_an_toàn',
139
+ 'lớp_dữ_liệu',
140
+ 'main',
141
+ 'mã_hóa_base64',
142
+ 'mở_tệp',
143
+ 'nghỉ_bất_đồng_bộ',
144
+ 'nhập_đúng_sai',
145
+ 'nhập_số_nguyên',
146
+ 'nhập_số_thực',
147
+ 'nối_chuỗi',
148
+ 'phẳng_hóa',
149
+ 'round_float',
150
+ 'sao_chép_sâu',
151
+ 'so_sánh_hiệu_suất',
152
+ 'so_sánh_ngày',
153
+ 'strip_vietnamese_accents',
154
+ 'sắp_xếp_an_toàn',
155
+ 'sắp_xếp_nhanh',
156
+ 'số_thực_chính_xác',
157
+ 'thử_lại',
158
+ 'trung_bình_chính_xác',
159
+ 'tìm_kiếm_an_toàn',
160
+ 'tìm_kiếm_nhị_phân',
161
+ 'tính_chuẩn',
162
+ 'tạo_ma_trận',
163
+ 'tạo_tác_vụ_async',
164
+ 'tạo_uuid',
165
+ 'tồn_tại_thư_mục',
166
+ 'tồn_tại_tệp',
167
+ 'xóa_an_toàn',
168
+ 'ánh_xạ_an_toàn',
169
+ 'đo_bộ_nhớ',
170
+ 'đo_thời_gian',
171
+ 'đánh_giá_độ_phức_tạp',
172
+ 'đọc_csv',
173
+ 'đọc_dòng_tệp',
174
+ 'đọc_json',
175
+ 'đọc_tệp',
176
+ 'đếm_phần_tử',
177
+ 'định_dạng_ngày',
178
+ 'định_dạng_số',
179
+ 'ước_chung_lớn_nhất',
180
+ 'ĐồngHồBấmGiờ',
181
+ 'ĐồThị',
182
+ 'ĐườngDẫn',
183
+ 'Đường_Dẫn',
184
+ 'MảngSố',
185
+ 'MaTrận',
186
+ 'tạo_ma_trận_đơn_vị',
187
+ 'sigmoid',
188
+ 'relu',
189
+ 'softmax',
190
+ 'MáyChủWeb',
191
+ 'phản_hồi_json',
192
+ 'phản_hồi_html',
193
+ 'YêuCầu',
194
+ 'PhảnHồi',
195
+ 'ThanhTiếnTrình',
196
+ 'BảngDữLiệu',
197
+ 'in_màu',
198
+ 'tô_màu',
199
+ 'CYBERPUNK_BANNER',
200
+ 'KynASTOptimizer',
201
+ 'optimize_ast',
202
+ 'DEFAULT_CACHE_MANAGER',
203
+ 'KynCacheManager',
204
+ 'run_pyvn_doctor',
205
+ 'run_benchmark',
206
+ 'init_project',
207
+ 'start_web_ide',
208
+ 'ỨngDụngCửaSổ',
209
+ 'Nhãn',
210
+ 'NútBấm',
211
+ 'ÔNhập',
212
+ 'HộpVănBản',
213
+ 'HộpThoại',
214
+ 'MạngNơRon',
215
+ 'LớpNơRon',
216
+ 'KhungDữLiệu',
217
+ 'băm_sha256',
218
+ 'băm_sha512',
219
+ 'băm_md5',
220
+ 'băm_hmac_sha256',
221
+ 'mã_hóa_chuỗi',
222
+ 'giải_mã_chuỗi',
223
+ 'tạo_token_jwt',
224
+ 'xác_thực_token_jwt',
225
+ 'sinh_mật_khẩu_an_toàn',
226
+ 'kiểm_tra_độ_mạnh_mật_khẩu',
227
+ 'export_to_html',
228
+ 'ml',
229
+ 'Tensor',
230
+ 'Module',
231
+ 'Sequential',
232
+ 'Linear',
233
+ 'Activation',
234
+ 'Dropout',
235
+ 'Flatten',
236
+ 'Embedding',
237
+ 'BatchNorm1d',
238
+ 'BatchNorm2d',
239
+ 'Conv1d',
240
+ 'Conv2d',
241
+ 'RNN',
242
+ 'LSTM',
243
+ 'GRU',
244
+ 'MultiheadAttention',
245
+ 'Trainer',
246
+ 'EarlyStopping',
247
+ 'TensorDataset',
248
+ 'DataLoader',
249
+ 'StandardScaler',
250
+ 'train_test_split',
251
+ 'Generator',
252
+ 'seed_everything',
253
+ 'SGD',
254
+ 'Adam',
255
+ 'AdamW',
256
+ 'build_optimizer',
257
+ 'mse_loss',
258
+ 'cross_entropy',
259
+ 'CrossEntropyLoss',
260
+ 'accuracy',
261
+ 'gradcheck',
262
+ 'save_checkpoint',
263
+ 'load_checkpoint',
264
+ 'build_model',
265
+ 'CheckpointError',
266
+ 'LinearRegression',
267
+ 'LogisticRegression',
268
+ 'KNeighborsClassifier',
269
+ 'DecisionTreeClassifier',
270
+ 'RandomForestClassifier',
271
+ 'KMeans',
272
+ 'PCA',
273
+ 'InferenceEngine',
274
+ 'KynLinter',
275
+ 'ChẩnĐoán',
276
+ 'KếtQuảLint',
277
+ 'lint_source',
278
+ 'lint_file',
279
+ 'Computed',
280
+ 'ConstError',
281
+ 'ContractError',
282
+ 'CóGiáTrị',
283
+ 'Effect',
284
+ 'Err',
285
+ 'HiệuỨng',
286
+ 'KếtQuả',
287
+ 'LazyModuleProxy',
288
+ 'LuồngDữLiệu',
289
+ 'LínhCanh',
290
+ 'LỗiHằngSố',
291
+ 'LỗiHợpĐồng',
292
+ 'LựaChọn',
293
+ 'Nothing',
294
+ 'Ok',
295
+ 'Option',
296
+ 'Result',
297
+ 'Rỗng',
298
+ 'SUPER_RUNTIME_HELPERS',
299
+ 'Signal',
300
+ 'Some',
301
+ 'Stream',
302
+ 'SuperASTTransformer',
303
+ 'ThànhCông',
304
+ 'ThấtBại',
305
+ 'TínHiệu',
306
+ 'TínhToán',
307
+ 'TừĐiểnBấtBiến',
308
+ 'apply_super_ast_transforms',
309
+ 'batch',
310
+ 'bắt_kết_quả',
311
+ 'catch_result',
312
+ 'contract',
313
+ 'enforce_types',
314
+ 'frozendict',
315
+ 'gộp_cập_nhật',
316
+ 'hợp_đồng',
317
+ 'preprocess_super_syntax',
318
+ 'sentinel',
319
+ 'tail_call',
320
+ 'tco',
321
+ 'tối_ưu_đuôi',
322
+ 'ép_kiểu',
323
+ 'đệ_quy_đuôi',
324
+ ]
325
+
326
+ # Export name -> (module path, attribute name). Submodule "ml" is special-cased.
327
+ _LAZY_EXPORTS: dict[str, tuple[str, str]] = {
328
+ 'ASTSanitizeResult': ('kyn.shield', 'ASTSanitizeResult'),
329
+ 'Activation': ('kyn.ml', 'Activation'),
330
+ 'Adam': ('kyn.ml', 'Adam'),
331
+ 'AdamW': ('kyn.ml', 'AdamW'),
332
+ 'BASE_PHRASE_FLAGS': ('kyn.lexicon', 'BASE_PHRASE_FLAGS'),
333
+ 'BASE_VIETNAMESE_DICTIONARY': ('kyn.lexicon', 'BASE_VIETNAMESE_DICTIONARY'),
334
+ 'BatchNorm1d': ('kyn.ml', 'BatchNorm1d'),
335
+ 'BatchNorm2d': ('kyn.ml', 'BatchNorm2d'),
336
+ 'BiếnAnToàn': ('kyn.runtime', 'BiếnAnToàn'),
337
+ 'BáoCáoHiệuSuất': ('kyn.profiler', 'BáoCáoHiệuSuất'),
338
+ 'BảngDữLiệu': ('kyn.terminal', 'BảngDữLiệu'),
339
+ 'Bất_Kỳ': ('kyn.runtime', 'Bất_Kỳ'),
340
+ 'Bộ': ('kyn.runtime', 'Bộ'),
341
+ 'BộGiáTrịĐặtTên': ('kyn.runtime', 'BộGiáTrịĐặtTên'),
342
+ 'BộKiểmThử': ('kyn.runtime', 'BộKiểmThử'),
343
+ 'BộĐếm': ('kyn.runtime', 'BộĐếm'),
344
+ 'CYBERPUNK_BANNER': ('kyn.terminal', 'CYBERPUNK_BANNER'),
345
+ 'CheckpointError': ('kyn.ml', 'CheckpointError'),
346
+ 'Chung': ('kyn.runtime', 'Chung'),
347
+ 'Chuỗi_Ký_Tự': ('kyn.runtime', 'Chuỗi_Ký_Tự'),
348
+ 'ChẩnĐoán': ('kyn.linter', 'ChẩnĐoán'),
349
+ 'Computed': ('kyn.super_runtime', 'Computed'),
350
+ 'ConstError': ('kyn.super_runtime', 'ConstError'),
351
+ 'ContextFlags': ('kyn.lexicon', 'ContextFlags'),
352
+ 'ContractError': ('kyn.super_runtime', 'ContractError'),
353
+ 'Conv1d': ('kyn.ml', 'Conv1d'),
354
+ 'Conv2d': ('kyn.ml', 'Conv2d'),
355
+ 'CrossEntropyLoss': ('kyn.ml', 'CrossEntropyLoss'),
356
+ 'CóGiáTrị': ('kyn.super_runtime', 'CóGiáTrị'),
357
+ 'Có_Thể_Lặp': ('kyn.runtime', 'Có_Thể_Lặp'),
358
+ 'DEFAULT_CACHE_MANAGER': ('kyn.cache', 'DEFAULT_CACHE_MANAGER'),
359
+ 'DEFAULT_DOT_METHOD_TRIE': ('kyn.trie', 'DEFAULT_DOT_METHOD_TRIE'),
360
+ 'DEFAULT_KEYWORD_TRIE': ('kyn.trie', 'DEFAULT_KEYWORD_TRIE'),
361
+ 'DEFAULT_SOURCE_REGISTRY': ('kyn.diagnostics', 'DEFAULT_SOURCE_REGISTRY'),
362
+ 'DEFAULT_TRACEBACK_FORMATTER': ('kyn.diagnostics', 'DEFAULT_TRACEBACK_FORMATTER'),
363
+ 'DEFAULT_TRANSPILER': ('kyn.transpiler', 'DEFAULT_TRANSPILER'),
364
+ 'DOT_METHOD_DICTIONARY': ('kyn.lexicon', 'DOT_METHOD_DICTIONARY'),
365
+ 'DOT_PHRASE_FLAGS': ('kyn.lexicon', 'DOT_PHRASE_FLAGS'),
366
+ 'Danh_Sách': ('kyn.runtime', 'Danh_Sách'),
367
+ 'DataLoader': ('kyn.ml', 'DataLoader'),
368
+ 'DecisionTreeClassifier': ('kyn.ml', 'DecisionTreeClassifier'),
369
+ 'Dropout': ('kyn.ml', 'Dropout'),
370
+ 'EarlyStopping': ('kyn.ml', 'EarlyStopping'),
371
+ 'Effect': ('kyn.super_runtime', 'Effect'),
372
+ 'Embedding': ('kyn.ml', 'Embedding'),
373
+ 'Err': ('kyn.super_runtime', 'Err'),
374
+ 'Flatten': ('kyn.ml', 'Flatten'),
375
+ 'GLOBAL_DOT_METHOD_TRIE': ('kyn.trie', 'GLOBAL_DOT_METHOD_TRIE'),
376
+ 'GLOBAL_KEYWORD_TRIE': ('kyn.trie', 'GLOBAL_KEYWORD_TRIE'),
377
+ 'GLOBAL_TRANSPILER': ('kyn.transpiler', 'GLOBAL_TRANSPILER'),
378
+ 'GRU': ('kyn.ml', 'GRU'),
379
+ 'Generator': ('kyn.ml', 'Generator'),
380
+ 'Giao_Thức': ('kyn.runtime', 'Giao_Thức'),
381
+ 'Giá_Trị_Logic': ('kyn.runtime', 'Giá_Trị_Logic'),
382
+ 'HiệuỨng': ('kyn.super_runtime', 'HiệuỨng'),
383
+ 'HàngĐợiHaiĐầu': ('kyn.runtime', 'HàngĐợiHaiĐầu'),
384
+ 'HàngĐợiUT': ('kyn.runtime', 'HàngĐợiUT'),
385
+ 'HộpThoại': ('kyn.gui', 'HộpThoại'),
386
+ 'HộpVănBản': ('kyn.gui', 'HộpVănBản'),
387
+ 'Hợp': ('kyn.runtime', 'Hợp'),
388
+ 'InferenceEngine': ('kyn.ml', 'InferenceEngine'),
389
+ 'KMeans': ('kyn.ml', 'KMeans'),
390
+ 'KNeighborsClassifier': ('kyn.ml', 'KNeighborsClassifier'),
391
+ 'KhungDữLiệu': ('kyn.dataframe', 'KhungDữLiệu'),
392
+ 'KhóaLuồng': ('kyn.runtime', 'KhóaLuồng'),
393
+ 'Không_Có': ('kyn.runtime', 'Không_Có'),
394
+ 'KếtQuả': ('kyn.super_runtime', 'KếtQuả'),
395
+ 'KếtQuảLint': ('kyn.linter', 'KếtQuảLint'),
396
+ 'LEXICON_ENTRIES': ('kyn.lexicon', 'LEXICON_ENTRIES'),
397
+ 'LSTM': ('kyn.ml', 'LSTM'),
398
+ 'LazyModuleProxy': ('kyn.super_runtime', 'LazyModuleProxy'),
399
+ 'LexicalScopeManager': ('kyn.scope', 'LexicalScopeManager'),
400
+ 'LexiconAuditReport': ('kyn.lexicon', 'LexiconAuditReport'),
401
+ 'LexiconEntry': ('kyn.lexicon', 'LexiconEntry'),
402
+ 'Linear': ('kyn.ml', 'Linear'),
403
+ 'LinearRegression': ('kyn.ml', 'LinearRegression'),
404
+ 'LogisticRegression': ('kyn.ml', 'LogisticRegression'),
405
+ 'Luồng': ('kyn.runtime', 'Luồng'),
406
+ 'LuồngDữLiệu': ('kyn.super_runtime', 'LuồngDữLiệu'),
407
+ 'LínhCanh': ('kyn.super_runtime', 'LínhCanh'),
408
+ 'LỗiHằngSố': ('kyn.super_runtime', 'LỗiHằngSố'),
409
+ 'LỗiHợpĐồng': ('kyn.super_runtime', 'LỗiHợpĐồng'),
410
+ 'LớpCơSởTrừuTượng': ('kyn.runtime', 'LớpCơSởTrừuTượng'),
411
+ 'LớpNơRon': ('kyn.ai', 'LớpNơRon'),
412
+ 'LựaChọn': ('kyn.super_runtime', 'LựaChọn'),
413
+ 'MaTrận': ('kyn.tensor', 'MaTrận'),
414
+ 'Module': ('kyn.ml', 'Module'),
415
+ 'MultiheadAttention': ('kyn.ml', 'MultiheadAttention'),
416
+ 'MáyChủWeb': ('kyn.web_framework', 'MáyChủWeb'),
417
+ 'MạngNơRon': ('kyn.ai', 'MạngNơRon'),
418
+ 'MảngSố': ('kyn.tensor', 'MảngSố'),
419
+ 'NgănXếp': ('kyn.runtime', 'NgănXếp'),
420
+ 'Nhãn': ('kyn.gui', 'Nhãn'),
421
+ 'Nothing': ('kyn.super_runtime', 'Nothing'),
422
+ 'NútBấm': ('kyn.gui', 'NútBấm'),
423
+ 'Ok': ('kyn.super_runtime', 'Ok'),
424
+ 'Option': ('kyn.super_runtime', 'Option'),
425
+ 'PCA': ('kyn.ml', 'PCA'),
426
+ 'PYTHON_FIX_HELPERS': ('kyn.fixes', 'PYTHON_FIX_HELPERS'),
427
+ 'PhraseTrie': ('kyn.trie', 'PhraseTrie'),
428
+ 'PhraseTrieNode': ('kyn.trie', 'PhraseTrieNode'),
429
+ 'PhânTíchBộNhớ': ('kyn.profiler', 'PhânTíchBộNhớ'),
430
+ 'PhânTíchThờiGian': ('kyn.profiler', 'PhânTíchThờiGian'),
431
+ 'PhươngThứcTrừuTượng': ('kyn.runtime', 'PhươngThứcTrừuTượng'),
432
+ 'PhảnHồi': ('kyn.web_framework', 'PhảnHồi'),
433
+ 'KynASTOptimizer': ('kyn.optimizer', 'KynASTOptimizer'),
434
+ 'KynASTSanitizer': ('kyn.shield', 'KynASTSanitizer'),
435
+ 'KynCacheManager': ('kyn.cache', 'KynCacheManager'),
436
+ 'KynFormatter': ('kyn.formatter', 'KynFormatter'),
437
+ 'KynLSP': ('kyn.lsp', 'KynLSP'),
438
+ 'KynLinter': ('kyn.linter', 'KynLinter'),
439
+ 'KynMetaPathFinder': ('kyn.importer', 'KynMetaPathFinder'),
440
+ 'KynProfiler': ('kyn.profiler', 'KynProfiler'),
441
+ 'KynSmartREPL': ('kyn.repl', 'KynSmartREPL'),
442
+ 'KynSourceFileLoader': ('kyn.importer', 'KynSourceFileLoader'),
443
+ 'KynTranspiler': ('kyn.transpiler', 'KynTranspiler'),
444
+ 'PythonBugFixer': ('kyn.fixes', 'PythonBugFixer'),
445
+ 'RNN': ('kyn.ml', 'RNN'),
446
+ 'RandomForestClassifier': ('kyn.ml', 'RandomForestClassifier'),
447
+ 'Result': ('kyn.super_runtime', 'Result'),
448
+ 'Rỗng': ('kyn.super_runtime', 'Rỗng'),
449
+ 'SGD': ('kyn.ml', 'SGD'),
450
+ 'SUPER_RUNTIME_HELPERS': ('kyn.super_runtime', 'SUPER_RUNTIME_HELPERS'),
451
+ 'ScopeFrame': ('kyn.scope', 'ScopeFrame'),
452
+ 'Sequential': ('kyn.ml', 'Sequential'),
453
+ 'Signal': ('kyn.super_runtime', 'Signal'),
454
+ 'Some': ('kyn.super_runtime', 'Some'),
455
+ 'SourceMap': ('kyn.transpiler', 'SourceMap'),
456
+ 'SourceRegistry': ('kyn.diagnostics', 'SourceRegistry'),
457
+ 'StandardScaler': ('kyn.ml', 'StandardScaler'),
458
+ 'Stream': ('kyn.super_runtime', 'Stream'),
459
+ 'StyleReport': ('kyn.formatter', 'StyleReport'),
460
+ 'SuperASTTransformer': ('kyn.super_ast', 'SuperASTTransformer'),
461
+ 'Số_Nguyên': ('kyn.runtime', 'Số_Nguyên'),
462
+ 'Số_Thực': ('kyn.runtime', 'Số_Thực'),
463
+ 'SựKiệnLuồng': ('kyn.runtime', 'SựKiệnLuồng'),
464
+ 'Tensor': ('kyn.ml', 'Tensor'),
465
+ 'TensorDataset': ('kyn.ml', 'TensorDataset'),
466
+ 'ThanhTiếnTrình': ('kyn.terminal', 'ThanhTiếnTrình'),
467
+ 'ThànhCông': ('kyn.super_runtime', 'ThànhCông'),
468
+ 'ThấtBại': ('kyn.super_runtime', 'ThấtBại'),
469
+ 'Trainer': ('kyn.ml', 'Trainer'),
470
+ 'TranspileContext': ('kyn.transpiler', 'TranspileContext'),
471
+ 'Trình_Tạo': ('kyn.runtime', 'Trình_Tạo'),
472
+ 'TínHiệu': ('kyn.super_runtime', 'TínHiệu'),
473
+ 'TínhToán': ('kyn.super_runtime', 'TínhToán'),
474
+ 'Tùy_Chọn': ('kyn.runtime', 'Tùy_Chọn'),
475
+ 'Tập_Hợp': ('kyn.runtime', 'Tập_Hợp'),
476
+ 'Từ_Điển': ('kyn.runtime', 'Từ_Điển'),
477
+ 'TừĐiểnBấtBiến': ('kyn.super_runtime', 'TừĐiểnBấtBiến'),
478
+ 'TừĐiểnMặcĐịnh': ('kyn.runtime', 'TừĐiểnMặcĐịnh'),
479
+ 'VietnameseTracebackFormatter': ('kyn.diagnostics', 'VietnameseTracebackFormatter'),
480
+ 'YêuCầu': ('kyn.web_framework', 'YêuCầu'),
481
+ 'accuracy': ('kyn.ml', 'accuracy'),
482
+ 'apply_python_bug_fixes': ('kyn.fixes', 'apply_python_bug_fixes'),
483
+ 'apply_super_ast_transforms': ('kyn.super_ast', 'apply_super_ast_transforms'),
484
+ 'audit_lexicon': ('kyn.lexicon', 'audit_lexicon'),
485
+ 'batch': ('kyn.super_runtime', 'batch'),
486
+ 'build_model': ('kyn.ml', 'build_model'),
487
+ 'build_optimizer': ('kyn.ml', 'build_optimizer'),
488
+ 'build_phrase_trie': ('kyn.trie', 'build_phrase_trie'),
489
+ 'bình_phương': ('kyn.fixes', 'bình_phương'),
490
+ 'băm_chuỗi': ('kyn.fixes', 'băm_chuỗi'),
491
+ 'băm_hmac_sha256': ('kyn.crypto', 'băm_hmac_sha256'),
492
+ 'băm_md5': ('kyn.crypto', 'băm_md5'),
493
+ 'băm_sha256': ('kyn.crypto', 'băm_sha256'),
494
+ 'băm_sha512': ('kyn.crypto', 'băm_sha512'),
495
+ 'bắt_kết_quả': ('kyn.super_runtime', 'bắt_kết_quả'),
496
+ 'bộ_nhớ_đệm_lru': ('kyn.runtime', 'bộ_nhớ_đệm_lru'),
497
+ 'bội_chung_nhỏ_nhất': ('kyn.runtime', 'bội_chung_nhỏ_nhất'),
498
+ 'catch_result': ('kyn.super_runtime', 'catch_result'),
499
+ 'check_pyvn_source': ('kyn.cli', 'check_pyvn_source'),
500
+ 'check_pyvn_style': ('kyn.formatter', 'check_pyvn_style'),
501
+ 'chia_an_toàn': ('kyn.fixes', 'chia_an_toàn'),
502
+ 'chuyển_ngày_an_toàn': ('kyn.fixes', 'chuyển_ngày_an_toàn'),
503
+ 'chuyển_số_an_toàn': ('kyn.fixes', 'chuyển_số_an_toàn'),
504
+ 'chạy_bất_đồng_bộ': ('kyn.runtime', 'chạy_bất_đồng_bộ'),
505
+ 'chặn_giá_trị': ('kyn.fixes', 'chặn_giá_trị'),
506
+ 'contract': ('kyn.super_runtime', 'contract'),
507
+ 'cross_entropy': ('kyn.ml', 'cross_entropy'),
508
+ 'căn_bậc_hai': ('kyn.fixes', 'căn_bậc_hai'),
509
+ 'cắt_chuỗi_an_toàn': ('kyn.fixes', 'cắt_chuỗi_an_toàn'),
510
+ 'cộng_chính_xác': ('kyn.fixes', 'cộng_chính_xác'),
511
+ 'enforce_types': ('kyn.super_runtime', 'enforce_types'),
512
+ 'execute_kyn_source': ('kyn.cli', 'execute_kyn_source'),
513
+ 'export_to_html': ('kyn.html_exporter', 'export_to_html'),
514
+ 'fibonacci': ('kyn.runtime', 'fibonacci'),
515
+ 'format_pyvn_file': ('kyn.formatter', 'format_pyvn_file'),
516
+ 'frozendict': ('kyn.super_runtime', 'frozendict'),
517
+ 'ghi_csv': ('kyn.fixes', 'ghi_csv'),
518
+ 'ghi_json': ('kyn.fixes', 'ghi_json'),
519
+ 'ghi_nhật_ký': ('kyn.fixes', 'ghi_nhật_ký'),
520
+ 'ghi_nhớ': ('kyn.runtime', 'ghi_nhớ'),
521
+ 'ghi_thêm_tệp': ('kyn.fixes', 'ghi_thêm_tệp'),
522
+ 'ghi_tệp': ('kyn.fixes', 'ghi_tệp'),
523
+ 'giai_thừa': ('kyn.runtime', 'giai_thừa'),
524
+ 'giải_mã_base64': ('kyn.fixes', 'giải_mã_base64'),
525
+ 'giải_mã_chuỗi': ('kyn.crypto', 'giải_mã_chuỗi'),
526
+ 'gradcheck': ('kyn.ml', 'gradcheck'),
527
+ 'gần_bằng': ('kyn.fixes', 'gần_bằng'),
528
+ 'gộp_cập_nhật': ('kyn.super_runtime', 'gộp_cập_nhật'),
529
+ 'gộp_từ_điển': ('kyn.fixes', 'gộp_từ_điển'),
530
+ 'gửi_yêu_cầu_http': ('kyn.fixes', 'gửi_yêu_cầu_http'),
531
+ 'hợp_đồng': ('kyn.super_runtime', 'hợp_đồng'),
532
+ 'in_an_toàn': ('kyn.fixes', 'in_an_toàn'),
533
+ 'in_màu': ('kyn.terminal', 'in_màu'),
534
+ 'init_project': ('kyn.scaffold', 'init_project'),
535
+ 'inject_runtime_helpers': ('kyn.runtime', 'inject_runtime_helpers'),
536
+ 'install_pyvn_import_hook': ('kyn.importer', 'install_pyvn_import_hook'),
537
+ 'khẳng_định_bằng': ('kyn.runtime', 'khẳng_định_bằng'),
538
+ 'khẳng_định_ném_lỗi': ('kyn.runtime', 'khẳng_định_ném_lỗi'),
539
+ 'khẳng_định_sai': ('kyn.runtime', 'khẳng_định_sai'),
540
+ 'khẳng_định_đúng': ('kyn.runtime', 'khẳng_định_đúng'),
541
+ 'kiểm_tra_nguyên_tố': ('kyn.runtime', 'kiểm_tra_nguyên_tố'),
542
+ 'kiểm_tra_độ_mạnh_mật_khẩu': ('kyn.crypto', 'kiểm_tra_độ_mạnh_mật_khẩu'),
543
+ 'kết_nối_cơ_sở_dữ_liệu': ('kyn.runtime', 'kết_nối_cơ_sở_dữ_liệu'),
544
+ 'lint_file': ('kyn.linter', 'lint_file'),
545
+ 'lint_source': ('kyn.linter', 'lint_source'),
546
+ 'load_checkpoint': ('kyn.ml', 'load_checkpoint'),
547
+ 'load_lexicon_file': ('kyn.lexicon', 'load_lexicon_file'),
548
+ 'load_topic_lexicon_files': ('kyn.lexicon', 'load_topic_lexicon_files'),
549
+ 'loại_bỏ_trùng': ('kyn.fixes', 'loại_bỏ_trùng'),
550
+ 'làm_tròn': ('kyn.fixes', 'làm_tròn'),
551
+ 'làm_tròn_số_thực': ('kyn.runtime', 'làm_tròn_số_thực'),
552
+ 'lấy_an_toàn': ('kyn.fixes', 'lấy_an_toàn'),
553
+ 'lọc_an_toàn': ('kyn.fixes', 'lọc_an_toàn'),
554
+ 'lớp_dữ_liệu': ('kyn.runtime', 'lớp_dữ_liệu'),
555
+ 'main': ('kyn.cli', 'main'),
556
+ 'mse_loss': ('kyn.ml', 'mse_loss'),
557
+ 'mã_hóa_base64': ('kyn.fixes', 'mã_hóa_base64'),
558
+ 'mã_hóa_chuỗi': ('kyn.crypto', 'mã_hóa_chuỗi'),
559
+ 'mở_tệp': ('kyn.fixes', 'mở_tệp'),
560
+ 'nghỉ_bất_đồng_bộ': ('kyn.runtime', 'nghỉ_bất_đồng_bộ'),
561
+ 'nhập_số_nguyên': ('kyn.fixes', 'nhập_số_nguyên'),
562
+ 'nhập_số_thực': ('kyn.fixes', 'nhập_số_thực'),
563
+ 'nhập_đúng_sai': ('kyn.fixes', 'nhập_đúng_sai'),
564
+ 'nối_chuỗi': ('kyn.fixes', 'nối_chuỗi'),
565
+ 'optimize_ast': ('kyn.optimizer', 'optimize_ast'),
566
+ 'phản_hồi_html': ('kyn.web_framework', 'phản_hồi_html'),
567
+ 'phản_hồi_json': ('kyn.web_framework', 'phản_hồi_json'),
568
+ 'phẳng_hóa': ('kyn.fixes', 'phẳng_hóa'),
569
+ 'preprocess_super_syntax': ('kyn.super_syntax', 'preprocess_super_syntax'),
570
+ 'python_to_pyvn': ('kyn.transpiler', 'python_to_pyvn'),
571
+ 'relu': ('kyn.tensor', 'relu'),
572
+ 'round_float': ('kyn.runtime', 'round_float'),
573
+ 'run_benchmark': ('kyn.bench', 'run_benchmark'),
574
+ 'run_pyvn_doctor': ('kyn.doctor', 'run_pyvn_doctor'),
575
+ 'sao_chép_sâu': ('kyn.fixes', 'sao_chép_sâu'),
576
+ 'save_checkpoint': ('kyn.ml', 'save_checkpoint'),
577
+ 'seed_everything': ('kyn.ml', 'seed_everything'),
578
+ 'sentinel': ('kyn.super_runtime', 'sentinel'),
579
+ 'sigmoid': ('kyn.tensor', 'sigmoid'),
580
+ 'sinh_mật_khẩu_an_toàn': ('kyn.crypto', 'sinh_mật_khẩu_an_toàn'),
581
+ 'so_sánh_hiệu_suất': ('kyn.profiler', 'so_sánh_hiệu_suất'),
582
+ 'so_sánh_ngày': ('kyn.fixes', 'so_sánh_ngày'),
583
+ 'softmax': ('kyn.tensor', 'softmax'),
584
+ 'start_lsp_server': ('kyn.lsp', 'start_lsp_server'),
585
+ 'start_web_ide': ('kyn.web_server', 'start_web_ide'),
586
+ 'strip_vietnamese_accents': ('kyn.lexicon', 'strip_vietnamese_accents'),
587
+ 'sắp_xếp_an_toàn': ('kyn.fixes', 'sắp_xếp_an_toàn'),
588
+ 'sắp_xếp_nhanh': ('kyn.runtime', 'sắp_xếp_nhanh'),
589
+ 'số_thực_chính_xác': ('kyn.fixes', 'số_thực_chính_xác'),
590
+ 'tail_call': ('kyn.super_runtime', 'tail_call'),
591
+ 'tco': ('kyn.super_runtime', 'tco'),
592
+ 'thử_lại': ('kyn.runtime', 'thử_lại'),
593
+ 'train_test_split': ('kyn.ml', 'train_test_split'),
594
+ 'trung_bình_chính_xác': ('kyn.fixes', 'trung_bình_chính_xác'),
595
+ 'tìm_kiếm_an_toàn': ('kyn.fixes', 'tìm_kiếm_an_toàn'),
596
+ 'tìm_kiếm_nhị_phân': ('kyn.runtime', 'tìm_kiếm_nhị_phân'),
597
+ 'tính_chuẩn': ('kyn.runtime', 'tính_chuẩn'),
598
+ 'tô_màu': ('kyn.terminal', 'tô_màu'),
599
+ 'tạo_ma_trận': ('kyn.fixes', 'tạo_ma_trận'),
600
+ 'tạo_ma_trận_đơn_vị': ('kyn.tensor', 'tạo_ma_trận_đơn_vị'),
601
+ 'tạo_token_jwt': ('kyn.crypto', 'tạo_token_jwt'),
602
+ 'tạo_tác_vụ_async': ('kyn.runtime', 'tạo_tác_vụ_async'),
603
+ 'tạo_uuid': ('kyn.fixes', 'tạo_uuid'),
604
+ 'tối_ưu_đuôi': ('kyn.super_runtime', 'tối_ưu_đuôi'),
605
+ 'tồn_tại_thư_mục': ('kyn.fixes', 'tồn_tại_thư_mục'),
606
+ 'tồn_tại_tệp': ('kyn.fixes', 'tồn_tại_tệp'),
607
+ 'xác_thực_token_jwt': ('kyn.crypto', 'xác_thực_token_jwt'),
608
+ 'xóa_an_toàn': ('kyn.fixes', 'xóa_an_toàn'),
609
+ 'ÔNhập': ('kyn.gui', 'ÔNhập'),
610
+ 'ánh_xạ_an_toàn': ('kyn.fixes', 'ánh_xạ_an_toàn'),
611
+ 'ép_kiểu': ('kyn.super_runtime', 'ép_kiểu'),
612
+ 'ĐườngDẫn': ('kyn.runtime', 'ĐườngDẫn'),
613
+ 'Đường_Dẫn': ('kyn.runtime', 'Đường_Dẫn'),
614
+ 'ĐồThị': ('kyn.runtime', 'ĐồThị'),
615
+ 'ĐồngHồBấmGiờ': ('kyn.runtime', 'ĐồngHồBấmGiờ'),
616
+ 'đo_bộ_nhớ': ('kyn.profiler', 'đo_bộ_nhớ'),
617
+ 'đo_thời_gian': ('kyn.profiler', 'đo_thời_gian'),
618
+ 'đánh_giá_độ_phức_tạp': ('kyn.profiler', 'đánh_giá_độ_phức_tạp'),
619
+ 'đếm_phần_tử': ('kyn.fixes', 'đếm_phần_tử'),
620
+ 'đệ_quy_đuôi': ('kyn.super_runtime', 'đệ_quy_đuôi'),
621
+ 'định_dạng_ngày': ('kyn.fixes', 'định_dạng_ngày'),
622
+ 'định_dạng_số': ('kyn.fixes', 'định_dạng_số'),
623
+ 'đọc_csv': ('kyn.fixes', 'đọc_csv'),
624
+ 'đọc_dòng_tệp': ('kyn.fixes', 'đọc_dòng_tệp'),
625
+ 'đọc_json': ('kyn.fixes', 'đọc_json'),
626
+ 'đọc_tệp': ('kyn.fixes', 'đọc_tệp'),
627
+ 'ước_chung_lớn_nhất': ('kyn.runtime', 'ước_chung_lớn_nhất'),
628
+ 'ỨngDụngCửaSổ': ('kyn.gui', 'ỨngDụngCửaSổ'),
629
+ }
630
+
631
+ def __getattr__(name: str): # PEP 562 lazy loading
632
+ """Nạp lười API công khai khi truy cập `kyn.<name>` lần đầu."""
633
+ if name == "ml":
634
+ mod = _importlib.import_module("kyn.ml")
635
+ globals()["ml"] = mod
636
+ return mod
637
+ loc = _LAZY_EXPORTS.get(name)
638
+ if loc is None:
639
+ raise AttributeError(f"module 'kyn' has no attribute {name!r}")
640
+ module_name, attr = loc
641
+ mod = _importlib.import_module(module_name)
642
+ try:
643
+ value = getattr(mod, attr)
644
+ except AttributeError as exc:
645
+ raise AttributeError(f"module {module_name!r} has no attribute {attr!r} (requested as kyn.{name})") from exc
646
+ globals()[name] = value
647
+ return value
648
+
649
+ def __dir__():
650
+ """`dir(kyn)` liệt kê đầy đủ 303 exports kể cả chưa nạp."""
651
+ return sorted(set(globals()) | set(_LAZY_EXPORTS) | {"ml"})
652
+
653
+ _LAZY_EXPORTS["ml"] = ("kyn.ml", "ml") # for introspection consistency
kyn/__main__.py ADDED
@@ -0,0 +1,21 @@
1
+ """
2
+ Điểm vào thực thi gói `python -m kyn` (`kyn/__main__.py`).
3
+
4
+ Fast-path (Phase 2): `--version`/`-V`/`version` được trả lời ngay từ
5
+ `_version` (nhẹ, không import `cli`/transpiler/lexicon), nên
6
+ `python -m kyn --version` chạy trong vài chục mili-giây thay vì
7
+ ~2 giây như trước. Mọi lệnh khác vẫn đi qua `kyn.cli:main` như cũ.
8
+ """
9
+
10
+ import sys
11
+
12
+ if __name__ == "__main__":
13
+ _args = sys.argv[1:]
14
+ if _args and _args[0] in ("--version", "-V", "version", "phien_ban"):
15
+ from ._version import BRIDGE_VERSION, ENGINE_VERSION, ML_VERSION
16
+
17
+ print(f"Kyn v{BRIDGE_VERSION} (bridge {BRIDGE_VERSION} / engine {ENGINE_VERSION} / ml {ML_VERSION})")
18
+ sys.exit(0)
19
+ from .cli import main
20
+
21
+ sys.exit(main())