kotoshu 1.0.2-aarch64-linux

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 (458) hide show
  1. checksums.yaml +7 -0
  2. data/.kotoshu-baseline.json +1 -0
  3. data/.pre-commit-hooks.yaml +18 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +351 -0
  6. data/.yardopts +8 -0
  7. data/CHANGELOG.md +813 -0
  8. data/CLAUDE.md +176 -0
  9. data/CODE_OF_CONDUCT.md +132 -0
  10. data/Cargo.lock +359 -0
  11. data/Cargo.toml +15 -0
  12. data/LICENSE +31 -0
  13. data/README.adoc +1292 -0
  14. data/Rakefile +150 -0
  15. data/SECURITY.md +93 -0
  16. data/TODO.impl/00-cut-0.1.md +121 -0
  17. data/TODO.impl/00-cut-0.2.md +175 -0
  18. data/TODO.impl/00-vision.md +281 -0
  19. data/TODO.impl/01-hunspell-correctness.md +111 -0
  20. data/TODO.impl/02-cli-unification.md +74 -0
  21. data/TODO.impl/03-dynamic-download.md +107 -0
  22. data/TODO.impl/04-language-modules.md +89 -0
  23. data/TODO.impl/05-semantic-path.md +83 -0
  24. data/TODO.impl/06-cjk-support.md +105 -0
  25. data/TODO.impl/07-rtl-support.md +71 -0
  26. data/TODO.impl/08-grammar-engine.md +106 -0
  27. data/TODO.impl/09-integrity-security.md +90 -0
  28. data/TODO.impl/10-testing-ci.md +98 -0
  29. data/TODO.impl/100-full-feature-batch3.md +28 -0
  30. data/TODO.impl/101-int4-tier-experiment.md +32 -0
  31. data/TODO.impl/102-lid-chain.md +28 -0
  32. data/TODO.impl/103-oov-bucket-tables.md +27 -0
  33. data/TODO.impl/104-vscode-marketplace-readiness.md +32 -0
  34. data/TODO.impl/105-personal-dictionary-in-check.md +34 -0
  35. data/TODO.impl/106-native-lid-detection.md +36 -0
  36. data/TODO.impl/107-basic-support-every-staged-language.md +42 -0
  37. data/TODO.impl/108-ko-ne-full-feature.md +37 -0
  38. data/TODO.impl/109-ten-audit.md +26 -0
  39. data/TODO.impl/11-release-v1.md +95 -0
  40. data/TODO.impl/110-sr-latn-and-polish.md +33 -0
  41. data/TODO.impl/111-embedding-bakeoff.md +33 -0
  42. data/TODO.impl/112-deployability-and-gating.md +26 -0
  43. data/TODO.impl/113-language-packs.md +26 -0
  44. data/TODO.impl/114-typo-biencoder-thread.md +33 -0
  45. data/TODO.impl/115-hybrid-retrieval-pricing.md +22 -0
  46. data/TODO.impl/116-baseline-suggestion-skip.md +81 -0
  47. data/TODO.impl/117-deterministic-frequency-tiers.md +110 -0
  48. data/TODO.impl/118-server-gem-floor.md +33 -0
  49. data/TODO.impl/119-embedded-kelly-tiers.md +56 -0
  50. data/TODO.impl/120-setup-metadata-refresh.md +35 -0
  51. data/TODO.impl/121-jekyll-baseline-skip.md +33 -0
  52. data/TODO.impl/122-pack-compression-kpk2.md +66 -0
  53. data/TODO.impl/123-typo-corpus-synthesis.md +55 -0
  54. data/TODO.impl/124-owner-residue.md +19 -0
  55. data/TODO.impl/125-consumer-floor-guards.md +43 -0
  56. data/TODO.impl/126-tier-error-budgets.md +33 -0
  57. data/TODO.impl/127-suggestion-feedback-loop.md +34 -0
  58. data/TODO.impl/128-hybrid-pricing-verdict.md +47 -0
  59. data/TODO.impl/129-pt-fr-corpora.md +23 -0
  60. data/TODO.impl/130-news-truth-0912.md +23 -0
  61. data/TODO.impl/131-hybrid-productization.md +42 -0
  62. data/TODO.impl/132-techniques-page-and-prose.md +27 -0
  63. data/TODO.impl/133-rust-first-distribution.md +68 -0
  64. data/TODO.impl/20-encapsulation-cleanup.md +47 -0
  65. data/TODO.impl/21-autoload-migration.md +64 -0
  66. data/TODO.impl/22-url-pin-single-source-of-truth.md +120 -0
  67. data/TODO.impl/23-fix-url-defaults.md +57 -0
  68. data/TODO.impl/24-cli-auto-setup-prompt.md +76 -0
  69. data/TODO.impl/25-soft-onnxruntime-require.md +75 -0
  70. data/TODO.impl/26-onnx-vocab-json-generation.md +96 -0
  71. data/TODO.impl/27-end-to-end-smoke-spec.md +113 -0
  72. data/TODO.impl/28-readme-quickstart-verification.md +68 -0
  73. data/TODO.impl/29-status-command.md +84 -0
  74. data/TODO.impl/30-language-auto-detection.md +74 -0
  75. data/TODO.impl/31-download-progress.md +58 -0
  76. data/TODO.impl/32-sarif-output-verification.md +72 -0
  77. data/TODO.impl/33-audit-log-rotation.md +54 -0
  78. data/TODO.impl/34-cache-eviction.md +59 -0
  79. data/TODO.impl/35-shell-completion.md +61 -0
  80. data/TODO.impl/36-cleanup-regressions-0.3.1.md +134 -0
  81. data/TODO.impl/37-hunspell-correctness-tier2.md +203 -0
  82. data/TODO.impl/38-onnx-semantic-gating.md +218 -0
  83. data/TODO.impl/39-tier3-and-beyond.md +232 -0
  84. data/TODO.impl/40-spec-drift-cleanup.md +134 -0
  85. data/TODO.impl/50-structure-aware-document-api.md +194 -0
  86. data/TODO.impl/51-grammar-engine-expansion.md +75 -0
  87. data/TODO.impl/52-multi-language-documents.md +95 -0
  88. data/TODO.impl/53-document-plugin-architecture.md +94 -0
  89. data/TODO.impl/54-cjk-support.md +117 -0
  90. data/TODO.impl/55-rtl-support.md +109 -0
  91. data/TODO.impl/56-t4-t5-t6-quality-architecture-ecosystem.md +126 -0
  92. data/TODO.impl/57-t5.1-step3-pure-function-strategies.md +138 -0
  93. data/TODO.impl/58-t5.2-configuration-as-data.md +113 -0
  94. data/TODO.impl/59-yard-api-documentation.md +75 -0
  95. data/TODO.impl/60-lsp-server.md +174 -0
  96. data/TODO.impl/61-editor-ecosystem.md +167 -0
  97. data/TODO.impl/62-framework-integrations.md +159 -0
  98. data/TODO.impl/63-web-playground-wasm.md +186 -0
  99. data/TODO.impl/64-http-api-and-sdks.md +191 -0
  100. data/TODO.impl/65-universal-kotoshu.md +251 -0
  101. data/TODO.impl/66-kotoshu-core.md +169 -0
  102. data/TODO.impl/67-kotoshu-rs-and-access-libraries.md +137 -0
  103. data/TODO.impl/68-sota-adoption.md +152 -0
  104. data/TODO.impl/69-sota-typo-eval.md +74 -0
  105. data/TODO.impl/70-sota-confidence-cascade.md +59 -0
  106. data/TODO.impl/71-sota-nested-model.md +63 -0
  107. data/TODO.impl/72-model2vec-evaluation.md +49 -0
  108. data/TODO.impl/73-rl-reranker.md +42 -0
  109. data/TODO.impl/74-distilled-reranker.md +36 -0
  110. data/TODO.impl/75-llm-evaluator.md +35 -0
  111. data/TODO.impl/76-optional-llm-backend.md +37 -0
  112. data/TODO.impl/77-model-coverage-expansion.md +96 -0
  113. data/TODO.impl/78-in-browser-playground.md +69 -0
  114. data/TODO.impl/79-news-and-releases.md +60 -0
  115. data/TODO.impl/80-ecosystem-docs.md +56 -0
  116. data/TODO.impl/81-editor-reach.md +68 -0
  117. data/TODO.impl/82-doc-formats-and-ignores.md +81 -0
  118. data/TODO.impl/83-models-batch-2.md +56 -0
  119. data/TODO.impl/84-language-modules-wave2.md +75 -0
  120. data/TODO.impl/85-wasm-model-api.md +48 -0
  121. data/TODO.impl/86-site-truth-wave2.md +45 -0
  122. data/TODO.impl/87-lsp-personal-dictionary.md +36 -0
  123. data/TODO.impl/88-cli-directory-mode.md +54 -0
  124. data/TODO.impl/89-framework-integrations-exec.md +59 -0
  125. data/TODO.impl/90-gem-correctness-residues.md +44 -0
  126. data/TODO.impl/91-unicode-and-sv-aff.md +47 -0
  127. data/TODO.impl/92-tier-mirror-cors.md +88 -0
  128. data/TODO.impl/93-python-wheels.md +32 -0
  129. data/TODO.impl/94-site-integrations-docs.md +35 -0
  130. data/TODO.impl/95-editor-action-polish.md +27 -0
  131. data/TODO.impl/96-server-semantic-models.md +50 -0
  132. data/TODO.impl/97-yard-execution.md +73 -0
  133. data/TODO.impl/98-campaign-cleanup.md +78 -0
  134. data/TODO.impl/99-site-truth-performance-docs.md +31 -0
  135. data/conformance/vectors.jsonl +2630 -0
  136. data/data/en/grammar/rules.yaml +851 -0
  137. data/docs/STABILITY-1.0-AUDIT.md +251 -0
  138. data/docs/STABILITY-1.0.md +137 -0
  139. data/docs/cache-architecture.md +502 -0
  140. data/docs/verification-evidence/correct3/pr_body.md +37 -0
  141. data/docs/verification-evidence/correct3/rspec_final.log +5588 -0
  142. data/docs/verification-evidence/correct3/rspec_full.log +4504 -0
  143. data/docs/verification-evidence/correct3/sv.aff +856 -0
  144. data/docs/verification-evidence/correct3/sv.dic +153717 -0
  145. data/examples/01_basic_word_checking.rb +38 -0
  146. data/examples/02_text_document_checking.rb +77 -0
  147. data/examples/03_dictionary_backends.rb +137 -0
  148. data/examples/04_trie_data_structure.rb +146 -0
  149. data/examples/05_suggestion_algorithms.rb +239 -0
  150. data/examples/06_configuration_advanced.rb +287 -0
  151. data/examples/07_multi_language_dictionaries.rb +278 -0
  152. data/exe/kotoshu +6 -0
  153. data/lib/kotoshu/algorithms/capitalization.rb +276 -0
  154. data/lib/kotoshu/algorithms/edit_distance.rb +128 -0
  155. data/lib/kotoshu/algorithms/lookup/affix_form.rb +132 -0
  156. data/lib/kotoshu/algorithms/lookup/compound_checks.rb +209 -0
  157. data/lib/kotoshu/algorithms/lookup/compound_form.rb +50 -0
  158. data/lib/kotoshu/algorithms/lookup.rb +841 -0
  159. data/lib/kotoshu/algorithms/ngram_suggest.rb +367 -0
  160. data/lib/kotoshu/algorithms/permutations.rb +283 -0
  161. data/lib/kotoshu/algorithms/phonet_suggest.rb +162 -0
  162. data/lib/kotoshu/algorithms/soundex.rb +92 -0
  163. data/lib/kotoshu/algorithms/suggest.rb +794 -0
  164. data/lib/kotoshu/algorithms.rb +23 -0
  165. data/lib/kotoshu/analyzers/semantic_analyzer.rb +405 -0
  166. data/lib/kotoshu/analyzers.rb +8 -0
  167. data/lib/kotoshu/baseline/application.rb +18 -0
  168. data/lib/kotoshu/baseline/entry.rb +33 -0
  169. data/lib/kotoshu/baseline/store.rb +175 -0
  170. data/lib/kotoshu/baseline.rb +20 -0
  171. data/lib/kotoshu/cache/base_cache.rb +778 -0
  172. data/lib/kotoshu/cache/cache.rb +91 -0
  173. data/lib/kotoshu/cache/eviction_policy.rb +66 -0
  174. data/lib/kotoshu/cache/frequency_cache.rb +283 -0
  175. data/lib/kotoshu/cache/language_cache.rb +511 -0
  176. data/lib/kotoshu/cache/lookup_cache.rb +166 -0
  177. data/lib/kotoshu/cache/model_cache.rb +1147 -0
  178. data/lib/kotoshu/cache/model_registry.rb +109 -0
  179. data/lib/kotoshu/cache/staged_languages.rb +45 -0
  180. data/lib/kotoshu/cache/suggestion_cache.rb +113 -0
  181. data/lib/kotoshu/cache.rb +49 -0
  182. data/lib/kotoshu/cli/auto_setup.rb +71 -0
  183. data/lib/kotoshu/cli/baseline_command.rb +119 -0
  184. data/lib/kotoshu/cli/batch_reporter.rb +321 -0
  185. data/lib/kotoshu/cli/cache_command.rb +282 -0
  186. data/lib/kotoshu/cli/completions_command.rb +210 -0
  187. data/lib/kotoshu/cli/dict_command.rb +64 -0
  188. data/lib/kotoshu/cli/directory_check.rb +146 -0
  189. data/lib/kotoshu/cli/directory_walker.rb +132 -0
  190. data/lib/kotoshu/cli/display_formatter.rb +429 -0
  191. data/lib/kotoshu/cli/errors.rb +36 -0
  192. data/lib/kotoshu/cli/ignore_matcher.rb +205 -0
  193. data/lib/kotoshu/cli/interactive_reviewer.rb +314 -0
  194. data/lib/kotoshu/cli/language_resolver.rb +91 -0
  195. data/lib/kotoshu/cli/navigation_manager.rb +273 -0
  196. data/lib/kotoshu/cli/personal_command.rb +113 -0
  197. data/lib/kotoshu/cli/progress_reporter.rb +114 -0
  198. data/lib/kotoshu/cli/status_report.rb +130 -0
  199. data/lib/kotoshu/cli.rb +880 -0
  200. data/lib/kotoshu/components/passthrough_spell_checker.rb +70 -0
  201. data/lib/kotoshu/components/pos_tagger.rb +98 -0
  202. data/lib/kotoshu/components/spell_checker.rb +73 -0
  203. data/lib/kotoshu/components/synthesizer.rb +60 -0
  204. data/lib/kotoshu/components/tokenizer.rb +58 -0
  205. data/lib/kotoshu/components/whitespace_tokenizer.rb +94 -0
  206. data/lib/kotoshu/components.rb +13 -0
  207. data/lib/kotoshu/configuration/builder.rb +207 -0
  208. data/lib/kotoshu/configuration/resolver.rb +124 -0
  209. data/lib/kotoshu/configuration.rb +829 -0
  210. data/lib/kotoshu/conformance_exporter.rb +256 -0
  211. data/lib/kotoshu/conformance_runner.rb +176 -0
  212. data/lib/kotoshu/core/exceptions.rb +186 -0
  213. data/lib/kotoshu/core/indexed_dictionary.rb +293 -0
  214. data/lib/kotoshu/core/models/affix_rule.rb +262 -0
  215. data/lib/kotoshu/core/models/result/document_result.rb +132 -0
  216. data/lib/kotoshu/core/models/result/word_result.rb +131 -0
  217. data/lib/kotoshu/core/models/word.rb +131 -0
  218. data/lib/kotoshu/core/trie/builder.rb +119 -0
  219. data/lib/kotoshu/core/trie/node.rb +94 -0
  220. data/lib/kotoshu/core/trie/trie.rb +249 -0
  221. data/lib/kotoshu/core.rb +28 -0
  222. data/lib/kotoshu/data/common_words/de.yml +1800 -0
  223. data/lib/kotoshu/data/common_words/en.yml +1215 -0
  224. data/lib/kotoshu/data/common_words/es.yml +750 -0
  225. data/lib/kotoshu/data/common_words/fr.yml +1015 -0
  226. data/lib/kotoshu/data/common_words/pt.yml +870 -0
  227. data/lib/kotoshu/data/common_words/ru.yml +484 -0
  228. data/lib/kotoshu/data/common_words_loader.rb +141 -0
  229. data/lib/kotoshu/data/frozen_kelly/en.json +1154 -0
  230. data/lib/kotoshu/data/frozen_kelly.rb +38 -0
  231. data/lib/kotoshu/data.rb +8 -0
  232. data/lib/kotoshu/data_structures/bloom_filter.rb +188 -0
  233. data/lib/kotoshu/data_structures.rb +8 -0
  234. data/lib/kotoshu/debug_logger.rb +146 -0
  235. data/lib/kotoshu/debug_mode.rb +136 -0
  236. data/lib/kotoshu/defaults.rb +84 -0
  237. data/lib/kotoshu/dictionaries/catalog.rb +814 -0
  238. data/lib/kotoshu/dictionaries.rb +8 -0
  239. data/lib/kotoshu/dictionary/base.rb +324 -0
  240. data/lib/kotoshu/dictionary/cspell.rb +243 -0
  241. data/lib/kotoshu/dictionary/custom.rb +225 -0
  242. data/lib/kotoshu/dictionary/hunspell.rb +520 -0
  243. data/lib/kotoshu/dictionary/plain_text.rb +302 -0
  244. data/lib/kotoshu/dictionary/repository.rb +246 -0
  245. data/lib/kotoshu/dictionary/unified.rb +236 -0
  246. data/lib/kotoshu/dictionary/unix_words.rb +218 -0
  247. data/lib/kotoshu/dictionary.rb +15 -0
  248. data/lib/kotoshu/documents/document.rb +120 -0
  249. data/lib/kotoshu/documents/plain_text_document.rb +73 -0
  250. data/lib/kotoshu/documents/source_position.rb +45 -0
  251. data/lib/kotoshu/documents/source_range.rb +76 -0
  252. data/lib/kotoshu/documents/suppressions/scanner.rb +149 -0
  253. data/lib/kotoshu/documents/suppressions/suppression.rb +75 -0
  254. data/lib/kotoshu/documents/suppressions.rb +44 -0
  255. data/lib/kotoshu/documents/text_node.rb +49 -0
  256. data/lib/kotoshu/documents.rb +178 -0
  257. data/lib/kotoshu/embeddings/embedding_pipeline.rb +238 -0
  258. data/lib/kotoshu/embeddings/lru_cache.rb +244 -0
  259. data/lib/kotoshu/embeddings/onnx_runtime_model.rb +411 -0
  260. data/lib/kotoshu/embeddings/protocol.rb +96 -0
  261. data/lib/kotoshu/embeddings/protocols.rb +23 -0
  262. data/lib/kotoshu/embeddings/registry.rb +184 -0
  263. data/lib/kotoshu/embeddings/search.rb +204 -0
  264. data/lib/kotoshu/embeddings/similarity_engine.rb +278 -0
  265. data/lib/kotoshu/embeddings/similarity_search.rb +328 -0
  266. data/lib/kotoshu/embeddings/vocabulary.rb +306 -0
  267. data/lib/kotoshu/embeddings.rb +87 -0
  268. data/lib/kotoshu/fluent_checker.rb +94 -0
  269. data/lib/kotoshu/grammar/pattern_matchers/base_matcher.rb +48 -0
  270. data/lib/kotoshu/grammar/pattern_matchers/double_negative_matcher.rb +179 -0
  271. data/lib/kotoshu/grammar/pattern_matchers/phrase_matcher.rb +86 -0
  272. data/lib/kotoshu/grammar/pattern_matchers/possessive_context_matcher.rb +75 -0
  273. data/lib/kotoshu/grammar/pattern_matchers/possessive_contraction_matcher.rb +87 -0
  274. data/lib/kotoshu/grammar/pattern_matchers/sentence_start_matcher.rb +84 -0
  275. data/lib/kotoshu/grammar/pattern_matchers/vowel_sound_matcher.rb +81 -0
  276. data/lib/kotoshu/grammar/pattern_matchers/word_list_matcher.rb +66 -0
  277. data/lib/kotoshu/grammar/rule.rb +99 -0
  278. data/lib/kotoshu/grammar/rule_engine.rb +96 -0
  279. data/lib/kotoshu/grammar/rule_loader.rb +30 -0
  280. data/lib/kotoshu/grammar.rb +24 -0
  281. data/lib/kotoshu/integrity/audit_log.rb +167 -0
  282. data/lib/kotoshu/integrity/manifest.rb +116 -0
  283. data/lib/kotoshu/integrity/net_http.rb +51 -0
  284. data/lib/kotoshu/integrity/rotation_policy.rb +88 -0
  285. data/lib/kotoshu/integrity.rb +26 -0
  286. data/lib/kotoshu/jekyll.rb +101 -0
  287. data/lib/kotoshu/keyboard/layout.rb +116 -0
  288. data/lib/kotoshu/keyboard/layouts/arabic.rb +59 -0
  289. data/lib/kotoshu/keyboard/layouts/azerty.rb +55 -0
  290. data/lib/kotoshu/keyboard/layouts/bulgarian.rb +57 -0
  291. data/lib/kotoshu/keyboard/layouts/devanagari_inscript.rb +52 -0
  292. data/lib/kotoshu/keyboard/layouts/dubeolsik.rb +56 -0
  293. data/lib/kotoshu/keyboard/layouts/dvorak.rb +54 -0
  294. data/lib/kotoshu/keyboard/layouts/greek.rb +52 -0
  295. data/lib/kotoshu/keyboard/layouts/hebrew.rb +57 -0
  296. data/lib/kotoshu/keyboard/layouts/hrsl.rb +94 -0
  297. data/lib/kotoshu/keyboard/layouts/jcuken.rb +57 -0
  298. data/lib/kotoshu/keyboard/layouts/latin.rb +266 -0
  299. data/lib/kotoshu/keyboard/layouts/persian.rb +58 -0
  300. data/lib/kotoshu/keyboard/layouts/qwerty.rb +52 -0
  301. data/lib/kotoshu/keyboard/layouts/qwertz.rb +55 -0
  302. data/lib/kotoshu/keyboard/layouts/serbian.rb +59 -0
  303. data/lib/kotoshu/keyboard/layouts/turkish_q.rb +52 -0
  304. data/lib/kotoshu/keyboard/layouts/ukrainian.rb +51 -0
  305. data/lib/kotoshu/keyboard/registry.rb +201 -0
  306. data/lib/kotoshu/keyboard.rb +96 -0
  307. data/lib/kotoshu/kotoshu_native.so +0 -0
  308. data/lib/kotoshu/language/detector.rb +242 -0
  309. data/lib/kotoshu/language/identifier.rb +376 -0
  310. data/lib/kotoshu/language/languages/base.rb +271 -0
  311. data/lib/kotoshu/language/lid_detector.rb +188 -0
  312. data/lib/kotoshu/language/normalizer/arabic.rb +113 -0
  313. data/lib/kotoshu/language/normalizer/base.rb +133 -0
  314. data/lib/kotoshu/language/normalizer/greek.rb +63 -0
  315. data/lib/kotoshu/language/normalizer/hebrew.rb +72 -0
  316. data/lib/kotoshu/language/normalizer/persian.rb +36 -0
  317. data/lib/kotoshu/language/normalizer/turkish.rb +38 -0
  318. data/lib/kotoshu/language/registry.rb +209 -0
  319. data/lib/kotoshu/language/resources/ar/common_words.txt +6753 -0
  320. data/lib/kotoshu/language/resources/ar/confusion_sets.txt +11 -0
  321. data/lib/kotoshu/language/resources/de/common_words.txt +10003 -0
  322. data/lib/kotoshu/language/resources/de/confusion_sets.txt +246 -0
  323. data/lib/kotoshu/language/resources/en/common_words.txt +9979 -0
  324. data/lib/kotoshu/language/resources/en/confusion_sets.txt +871 -0
  325. data/lib/kotoshu/language/resources/es/common_words.txt +9992 -0
  326. data/lib/kotoshu/language/resources/es/confusion_sets.txt +17 -0
  327. data/lib/kotoshu/language/resources/fr/common_words.txt +9993 -0
  328. data/lib/kotoshu/language/resources/fr/confusion_sets.txt +76 -0
  329. data/lib/kotoshu/language/resources/pt/common_words.txt +9977 -0
  330. data/lib/kotoshu/language/resources/pt/confusion_sets.txt +18 -0
  331. data/lib/kotoshu/language/resources/ru/common_words.txt +9951 -0
  332. data/lib/kotoshu/language/resources/ru/confusion_sets.txt +5 -0
  333. data/lib/kotoshu/language/script.rb +128 -0
  334. data/lib/kotoshu/language/segmenter.rb +122 -0
  335. data/lib/kotoshu/language/suika.rb +38 -0
  336. data/lib/kotoshu/language/tokenizer/base.rb +187 -0
  337. data/lib/kotoshu/language/tokenizer/cyrillic_tokenizer.rb +76 -0
  338. data/lib/kotoshu/language/tokenizer/devanagari_tokenizer.rb +70 -0
  339. data/lib/kotoshu/language/tokenizer/french_tokenizer.rb +172 -0
  340. data/lib/kotoshu/language/tokenizer/german_tokenizer.rb +41 -0
  341. data/lib/kotoshu/language/tokenizer/greek_tokenizer.rb +72 -0
  342. data/lib/kotoshu/language/tokenizer/hangul_tokenizer.rb +70 -0
  343. data/lib/kotoshu/language/tokenizer/japanese_tokenizer.rb +55 -0
  344. data/lib/kotoshu/language/tokenizer/latin_tokenizer.rb +153 -0
  345. data/lib/kotoshu/language/tokenizer/portuguese_tokenizer.rb +160 -0
  346. data/lib/kotoshu/language/tokenizer/russian_tokenizer.rb +93 -0
  347. data/lib/kotoshu/language/tokenizer/script_tokenizer.rb +62 -0
  348. data/lib/kotoshu/language/tokenizer/spanish_tokenizer.rb +122 -0
  349. data/lib/kotoshu/language.rb +127 -0
  350. data/lib/kotoshu/languages/ar/language.rb +98 -0
  351. data/lib/kotoshu/languages/bg/language.rb +37 -0
  352. data/lib/kotoshu/languages/ca/language.rb +22 -0
  353. data/lib/kotoshu/languages/cs/language.rb +22 -0
  354. data/lib/kotoshu/languages/da/language.rb +22 -0
  355. data/lib/kotoshu/languages/de/language.rb +554 -0
  356. data/lib/kotoshu/languages/el/language.rb +50 -0
  357. data/lib/kotoshu/languages/en/language.rb +470 -0
  358. data/lib/kotoshu/languages/es/language.rb +476 -0
  359. data/lib/kotoshu/languages/et/language.rb +24 -0
  360. data/lib/kotoshu/languages/fa/language.rb +91 -0
  361. data/lib/kotoshu/languages/fr/language.rb +505 -0
  362. data/lib/kotoshu/languages/he/language.rb +98 -0
  363. data/lib/kotoshu/languages/hr/language.rb +24 -0
  364. data/lib/kotoshu/languages/hu/language.rb +22 -0
  365. data/lib/kotoshu/languages/id/language.rb +25 -0
  366. data/lib/kotoshu/languages/it/language.rb +22 -0
  367. data/lib/kotoshu/languages/ja/language.rb +476 -0
  368. data/lib/kotoshu/languages/ko/language.rb +56 -0
  369. data/lib/kotoshu/languages/latin_base.rb +53 -0
  370. data/lib/kotoshu/languages/lt/language.rb +24 -0
  371. data/lib/kotoshu/languages/lv/language.rb +24 -0
  372. data/lib/kotoshu/languages/nb/language.rb +25 -0
  373. data/lib/kotoshu/languages/ne/language.rb +60 -0
  374. data/lib/kotoshu/languages/nl/language.rb +22 -0
  375. data/lib/kotoshu/languages/nn/language.rb +26 -0
  376. data/lib/kotoshu/languages/pl/language.rb +22 -0
  377. data/lib/kotoshu/languages/pt/language.rb +439 -0
  378. data/lib/kotoshu/languages/ro/language.rb +22 -0
  379. data/lib/kotoshu/languages/ru/language.rb +420 -0
  380. data/lib/kotoshu/languages/sk/language.rb +25 -0
  381. data/lib/kotoshu/languages/sl/language.rb +25 -0
  382. data/lib/kotoshu/languages/sr/language.rb +39 -0
  383. data/lib/kotoshu/languages/sr-Latn/language.rb +35 -0
  384. data/lib/kotoshu/languages/sv/language.rb +22 -0
  385. data/lib/kotoshu/languages/tr/language.rb +36 -0
  386. data/lib/kotoshu/languages/uk/language.rb +38 -0
  387. data/lib/kotoshu/languages/vi/language.rb +22 -0
  388. data/lib/kotoshu/languages.rb +64 -0
  389. data/lib/kotoshu/metrics_collector.rb +238 -0
  390. data/lib/kotoshu/metrics_module.rb +121 -0
  391. data/lib/kotoshu/models/context.rb +119 -0
  392. data/lib/kotoshu/models/embedding_model.rb +181 -0
  393. data/lib/kotoshu/models/fasttext_model.rb +212 -0
  394. data/lib/kotoshu/models/nearest_neighbor.rb +96 -0
  395. data/lib/kotoshu/models/onnx_model.rb +330 -0
  396. data/lib/kotoshu/models/semantic_error.rb +204 -0
  397. data/lib/kotoshu/models/suggestion.rb +106 -0
  398. data/lib/kotoshu/models/word_embedding.rb +97 -0
  399. data/lib/kotoshu/models.rb +27 -0
  400. data/lib/kotoshu/multi_language_checker.rb +127 -0
  401. data/lib/kotoshu/native.rb +83 -0
  402. data/lib/kotoshu/native_backend.rb +131 -0
  403. data/lib/kotoshu/paths.rb +79 -0
  404. data/lib/kotoshu/personal_dictionary.rb +105 -0
  405. data/lib/kotoshu/plugins/plugin.rb +61 -0
  406. data/lib/kotoshu/plugins/registry.rb +118 -0
  407. data/lib/kotoshu/plugins.rb +9 -0
  408. data/lib/kotoshu/project_config.rb +76 -0
  409. data/lib/kotoshu/readers/aff_data.rb +530 -0
  410. data/lib/kotoshu/readers/aff_reader.rb +393 -0
  411. data/lib/kotoshu/readers/condition_checker.rb +125 -0
  412. data/lib/kotoshu/readers/dic_reader.rb +208 -0
  413. data/lib/kotoshu/readers/file_reader.rb +377 -0
  414. data/lib/kotoshu/readers/lookup_builder.rb +584 -0
  415. data/lib/kotoshu/readers/readers.rb +17 -0
  416. data/lib/kotoshu/readers.rb +25 -0
  417. data/lib/kotoshu/resource_bundle.rb +55 -0
  418. data/lib/kotoshu/resource_manager.rb +600 -0
  419. data/lib/kotoshu/results/result.rb +165 -0
  420. data/lib/kotoshu/results.rb +8 -0
  421. data/lib/kotoshu/rspec.rb +163 -0
  422. data/lib/kotoshu/scripts/fasttext_to_onnx.py +275 -0
  423. data/lib/kotoshu/source_registry.rb +104 -0
  424. data/lib/kotoshu/spellchecker/parallel_checker.rb +90 -0
  425. data/lib/kotoshu/spellchecker.rb +406 -0
  426. data/lib/kotoshu/string_metrics.rb +153 -0
  427. data/lib/kotoshu/suggestions/context.rb +43 -0
  428. data/lib/kotoshu/suggestions/frequency_provider.rb +80 -0
  429. data/lib/kotoshu/suggestions/generator.rb +169 -0
  430. data/lib/kotoshu/suggestions/pipeline.rb +135 -0
  431. data/lib/kotoshu/suggestions/semantic_cascade.rb +73 -0
  432. data/lib/kotoshu/suggestions/strategies/base_strategy.rb +315 -0
  433. data/lib/kotoshu/suggestions/strategies/composite_strategy.rb +197 -0
  434. data/lib/kotoshu/suggestions/strategies/edit_distance_strategy.rb +631 -0
  435. data/lib/kotoshu/suggestions/strategies/keyboard_proximity_strategy.rb +207 -0
  436. data/lib/kotoshu/suggestions/strategies/ngram_strategy.rb +165 -0
  437. data/lib/kotoshu/suggestions/strategies/phonetic_strategy.rb +284 -0
  438. data/lib/kotoshu/suggestions/strategies/semantic_strategy.rb +317 -0
  439. data/lib/kotoshu/suggestions/strategies/symspell_strategy.rb +270 -0
  440. data/lib/kotoshu/suggestions/strategies/word_index.rb +78 -0
  441. data/lib/kotoshu/suggestions/suggestion.rb +154 -0
  442. data/lib/kotoshu/suggestions/suggestion_set.rb +270 -0
  443. data/lib/kotoshu/suggestions/sweep_index.rb +137 -0
  444. data/lib/kotoshu/suggestions.rb +29 -0
  445. data/lib/kotoshu/tasks/check_task.rb +104 -0
  446. data/lib/kotoshu/tasks.rb +11 -0
  447. data/lib/kotoshu/validators/spelling_validator.rb +101 -0
  448. data/lib/kotoshu/validators.rb +9 -0
  449. data/lib/kotoshu/version.rb +5 -0
  450. data/lib/kotoshu.rb +538 -0
  451. data/rakelib/compile.rake +10 -0
  452. data/script/validate_all_dictionaries.rb +444 -0
  453. data/scripts/build_native_gem.rb +45 -0
  454. data/scripts/extract_eval_grids.rb +37 -0
  455. data/scripts/generate_frozen_tiers.rb +44 -0
  456. data/sig/kotoshu.rbs +435 -0
  457. data/test_oop.rb +79 -0
  458. metadata +546 -0
@@ -0,0 +1,814 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kotoshu
4
+ module Dictionaries
5
+ # Catalog of all available dictionaries from kotoshu/dictionaries repository
6
+ #
7
+ # This class provides a structured registry of all available dictionaries
8
+ # with their metadata, URLs, and license information.
9
+ #
10
+ # @example Listing all dictionaries
11
+ # catalog = Kotoshu::Dictionaries::Catalog.new
12
+ # catalog.all.each do |dict|
13
+ # puts "#{dict.code}: #{dict.name} (#{dict.size} words)"
14
+ # end
15
+ #
16
+ # @example Finding dictionaries by language
17
+ # catalog = Kotoshu::Dictionaries::Catalog.new
18
+ # german_dicts = catalog.by_language("de")
19
+ #
20
+ # @example Getting a specific dictionary
21
+ # catalog = Kotoshu::Dictionaries::Catalog.new
22
+ # dict = catalog.find("en-GB")
23
+ # dict.load # => Kotoshu::Dictionary::Base subclass
24
+ #
25
+ class Catalog
26
+ # Dictionary entry in the catalog
27
+ class DictionaryEntry
28
+ attr_reader :code, :name, :language, :region, :format,
29
+ :source, :license, :word_count, :dic_url, :aff_url,
30
+ :metadata
31
+
32
+ def initialize(code:, name:, language:, format:, source:, license:, word_count:, dic_url:, region: nil, aff_url: nil,
33
+ metadata: {})
34
+ @code = code
35
+ @name = name
36
+ @language = language
37
+ @region = region
38
+ @format = format
39
+ @source = source
40
+ @license = license
41
+ @word_count = word_count
42
+ @dic_url = dic_url
43
+ @aff_url = aff_url
44
+ @metadata = metadata
45
+ freeze
46
+ end
47
+
48
+ # Load this dictionary from URL
49
+ # @return [Kotoshu::Dictionary::Base] The loaded dictionary
50
+ def load
51
+ case @format
52
+ when :hunspell
53
+ raise ArgumentError, "Missing aff_url for Hunspell dictionary" unless @aff_url
54
+
55
+ Kotoshu::Dictionary::Hunspell.new(
56
+ dic_path: @dic_url,
57
+ aff_path: @aff_url,
58
+ language_code: @code,
59
+ metadata: @metadata
60
+ )
61
+ when :plain_text
62
+ Kotoshu::Dictionary::PlainText.new(
63
+ @dic_url,
64
+ language_code: @code,
65
+ metadata: @metadata
66
+ )
67
+ else
68
+ raise ArgumentError, "Unknown format: #{@format}"
69
+ end
70
+ end
71
+
72
+ # @return [String] Human-readable description
73
+ def description
74
+ region_part = @region ? " (#{@region})" : ""
75
+ "#{@name}#{region_part} - #{@word_count} words"
76
+ end
77
+
78
+ # @return [Boolean] true if this is a Hunspell dictionary
79
+ def hunspell?
80
+ @format == :hunspell
81
+ end
82
+
83
+ # @return [Boolean] true if this is a plain text dictionary
84
+ def plain_text?
85
+ @format == :plain_text
86
+ end
87
+ end
88
+
89
+ # Base URL for kotoshu/dictionaries repository
90
+ BASE_URL = "https://raw.githubusercontent.com/kotoshu/dictionaries/main"
91
+
92
+ # All available dictionaries
93
+ ALL_DICTIONARIES = [
94
+ # Unix System Dictionaries (Plain Text)
95
+ { code: "en-US-web2", name: "Webster's Second International", language: "en", region: "US",
96
+ format: :plain_text, source: "FreeBSD", license: "Public Domain",
97
+ word_count: 235_976,
98
+ dic_url: "#{BASE_URL}/unix-words/web2.txt",
99
+ metadata: { source_file: "web2.txt", year: 1934 } },
100
+
101
+ { code: "en-US-web2a", name: "Webster's with Affix Flags", language: "en", region: "US",
102
+ format: :plain_text, source: "FreeBSD", license: "Public Domain",
103
+ word_count: 50_000,
104
+ dic_url: "#{BASE_URL}/unix-words/web2a.txt",
105
+ metadata: { source_file: "web2a.txt", has_affix_flags: true } },
106
+
107
+ { code: "en-connectives", name: "English Connectives", language: "en",
108
+ format: :plain_text, source: "FreeBSD", license: "Public Domain",
109
+ word_count: 500,
110
+ dic_url: "#{BASE_URL}/unix-words/connectives.txt",
111
+ metadata: { source_file: "connectives.txt" } },
112
+
113
+ { code: "en-propernames", name: "Proper Names", language: "en",
114
+ format: :plain_text, source: "FreeBSD", license: "Public Domain",
115
+ word_count: 2000,
116
+ dic_url: "#{BASE_URL}/unix-words/propernames.txt",
117
+ metadata: { source_file: "propernames.txt" } },
118
+
119
+ # English (Hunspell from wooorm/dictionaries)
120
+ { code: "en", name: "US English", language: "en", region: "US",
121
+ format: :hunspell, source: "SCOWL", license: "LGPL/MPL/GPL",
122
+ word_count: 500_000,
123
+ dic_url: "#{BASE_URL}/en/index.dic",
124
+ aff_url: "#{BASE_URL}/en/index.aff",
125
+ metadata: { scowl_size: "large", source: "wooorm/dictionaries" } },
126
+
127
+ { code: "en-GB", name: "British English (ise)", language: "en", region: "GB",
128
+ format: :hunspell, source: "SCOWL", license: "LGPL/MPL/GPL",
129
+ word_count: 450_000,
130
+ dic_url: "#{BASE_URL}/en-GB/index.dic",
131
+ aff_url: "#{BASE_URL}/en-GB/index.aff",
132
+ metadata: { spelling_variant: "ise", source: "wooorm/dictionaries" } },
133
+
134
+ { code: "en-CA", name: "Canadian English", language: "en", region: "CA",
135
+ format: :hunspell, source: "SCOWL", license: "LGPL/MPL/GPL",
136
+ word_count: 300_000,
137
+ dic_url: "#{BASE_URL}/en-CA/index.dic",
138
+ aff_url: "#{BASE_URL}/en-CA/index.aff",
139
+ metadata: { source: "wooorm/dictionaries" } },
140
+
141
+ { code: "en-AU", name: "Australian English", language: "en", region: "AU",
142
+ format: :hunspell, source: "SCOWL", license: "LGPL/MPL/GPL",
143
+ word_count: 250_000,
144
+ dic_url: "#{BASE_URL}/en-AU/index.dic",
145
+ aff_url: "#{BASE_URL}/en-AU/index.aff",
146
+ metadata: { source: "wooorm/dictionaries" } },
147
+
148
+ { code: "en-ZA", name: "South African English", language: "en", region: "ZA",
149
+ format: :hunspell, source: "SCOWL", license: "LGPL/MPL/GPL",
150
+ word_count: 200_000,
151
+ dic_url: "#{BASE_URL}/en-ZA/index.dic",
152
+ aff_url: "#{BASE_URL}/en-ZA/index.aff",
153
+ metadata: { source: "wooorm/dictionaries" } },
154
+
155
+ # German
156
+ { code: "de", name: "German", language: "de",
157
+ format: :hunspell, source: "igerman98", license: "GPL",
158
+ word_count: 300_000,
159
+ dic_url: "#{BASE_URL}/de/index.dic",
160
+ aff_url: "#{BASE_URL}/de/index.aff",
161
+ metadata: { source: "wooorm/dictionaries" } },
162
+
163
+ { code: "de-AT", name: "German (Austria)", language: "de", region: "AT",
164
+ format: :hunspell, source: "igerman98", license: "GPL",
165
+ word_count: 200_000,
166
+ dic_url: "#{BASE_URL}/de-AT/index.dic",
167
+ aff_url: "#{BASE_URL}/de-AT/index.aff",
168
+ metadata: { source: "wooorm/dictionaries" } },
169
+
170
+ { code: "de-CH", name: "German (Switzerland)", language: "de", region: "CH",
171
+ format: :hunspell, source: "igerman98", license: "GPL",
172
+ word_count: 200_000,
173
+ dic_url: "#{BASE_URL}/de-CH/index.dic",
174
+ aff_url: "#{BASE_URL}/de-CH/index.aff",
175
+ metadata: { source: "wooorm/dictionaries" } },
176
+
177
+ { code: "de-DE", name: "German (Germany)", language: "de", region: "DE",
178
+ format: :hunspell, source: "igerman98", license: "GPL",
179
+ word_count: 300_000,
180
+ dic_url: "#{BASE_URL}/de-DE/index.dic",
181
+ aff_url: "#{BASE_URL}/de-DE/index.aff",
182
+ metadata: { source: "wooorm/dictionaries" } },
183
+
184
+ # Spanish
185
+ { code: "es", name: "Spanish", language: "es",
186
+ format: :hunspell, source: "LibreOffice", license: "GPL",
187
+ word_count: 500_000,
188
+ dic_url: "#{BASE_URL}/es/index.dic",
189
+ aff_url: "#{BASE_URL}/es/index.aff",
190
+ metadata: { source: "wooorm/dictionaries", regional_variants: 21 } },
191
+
192
+ { code: "es-AR", name: "Spanish (Argentina)", language: "es", region: "AR",
193
+ format: :hunspell, source: "LibreOffice", license: "GPL",
194
+ word_count: 400_000,
195
+ dic_url: "#{BASE_URL}/es-AR/index.dic",
196
+ aff_url: "#{BASE_URL}/es-AR/index.aff",
197
+ metadata: { source: "wooorm/dictionaries" } },
198
+
199
+ { code: "es-MX", name: "Spanish (Mexico)", language: "es", region: "MX",
200
+ format: :hunspell, source: "LibreOffice", license: "GPL",
201
+ word_count: 400_000,
202
+ dic_url: "#{BASE_URL}/es-MX/index.dic",
203
+ aff_url: "#{BASE_URL}/es-MX/index.aff",
204
+ metadata: { source: "wooorm/dictionaries" } },
205
+
206
+ # French
207
+ { code: "fr", name: "French", language: "fr",
208
+ format: :hunspell, source: "Grammalecte", license: "MPL 2.0",
209
+ word_count: 200_000,
210
+ dic_url: "#{BASE_URL}/fr/index.dic",
211
+ aff_url: "#{BASE_URL}/fr/index.aff",
212
+ metadata: { source: "wooorm/dictionaries" } },
213
+
214
+ { code: "fr-FR", name: "French (France)", language: "fr", region: "FR",
215
+ format: :hunspell, source: "Grammalecte", license: "MPL 2.0",
216
+ word_count: 200_000,
217
+ dic_url: "#{BASE_URL}/fr-FR/index.dic",
218
+ aff_url: "#{BASE_URL}/fr-FR/index.aff",
219
+ metadata: { source: "wooorm/dictionaries" } },
220
+
221
+ # Italian
222
+ { code: "it", name: "Italian", language: "it",
223
+ format: :hunspell, source: "LibreOffice", license: "GPL 3",
224
+ word_count: 500_000,
225
+ dic_url: "#{BASE_URL}/it/index.dic",
226
+ aff_url: "#{BASE_URL}/it/index.aff",
227
+ metadata: { source: "wooorm/dictionaries" } },
228
+
229
+ # Portuguese
230
+ { code: "pt", name: "Portuguese", language: "pt",
231
+ format: :hunspell, source: "LibreOffice", license: "LGPLv3/MPL",
232
+ word_count: 400_000,
233
+ dic_url: "#{BASE_URL}/pt/index.dic",
234
+ aff_url: "#{BASE_URL}/pt/index.aff",
235
+ metadata: { source: "wooorm/dictionaries" } },
236
+
237
+ # Russian
238
+ { code: "ru", name: "Russian", language: "ru",
239
+ format: :hunspell, source: "Alexander Lebedev", license: "BSD-style",
240
+ word_count: 800_000,
241
+ dic_url: "#{BASE_URL}/ru/index.dic",
242
+ aff_url: "#{BASE_URL}/ru/index.aff",
243
+ metadata: { source: "wooorm/dictionaries" } },
244
+
245
+ # Dutch
246
+ { code: "nl", name: "Dutch", language: "nl",
247
+ format: :hunspell, source: "OpenTaal", license: "Revised BSD + CC BY 3.0",
248
+ word_count: 400_000,
249
+ dic_url: "#{BASE_URL}/nl/index.dic",
250
+ aff_url: "#{BASE_URL}/nl/index.aff",
251
+ metadata: { source: "wooorm/dictionaries" } },
252
+
253
+ # Polish
254
+ { code: "pl", name: "Polish", language: "pl",
255
+ format: :hunspell, source: "Polish Native Lang Project", license: "GPL/LGPL/MPL/CC",
256
+ word_count: 600_000,
257
+ dic_url: "#{BASE_URL}/pl/index.dic",
258
+ aff_url: "#{BASE_URL}/pl/index.aff",
259
+ metadata: { source: "wooorm/dictionaries" } },
260
+
261
+ # Additional European languages
262
+ { code: "cs", name: "Czech", language: "cs",
263
+ format: :hunspell, source: "LibreOffice", license: "GPL",
264
+ word_count: 400_000,
265
+ dic_url: "#{BASE_URL}/cs/index.dic",
266
+ aff_url: "#{BASE_URL}/cs/index.aff",
267
+ metadata: { source: "wooorm/dictionaries" } },
268
+
269
+ { code: "sk", name: "Slovak", language: "sk",
270
+ format: :hunspell, source: "LibreOffice", license: "GPL",
271
+ word_count: 300_000,
272
+ dic_url: "#{BASE_URL}/sk/index.dic",
273
+ aff_url: "#{BASE_URL}/sk/index.aff",
274
+ metadata: { source: "wooorm/dictionaries" } },
275
+
276
+ { code: "hr", name: "Croatian", language: "hr",
277
+ format: :hunspell, source: "LibreOffice", license: "GPL",
278
+ word_count: 300_000,
279
+ dic_url: "#{BASE_URL}/hr/index.dic",
280
+ aff_url: "#{BASE_URL}/hr/index.aff",
281
+ metadata: { source: "wooorm/dictionaries" } },
282
+
283
+ { code: "sr", name: "Serbian (Cyrillic)", language: "sr",
284
+ format: :hunspell, source: "LibreOffice", license: "GPL",
285
+ word_count: 400_000,
286
+ dic_url: "#{BASE_URL}/sr/index.dic",
287
+ aff_url: "#{BASE_URL}/sr/index.aff",
288
+ metadata: { source: "wooorm/dictionaries", script: "Cyrillic" } },
289
+
290
+ { code: "sr-Latn", name: "Serbian (Latin)", language: "sr", region: "Latn",
291
+ format: :hunspell, source: "LibreOffice", license: "GPL",
292
+ word_count: 400_000,
293
+ dic_url: "#{BASE_URL}/sr-Latn/index.dic",
294
+ aff_url: "#{BASE_URL}/sr-Latn/index.aff",
295
+ metadata: { source: "wooorm/dictionaries", script: "Latin" } },
296
+
297
+ { code: "sl", name: "Slovenian", language: "sl",
298
+ format: :hunspell, source: "LibreOffice", license: "GPL",
299
+ word_count: 200_000,
300
+ dic_url: "#{BASE_URL}/sl/index.dic",
301
+ aff_url: "#{BASE_URL}/sl/index.aff",
302
+ metadata: { source: "wooorm/dictionaries" } },
303
+
304
+ # Baltic languages
305
+ { code: "lt", name: "Lithuanian", language: "lt",
306
+ format: :hunspell, source: "LibreOffice", license: "GPL",
307
+ word_count: 200_000,
308
+ dic_url: "#{BASE_URL}/lt/index.dic",
309
+ aff_url: "#{BASE_URL}/lt/index.aff",
310
+ metadata: { source: "wooorm/dictionaries" } },
311
+
312
+ { code: "lv", name: "Latvian", language: "lv",
313
+ format: :hunspell, source: "LibreOffice", license: "GPL",
314
+ word_count: 250_000,
315
+ dic_url: "#{BASE_URL}/lv/index.dic",
316
+ aff_url: "#{BASE_URL}/lv/index.aff",
317
+ metadata: { source: "wooorm/dictionaries" } },
318
+
319
+ { code: "et", name: "Estonian", language: "et",
320
+ format: :hunspell, source: "LibreOffice", license: "GPL",
321
+ word_count: 200_000,
322
+ dic_url: "#{BASE_URL}/et/index.dic",
323
+ aff_url: "#{BASE_URL}/et/index.aff",
324
+ metadata: { source: "wooorm/dictionaries" } },
325
+
326
+ # Nordic languages
327
+ { code: "da", name: "Danish", language: "da",
328
+ format: :hunspell, source: "LibreOffice", license: "GPL",
329
+ word_count: 300_000,
330
+ dic_url: "#{BASE_URL}/da/index.dic",
331
+ aff_url: "#{BASE_URL}/da/index.aff",
332
+ metadata: { source: "wooorm/dictionaries" } },
333
+
334
+ { code: "sv", name: "Swedish", language: "sv",
335
+ format: :hunspell, source: "LibreOffice", license: "GPL",
336
+ word_count: 350_000,
337
+ dic_url: "#{BASE_URL}/sv/index.dic",
338
+ aff_url: "#{BASE_URL}/sv/index.aff",
339
+ metadata: { source: "wooorm/dictionaries" } },
340
+
341
+ { code: "sv-FI", name: "Swedish (Finland)", language: "sv", region: "FI",
342
+ format: :hunspell, source: "LibreOffice", license: "GPL",
343
+ word_count: 300_000,
344
+ dic_url: "#{BASE_URL}/sv-FI/index.dic",
345
+ aff_url: "#{BASE_URL}/sv-FI/index.aff",
346
+ metadata: { source: "wooorm/dictionaries" } },
347
+
348
+ { code: "nb", name: "Norwegian (Bokmål)", language: "nb",
349
+ format: :hunspell, source: "LibreOffice", license: "GPL",
350
+ word_count: 300_000,
351
+ dic_url: "#{BASE_URL}/nb/index.dic",
352
+ aff_url: "#{BASE_URL}/nb/index.aff",
353
+ metadata: { source: "wooorm/dictionaries" } },
354
+
355
+ { code: "nn", name: "Norwegian (Nynorsk)", language: "nn",
356
+ format: :hunspell, source: "LibreOffice", license: "GPL",
357
+ word_count: 250_000,
358
+ dic_url: "#{BASE_URL}/nn/index.dic",
359
+ aff_url: "#{BASE_URL}/nn/index.aff",
360
+ metadata: { source: "wooorm/dictionaries" } },
361
+
362
+ { code: "fi", name: "Finnish", language: "fi",
363
+ format: :hunspell, source: "LibreOffice", license: "GPL",
364
+ word_count: 400_000,
365
+ dic_url: "#{BASE_URL}/fi/index.dic",
366
+ aff_url: "#{BASE_URL}/fi/index.aff",
367
+ metadata: { source: "wooorm/dictionaries" } },
368
+
369
+ { code: "is", name: "Icelandic", language: "is",
370
+ format: :hunspell, source: "LibreOffice", license: "GPL",
371
+ word_count: 200_000,
372
+ dic_url: "#{BASE_URL}/is/index.dic",
373
+ aff_url: "#{BASE_URL}/is/index.aff",
374
+ metadata: { source: "wooorm/dictionaries" } },
375
+
376
+ { code: "fo", name: "Faroese", language: "fo",
377
+ format: :hunspell, source: "LibreOffice", license: "GPL",
378
+ word_count: 100_000,
379
+ dic_url: "#{BASE_URL}/fo/index.dic",
380
+ aff_url: "#{BASE_URL}/fo/index.aff",
381
+ metadata: { source: "wooorm/dictionaries" } },
382
+
383
+ # Celtic languages
384
+ { code: "ga", name: "Irish", language: "ga",
385
+ format: :hunspell, source: "LibreOffice", license: "GPL",
386
+ word_count: 50_000,
387
+ dic_url: "#{BASE_URL}/ga/index.dic",
388
+ aff_url: "#{BASE_URL}/ga/index.aff",
389
+ metadata: { source: "wooorm/dictionaries" } },
390
+
391
+ { code: "gd", name: "Scottish Gaelic", language: "gd",
392
+ format: :hunspell, source: "LibreOffice", license: "GPL",
393
+ word_count: 50_000,
394
+ dic_url: "#{BASE_URL}/gd/index.dic",
395
+ aff_url: "#{BASE_URL}/gd/index.aff",
396
+ metadata: { source: "wooorm/dictionaries" } },
397
+
398
+ { code: "cy", name: "Welsh", language: "cy",
399
+ format: :hunspell, source: "LibreOffice", license: "GPL",
400
+ word_count: 100_000,
401
+ dic_url: "#{BASE_URL}/cy/index.dic",
402
+ aff_url: "#{BASE_URL}/cy/index.aff",
403
+ metadata: { source: "wooorm/dictionaries" } },
404
+
405
+ { code: "br", name: "Breton", language: "br",
406
+ format: :hunspell, source: "LibreOffice", license: "GPL",
407
+ word_count: 50_000,
408
+ dic_url: "#{BASE_URL}/br/index.dic",
409
+ aff_url: "#{BASE_URL}/br/index.aff",
410
+ metadata: { source: "wooorm/dictionaries" } },
411
+
412
+ { code: "gv", name: "Manx", language: "gv",
413
+ format: :hunspell, source: "LibreOffice", license: "GPL",
414
+ word_count: 30_000,
415
+ dic_url: "#{BASE_URL}/gv/index.dic",
416
+ aff_url: "#{BASE_URL}/gv/index.aff",
417
+ metadata: { source: "wooorm/dictionaries" } },
418
+
419
+ # Other European languages
420
+ { code: "el", name: "Greek", language: "el",
421
+ format: :hunspell, source: "LibreOffice", license: "GPL",
422
+ word_count: 400_000,
423
+ dic_url: "#{BASE_URL}/el/index.dic",
424
+ aff_url: "#{BASE_URL}/el/index.aff",
425
+ metadata: { source: "wooorm/dictionaries" } },
426
+
427
+ { code: "el-polyton", name: "Greek (Polytonic)", language: "el", region: "polyton",
428
+ format: :hunspell, source: "LibreOffice", license: "GPL",
429
+ word_count: 100_000,
430
+ dic_url: "#{BASE_URL}/el-polyton/index.dic",
431
+ aff_url: "#{BASE_URL}/el-polyton/index.aff",
432
+ metadata: { source: "wooorm/dictionaries" } },
433
+
434
+ { code: "tr", name: "Turkish", language: "tr",
435
+ format: :hunspell, source: "LibreOffice", license: "GPL",
436
+ word_count: 400_000,
437
+ dic_url: "#{BASE_URL}/tr/index.dic",
438
+ aff_url: "#{BASE_URL}/tr/index.aff",
439
+ metadata: { source: "wooorm/dictionaries" } },
440
+
441
+ { code: "hu", name: "Hungarian", language: "hu",
442
+ format: :hunspell, source: "LibreOffice", license: "GPL",
443
+ word_count: 400_000,
444
+ dic_url: "#{BASE_URL}/hu/index.dic",
445
+ aff_url: "#{BASE_URL}/hu/index.aff",
446
+ metadata: { source: "wooorm/dictionaries" } },
447
+
448
+ { code: "ro", name: "Romanian", language: "ro",
449
+ format: :hunspell, source: "LibreOffice", license: "GPL",
450
+ word_count: 300_000,
451
+ dic_url: "#{BASE_URL}/ro/index.dic",
452
+ aff_url: "#{BASE_URL}/ro/index.aff",
453
+ metadata: { source: "wooorm/dictionaries" } },
454
+
455
+ { code: "bg", name: "Bulgarian", language: "bg",
456
+ format: :hunspell, source: "LibreOffice", license: "GPL",
457
+ word_count: 300_000,
458
+ dic_url: "#{BASE_URL}/bg/index.dic",
459
+ aff_url: "#{BASE_URL}/bg/index.aff",
460
+ metadata: { source: "wooorm/dictionaries" } },
461
+
462
+ { code: "be", name: "Belarusian", language: "be",
463
+ format: :hunspell, source: "LibreOffice", license: "GPL",
464
+ word_count: 200_000,
465
+ dic_url: "#{BASE_URL}/be/index.dic",
466
+ aff_url: "#{BASE_URL}/be/index.aff",
467
+ metadata: { source: "wooorm/dictionaries" } },
468
+
469
+ { code: "uk", name: "Ukrainian", language: "uk",
470
+ format: :hunspell, source: "LibreOffice", license: "GPL",
471
+ word_count: 400_000,
472
+ dic_url: "#{BASE_URL}/uk/index.dic",
473
+ aff_url: "#{BASE_URL}/uk/index.aff",
474
+ metadata: { source: "wooorm/dictionaries" } },
475
+
476
+ # Regional languages
477
+ { code: "ca", name: "Catalan", language: "ca",
478
+ format: :hunspell, source: "LibreOffice", license: "GPL",
479
+ word_count: 400_000,
480
+ dic_url: "#{BASE_URL}/ca/index.dic",
481
+ aff_url: "#{BASE_URL}/ca/index.aff",
482
+ metadata: { source: "wooorm/dictionaries" } },
483
+
484
+ { code: "ca-valencia", name: "Catalan (Valencia)", language: "ca", region: "valencia",
485
+ format: :hunspell, source: "LibreOffice", license: "GPL",
486
+ word_count: 400_000,
487
+ dic_url: "#{BASE_URL}/ca-valencia/index.dic",
488
+ aff_url: "#{BASE_URL}/ca-valencia/index.aff",
489
+ metadata: { source: "wooorm/dictionaries" } },
490
+
491
+ { code: "gl", name: "Galician", language: "gl",
492
+ format: :hunspell, source: "LibreOffice", license: "GPL",
493
+ word_count: 300_000,
494
+ dic_url: "#{BASE_URL}/gl/index.dic",
495
+ aff_url: "#{BASE_URL}/gl/index.aff",
496
+ metadata: { source: "wooorm/dictionaries" } },
497
+
498
+ { code: "eu", name: "Basque", language: "eu",
499
+ format: :hunspell, source: "LibreOffice", license: "GPL",
500
+ word_count: 200_000,
501
+ dic_url: "#{BASE_URL}/eu/index.dic",
502
+ aff_url: "#{BASE_URL}/eu/index.aff",
503
+ metadata: { source: "wooorm/dictionaries" } },
504
+
505
+ { code: "lb", name: "Luxembourgish", language: "lb",
506
+ format: :hunspell, source: "LibreOffice", license: "GPL",
507
+ word_count: 100_000,
508
+ dic_url: "#{BASE_URL}/lb/index.dic",
509
+ aff_url: "#{BASE_URL}/lb/index.aff",
510
+ metadata: { source: "wooorm/dictionaries" } },
511
+
512
+ { code: "li", name: "Limburgish", language: "li",
513
+ format: :hunspell, source: "LibreOffice", license: "GPL",
514
+ word_count: 50_000,
515
+ dic_url: "#{BASE_URL}/li/index.dic",
516
+ aff_url: "#{BASE_URL}/li/index.aff",
517
+ metadata: { source: "wooorm/dictionaries" } },
518
+
519
+ { code: "fy", name: "Western Frisian", language: "fy",
520
+ format: :hunspell, source: "LibreOffice", license: "GPL",
521
+ word_count: 100_000,
522
+ dic_url: "#{BASE_URL}/fy/index.dic",
523
+ aff_url: "#{BASE_URL}/fy/index.aff",
524
+ metadata: { source: "wooorm/dictionaries" } },
525
+
526
+ { code: "ltg", name: "Latgalian", language: "ltg",
527
+ format: :hunspell, source: "LibreOffice", license: "GPL",
528
+ word_count: 50_000,
529
+ dic_url: "#{BASE_URL}/ltg/index.dic",
530
+ aff_url: "#{BASE_URL}/ltg/index.aff",
531
+ metadata: { source: "wooorm/dictionaries" } },
532
+
533
+ { code: "ku", name: "Kurdish", language: "ku",
534
+ format: :hunspell, source: "LibreOffice", license: "GPL",
535
+ word_count: 50_000,
536
+ dic_url: "#{BASE_URL}/ku/index.dic",
537
+ aff_url: "#{BASE_URL}/ku/index.aff",
538
+ metadata: { source: "wooorm/dictionaries" } },
539
+
540
+ # Middle Eastern languages
541
+ { code: "hy", name: "Armenian", language: "hy",
542
+ format: :hunspell, source: "LibreOffice", license: "GPL",
543
+ word_count: 200_000,
544
+ dic_url: "#{BASE_URL}/hy/index.dic",
545
+ aff_url: "#{BASE_URL}/hy/index.aff",
546
+ metadata: { source: "wooorm/dictionaries" } },
547
+
548
+ { code: "hyw", name: "Western Armenian", language: "hy", region: "western",
549
+ format: :hunspell, source: "LibreOffice", license: "GPL",
550
+ word_count: 100_000,
551
+ dic_url: "#{BASE_URL}/hyw/index.dic",
552
+ aff_url: "#{BASE_URL}/hyw/index.aff",
553
+ metadata: { source: "wooorm/dictionaries" } },
554
+
555
+ { code: "ka", name: "Georgian", language: "ka",
556
+ format: :hunspell, source: "LibreOffice", license: "GPL",
557
+ word_count: 200_000,
558
+ dic_url: "#{BASE_URL}/ka/index.dic",
559
+ aff_url: "#{BASE_URL}/ka/index.aff",
560
+ metadata: { source: "wooorm/dictionaries" } },
561
+
562
+ { code: "he", name: "Hebrew", language: "he",
563
+ format: :hunspell, source: "LibreOffice", license: "GPL",
564
+ word_count: 300_000,
565
+ dic_url: "#{BASE_URL}/he/index.dic",
566
+ aff_url: "#{BASE_URL}/he/index.aff",
567
+ metadata: { source: "wooorm/dictionaries" } },
568
+
569
+ { code: "fa", name: "Persian", language: "fa",
570
+ format: :hunspell, source: "LibreOffice", license: "GPL",
571
+ word_count: 200_000,
572
+ dic_url: "#{BASE_URL}/fa/index.dic",
573
+ aff_url: "#{BASE_URL}/fa/index.aff",
574
+ metadata: { source: "wooorm/dictionaries" } },
575
+
576
+ # Asian languages
577
+ { code: "ko", name: "Korean", language: "ko",
578
+ format: :hunspell, source: "LibreOffice", license: "GPL",
579
+ word_count: 500_000,
580
+ dic_url: "#{BASE_URL}/ko/index.dic",
581
+ aff_url: "#{BASE_URL}/ko/index.aff",
582
+ metadata: { source: "wooorm/dictionaries" } },
583
+
584
+ { code: "vi", name: "Vietnamese", language: "vi",
585
+ format: :hunspell, source: "LibreOffice", license: "GPL",
586
+ word_count: 100_000,
587
+ dic_url: "#{BASE_URL}/vi/index.dic",
588
+ aff_url: "#{BASE_URL}/vi/index.aff",
589
+ metadata: { source: "wooorm/dictionaries" } },
590
+
591
+ # Constructed languages
592
+ { code: "eo", name: "Esperanto", language: "eo",
593
+ format: :hunspell, source: "LibreOffice", license: "GPL",
594
+ word_count: 100_000,
595
+ dic_url: "#{BASE_URL}/eo/index.dic",
596
+ aff_url: "#{BASE_URL}/eo/index.aff",
597
+ metadata: { source: "wooorm/dictionaries" } },
598
+
599
+ { code: "ia", name: "Interlingua", language: "ia",
600
+ format: :hunspell, source: "LibreOffice", license: "GPL",
601
+ word_count: 50_000,
602
+ dic_url: "#{BASE_URL}/ia/index.dic",
603
+ aff_url: "#{BASE_URL}/ia/index.aff",
604
+ metadata: { source: "wooorm/dictionaries" } },
605
+
606
+ # Additional Spanish regional variants
607
+ { code: "es-BO", name: "Spanish (Bolivia)", language: "es", region: "BO",
608
+ format: :hunspell, source: "LibreOffice", license: "GPL",
609
+ word_count: 350_000,
610
+ dic_url: "#{BASE_URL}/es-BO/index.dic",
611
+ aff_url: "#{BASE_URL}/es-BO/index.aff",
612
+ metadata: { source: "wooorm/dictionaries" } },
613
+
614
+ { code: "es-CO", name: "Spanish (Colombia)", language: "es", region: "CO",
615
+ format: :hunspell, source: "LibreOffice", license: "GPL",
616
+ word_count: 350_000,
617
+ dic_url: "#{BASE_URL}/es-CO/index.dic",
618
+ aff_url: "#{BASE_URL}/es-CO/index.aff",
619
+ metadata: { source: "wooorm/dictionaries" } },
620
+
621
+ { code: "es-CR", name: "Spanish (Costa Rica)", language: "es", region: "CR",
622
+ format: :hunspell, source: "LibreOffice", license: "GPL",
623
+ word_count: 350_000,
624
+ dic_url: "#{BASE_URL}/es-CR/index.dic",
625
+ aff_url: "#{BASE_URL}/es-CR/index.aff",
626
+ metadata: { source: "wooorm/dictionaries" } },
627
+
628
+ { code: "es-CU", name: "Spanish (Cuba)", language: "es", region: "CU",
629
+ format: :hunspell, source: "LibreOffice", license: "GPL",
630
+ word_count: 350_000,
631
+ dic_url: "#{BASE_URL}/es-CU/index.dic",
632
+ aff_url: "#{BASE_URL}/es-CU/index.aff",
633
+ metadata: { source: "wooorm/dictionaries" } },
634
+
635
+ { code: "es-DO", name: "Spanish (Dominican Republic)", language: "es", region: "DO",
636
+ format: :hunspell, source: "LibreOffice", license: "GPL",
637
+ word_count: 350_000,
638
+ dic_url: "#{BASE_URL}/es-DO/index.dic",
639
+ aff_url: "#{BASE_URL}/es-DO/index.aff",
640
+ metadata: { source: "wooorm/dictionaries" } },
641
+
642
+ { code: "es-EC", name: "Spanish (Ecuador)", language: "es", region: "EC",
643
+ format: :hunspell, source: "LibreOffice", license: "GPL",
644
+ word_count: 350_000,
645
+ dic_url: "#{BASE_URL}/es-EC/index.dic",
646
+ aff_url: "#{BASE_URL}/es-EC/index.aff",
647
+ metadata: { source: "wooorm/dictionaries" } },
648
+
649
+ { code: "es-GT", name: "Spanish (Guatemala)", language: "es", region: "GT",
650
+ format: :hunspell, source: "LibreOffice", license: "GPL",
651
+ word_count: 350_000,
652
+ dic_url: "#{BASE_URL}/es-GT/index.dic",
653
+ aff_url: "#{BASE_URL}/es-GT/index.aff",
654
+ metadata: { source: "wooorm/dictionaries" } },
655
+
656
+ { code: "es-HN", name: "Spanish (Honduras)", language: "es", region: "HN",
657
+ format: :hunspell, source: "LibreOffice", license: "GPL",
658
+ word_count: 350_000,
659
+ dic_url: "#{BASE_URL}/es-HN/index.dic",
660
+ aff_url: "#{BASE_URL}/es-HN/index.aff",
661
+ metadata: { source: "wooorm/dictionaries" } },
662
+
663
+ { code: "es-NI", name: "Spanish (Nicaragua)", language: "es", region: "NI",
664
+ format: :hunspell, source: "LibreOffice", license: "GPL",
665
+ word_count: 350_000,
666
+ dic_url: "#{BASE_URL}/es-NI/index.dic",
667
+ aff_url: "#{BASE_URL}/es-NI/index.aff",
668
+ metadata: { source: "wooorm/dictionaries" } },
669
+
670
+ { code: "es-PA", name: "Spanish (Panama)", language: "es", region: "PA",
671
+ format: :hunspell, source: "LibreOffice", license: "GPL",
672
+ word_count: 350_000,
673
+ dic_url: "#{BASE_URL}/es-PA/index.dic",
674
+ aff_url: "#{BASE_URL}/es-PA/index.aff",
675
+ metadata: { source: "wooorm/dictionaries" } },
676
+
677
+ { code: "es-PE", name: "Spanish (Peru)", language: "es", region: "PE",
678
+ format: :hunspell, source: "LibreOffice", license: "GPL",
679
+ word_count: 350_000,
680
+ dic_url: "#{BASE_URL}/es-PE/index.dic",
681
+ aff_url: "#{BASE_URL}/es-PE/index.aff",
682
+ metadata: { source: "wooorm/dictionaries" } },
683
+
684
+ { code: "es-PH", name: "Spanish (Philippines)", language: "es", region: "PH",
685
+ format: :hunspell, source: "LibreOffice", license: "GPL",
686
+ word_count: 350_000,
687
+ dic_url: "#{BASE_URL}/es-PH/index.dic",
688
+ aff_url: "#{BASE_URL}/es-PH/index.aff",
689
+ metadata: { source: "wooorm/dictionaries" } },
690
+
691
+ { code: "es-PR", name: "Spanish (Puerto Rico)", language: "es", region: "PR",
692
+ format: :hunspell, source: "LibreOffice", license: "GPL",
693
+ word_count: 350_000,
694
+ dic_url: "#{BASE_URL}/es-PR/index.dic",
695
+ aff_url: "#{BASE_URL}/es-PR/index.aff",
696
+ metadata: { source: "wooorm/dictionaries" } },
697
+
698
+ { code: "es-PY", name: "Spanish (Paraguay)", language: "es", region: "PY",
699
+ format: :hunspell, source: "LibreOffice", license: "GPL",
700
+ word_count: 350_000,
701
+ dic_url: "#{BASE_URL}/es-PY/index.dic",
702
+ aff_url: "#{BASE_URL}/es-PY/index.aff",
703
+ metadata: { source: "wooorm/dictionaries" } },
704
+
705
+ { code: "es-SV", name: "Spanish (El Salvador)", language: "es", region: "SV",
706
+ format: :hunspell, source: "LibreOffice", license: "GPL",
707
+ word_count: 350_000,
708
+ dic_url: "#{BASE_URL}/es-SV/index.dic",
709
+ aff_url: "#{BASE_URL}/es-SV/index.aff",
710
+ metadata: { source: "wooorm/dictionaries" } },
711
+
712
+ { code: "es-US", name: "Spanish (United States)", language: "es", region: "US",
713
+ format: :hunspell, source: "LibreOffice", license: "GPL",
714
+ word_count: 350_000,
715
+ dic_url: "#{BASE_URL}/es-US/index.dic",
716
+ aff_url: "#{BASE_URL}/es-US/index.aff",
717
+ metadata: { source: "wooorm/dictionaries" } },
718
+
719
+ { code: "es-UY", name: "Spanish (Uruguay)", language: "es", region: "UY",
720
+ format: :hunspell, source: "LibreOffice", license: "GPL",
721
+ word_count: 350_000,
722
+ dic_url: "#{BASE_URL}/es-UY/index.dic",
723
+ aff_url: "#{BASE_URL}/es-UY/index.aff",
724
+ metadata: { source: "wooorm/dictionaries" } },
725
+
726
+ { code: "es-VE", name: "Spanish (Venezuela)", language: "es", region: "VE",
727
+ format: :hunspell, source: "LibreOffice", license: "GPL",
728
+ word_count: 350_000,
729
+ dic_url: "#{BASE_URL}/es-VE/index.dic",
730
+ aff_url: "#{BASE_URL}/es-VE/index.aff",
731
+ metadata: { source: "wooorm/dictionaries" } }
732
+ ].freeze
733
+
734
+ # Create catalog entries from data
735
+ @entries = ALL_DICTIONARIES.map do |data|
736
+ DictionaryEntry.new(**data)
737
+ end.freeze
738
+
739
+ # @return [Array<DictionaryEntry>] All dictionary entries
740
+ def self.all
741
+ @entries
742
+ end
743
+
744
+ # Find dictionary by code
745
+ # @param code [String, Symbol] Dictionary code (e.g., "en-GB", :en_GB)
746
+ # @return [DictionaryEntry, nil] The dictionary entry or nil if not found
747
+ def self.find(code)
748
+ code_str = code.to_s.gsub("_", "-")
749
+ all.find { |e| e.code.casecmp(code_str).zero? }
750
+ end
751
+
752
+ # Find dictionaries by language code
753
+ # @param lang [String, Symbol] Language code (e.g., "en", :de)
754
+ # @return [Array<DictionaryEntry>] Dictionaries for the language
755
+ def self.by_language(lang)
756
+ lang_str = lang.to_s.downcase
757
+ all.select { |e| e.language == lang_str }
758
+ end
759
+
760
+ # Find dictionaries by format
761
+ # @param format [Symbol] Format type (:hunspell or :plain_text)
762
+ # @return [Array<DictionaryEntry>] Dictionaries with the format
763
+ def self.by_format(format)
764
+ all.select { |e| e.format == format }
765
+ end
766
+
767
+ # Find dictionaries by license
768
+ # @param license [String, Symbol] License type (e.g., "GPL", "Public Domain")
769
+ # @return [Array<DictionaryEntry>] Dictionaries with the license
770
+ def self.by_license(license)
771
+ license_str = license.to_s
772
+ all.select { |e| e.license.include?(license_str) }
773
+ end
774
+
775
+ # Get all Hunspell dictionaries
776
+ # @return [Array<DictionaryEntry>] All Hunspell dictionaries
777
+ def self.hunspell
778
+ by_format(:hunspell)
779
+ end
780
+
781
+ # Get all plain text dictionaries
782
+ # @return [Array<DictionaryEntry>] All plain text dictionaries
783
+ def self.plain_text
784
+ by_format(:plain_text)
785
+ end
786
+
787
+ # Get statistics about the catalog
788
+ # @return [Hash] Statistics hash
789
+ def self.statistics
790
+ {
791
+ total: all.size,
792
+ hunspell: hunspell.size,
793
+ plain_text: plain_text.size,
794
+ languages: all.map(&:language).uniq.size,
795
+ total_words: all.sum(&:word_count),
796
+ formats: all.group_by(&:format).transform_values(&:size),
797
+ licenses: all.group_by { |e| e.license.split.first }.transform_values(&:size)
798
+ }
799
+ end
800
+
801
+ # Get all unique language codes
802
+ # @return [Array<String>] Unique language codes
803
+ def self.languages
804
+ all.map(&:language).uniq.sort
805
+ end
806
+
807
+ # Get all unique licenses
808
+ # @return [Array<String>] Unique license types
809
+ def self.licenses
810
+ all.map(&:license).uniq
811
+ end
812
+ end
813
+ end
814
+ end