feat: add german spell check
This commit is contained in:
1 parent
e44f09ef42
commit
7faa16c89d
11 files changed
+76824
-48
No files matched your search
+1
-1
@@ -54,7 +54,7 @@
|
||||
**Editing aids**
|
||||
- Undo / Redo with a labelled history dropdown
|
||||
- Search & Replace (Ctrl+F / Ctrl+H): live match highlighting, match count, next / previous, match-case and whole-word options, replace current / replace all
|
||||
- Spell check in English with squiggles and a suggestions context menu (add / ignore word); selectable document language
|
||||
- Spell check in English and German with squiggles and a suggestions context menu (add / ignore word); selectable document language. Powered by Hunspell (WASM), so German compound words (Fußgänger, Krankenversicherung …) are recognised; dictionaries are lazy-loaded per language on demand
|
||||
- Word / character count statistics (whole document and selection)
|
||||
|
||||
**UI & theming**
|
||||
|
||||
Generated
+97
-29
@@ -35,13 +35,14 @@
|
||||
"@tiptap/pm": "^3.23.6",
|
||||
"docx": "^9.7.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
"hunspell-asm": "^4.0.2",
|
||||
"jspdf": "^4.2.1",
|
||||
"nspell": "^2.1.5",
|
||||
"odf-kit": "^0.13.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||
"@tsconfig/svelte": "^5.0.8",
|
||||
"dictionary-de": "^3.0.0",
|
||||
"dictionary-en": "^4.0.0",
|
||||
"jsdom": "^29.1.1",
|
||||
"svelte": "^5.55.9",
|
||||
@@ -1465,6 +1466,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dictionary-de": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dictionary-de/-/dictionary-de-3.0.0.tgz",
|
||||
"integrity": "sha512-0Xbq+YpWTscAL1e18aPPaqfG4goC2o9T595L/54v2OvOPC0/TJFFlclYanxuUoK73wutM5f9EgSuWGkvQXlOXw==",
|
||||
"dev": true,
|
||||
"license": "(GPL-2.0 OR GPL-3.0)",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/dictionary-en": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dictionary-en/-/dictionary-en-4.0.0.tgz",
|
||||
@@ -1521,6 +1533,26 @@
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/emscripten-wasm-loader": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/emscripten-wasm-loader/-/emscripten-wasm-loader-3.0.3.tgz",
|
||||
"integrity": "sha512-fyq2maBt5LOou27LEBlL5H6G04BxgSamXkvmMsAuIT6rd8ioH4BxNQhuyl6jVPeODh6U8Wk1BoFZxzHpg3o8wA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"getroot": "^1.0.0",
|
||||
"nanoid": "^2.0.3",
|
||||
"unixify": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/emscripten-wasm-loader/node_modules/nanoid": {
|
||||
"version": "2.1.11",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
|
||||
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz",
|
||||
@@ -1636,6 +1668,25 @@
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/getroot": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/getroot/-/getroot-1.0.0.tgz",
|
||||
"integrity": "sha512-W9Q31kOv921dQuZBeAbK4R/dAPbC0WkhZD3alLcdVwjSkEtS1aX8twrzG3I5yo0sQ88M/d4JOqVbRiCuI/XPNA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^1.7.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.4",
|
||||
"npm": ">=3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/getroot/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/hash.js": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
|
||||
@@ -1672,6 +1723,25 @@
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/hunspell-asm": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hunspell-asm/-/hunspell-asm-4.0.2.tgz",
|
||||
"integrity": "sha512-u3ZuEYKGYnLZlIs+k5S+KdY+Q57mYD46fTwZJCiSXdES+fhxcLNF5mJ0nxjqrPAgE/8Kow6XLxRdRd/HDUPQZg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emscripten-wasm-loader": "^3.0.3",
|
||||
"nanoid": "^2.1.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/hunspell-asm/node_modules/nanoid": {
|
||||
"version": "2.1.11",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
|
||||
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/immediate": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
|
||||
@@ -1690,29 +1760,6 @@
|
||||
"integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-buffer": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
|
||||
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/is-potential-custom-element-name": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||
@@ -2169,13 +2216,16 @@
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/nspell": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/nspell/-/nspell-2.1.5.tgz",
|
||||
"integrity": "sha512-PSStyugKMiD9mHmqI/CR5xXrSIGejUXPlo88FBRq5Og1kO5QwQ5Ilu8D8O5I/SHpoS+mibpw6uKA8rd3vXd2Sg==",
|
||||
"node_modules/normalize-path": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
|
||||
"integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-buffer": "^2.0.0"
|
||||
"remove-trailing-separator": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/obug": {
|
||||
@@ -2478,6 +2528,12 @@
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/remove-trailing-separator": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
||||
"integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
@@ -2842,6 +2898,18 @@
|
||||
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unixify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unixify/-/unixify-1.0.0.tgz",
|
||||
"integrity": "sha512-6bc58dPYhCMHHuwxldQxO3RRNZ4eCogZ/st++0+fcC1nr0jiGUtAdBJ2qzmLQWSxbtz42pWt4QQMiZ9HvZf5cg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"normalize-path": "^2.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||
"@tsconfig/svelte": "^5.0.8",
|
||||
"dictionary-de": "^3.0.0",
|
||||
"dictionary-en": "^4.0.0",
|
||||
"jsdom": "^29.1.1",
|
||||
"svelte": "^5.55.9",
|
||||
@@ -57,8 +58,8 @@
|
||||
"@tiptap/pm": "^3.23.6",
|
||||
"docx": "^9.7.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
"hunspell-asm": "^4.0.2",
|
||||
"jspdf": "^4.2.1",
|
||||
"nspell": "^2.1.5",
|
||||
"odf-kit": "^0.13.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
igerman98 - dictionaries for German language
|
||||
Copyright (C) 1999-2016 Björn Jacke <bjoern@j3e.de>.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2 or 3 as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
@@ -0,0 +1,729 @@
|
||||
# this is the affix file of the de_DE Hunspell dictionary
|
||||
# derived from the igerman98 dictionary
|
||||
#
|
||||
# Version: 20161207
|
||||
#
|
||||
# Copyright (C) 1998-2015 Bjoern Jacke <bjoern@j3e.de>
|
||||
#
|
||||
# License: GPLv2, GPLv3
|
||||
# There should be a copy of both of this licenses included
|
||||
# with every distribution of this dictionary. Modified
|
||||
# versions using the GPL may only include the GPL
|
||||
|
||||
SET UTF-8
|
||||
TRY esijanrtolcdugmphbyfvkwqxzäüößáéêàâñESIJANRTOLCDUGMPHBYFVKWQXZÄÜÖÉ-.
|
||||
|
||||
PFX U Y 1
|
||||
PFX U 0 un .
|
||||
|
||||
PFX V Y 1
|
||||
PFX V 0 ver .
|
||||
|
||||
SFX F Y 35
|
||||
SFX F 0 nen in
|
||||
SFX F e in e
|
||||
SFX F e innen e
|
||||
SFX F 0 in [^i]n
|
||||
SFX F 0 innen [^i]n
|
||||
SFX F 0 in [^enr]
|
||||
SFX F 0 innen [^enr]
|
||||
SFX F 0 in [^e]r
|
||||
SFX F 0 innen [^e]r
|
||||
SFX F 0 in [^r]er
|
||||
SFX F 0 innen [^r]er
|
||||
SFX F 0 in [^e]rer
|
||||
SFX F 0 innen [^e]rer
|
||||
SFX F 0 in ierer
|
||||
SFX F 0 innen ierer
|
||||
SFX F er in [^i]erer
|
||||
SFX F er innen [^i]erer
|
||||
SFX F in In in
|
||||
SFX F in Innen in
|
||||
SFX F e In e
|
||||
SFX F e Innen e
|
||||
SFX F 0 In [^i]n
|
||||
SFX F 0 Innen [^i]n
|
||||
SFX F 0 In [^en]
|
||||
SFX F 0 Innen [^en]
|
||||
SFX F 0 In [^e]r
|
||||
SFX F 0 Innen [^e]r
|
||||
SFX F 0 In [^r]er
|
||||
SFX F 0 Innen [^r]er
|
||||
SFX F 0 In [^e]rer
|
||||
SFX F 0 Innen [^e]rer
|
||||
SFX F 0 In ierer
|
||||
SFX F 0 Innen ierer
|
||||
SFX F er In [^i]erer
|
||||
SFX F er Innen [^i]erer
|
||||
#SFX F en innen en
|
||||
#SFX F en Innen en
|
||||
|
||||
|
||||
SFX L N 12
|
||||
SFX L 0 tlich n
|
||||
SFX L 0 tliche n
|
||||
SFX L 0 tlicher n
|
||||
SFX L 0 tliches n
|
||||
SFX L 0 tlichem n
|
||||
SFX L 0 tlichen n
|
||||
SFX L 0 lich [^n]
|
||||
SFX L 0 liche [^n]
|
||||
SFX L 0 licher [^n]
|
||||
SFX L 0 liches [^n]
|
||||
SFX L 0 lichem [^n]
|
||||
SFX L 0 lichen [^n]
|
||||
|
||||
|
||||
#SFX H N 2
|
||||
#SFX H 0 heit .
|
||||
#SFX H 0 heiten .
|
||||
|
||||
|
||||
#SFX K N 2
|
||||
#SFX K 0 keit .
|
||||
#SFX K 0 keiten .
|
||||
|
||||
|
||||
SFX M N 10
|
||||
SFX M 0 chen [^se]
|
||||
SFX M 0 chens [^se]
|
||||
SFX M ass ässchen ass
|
||||
SFX M ass ässchens ass
|
||||
SFX M oss össchen oss
|
||||
SFX M oss össchens oss
|
||||
SFX M uss üsschen uss
|
||||
SFX M uss üsschens uss
|
||||
SFX M e chen e
|
||||
SFX M e chens e
|
||||
|
||||
|
||||
SFX A Y 46
|
||||
SFX A 0 r e
|
||||
SFX A 0 n e
|
||||
SFX A 0 m e
|
||||
SFX A 0 s e
|
||||
SFX A 0 e [^elr]
|
||||
SFX A 0 er [^elr]
|
||||
SFX A 0 en [^elr]
|
||||
SFX A 0 em [^elr]
|
||||
SFX A 0 es [^elr]
|
||||
SFX A 0 e [^e][rl]
|
||||
SFX A 0 er [^e][rl]
|
||||
SFX A 0 en [^e][rl]
|
||||
SFX A 0 em [^e][rl]
|
||||
SFX A 0 es [^e][rl]
|
||||
SFX A 0 e [^u]er
|
||||
SFX A 0 er [^u]er
|
||||
SFX A 0 en [^u]er
|
||||
SFX A 0 em [^u]er
|
||||
SFX A 0 es [^u]er
|
||||
SFX A er re uer
|
||||
SFX A er rer uer
|
||||
SFX A er ren uer
|
||||
SFX A er rem uer
|
||||
SFX A er res uer
|
||||
SFX A 0 e [eil]el
|
||||
SFX A 0 er [eil]el
|
||||
SFX A 0 en [eil]el
|
||||
SFX A 0 em [eil]el
|
||||
SFX A 0 es [eil]el
|
||||
SFX A el le [^eil]el
|
||||
SFX A el ler [^eil]el
|
||||
SFX A el len [^eil]el
|
||||
SFX A el lem [^eil]el
|
||||
SFX A el les [^eil]el
|
||||
SFX A lig elig [^aeiouhlräüö]lig
|
||||
SFX A lig elige [^aeiouhlräüö]lig
|
||||
SFX A lig eliger [^aeiouhlräüö]lig
|
||||
SFX A lig eligen [^aeiouhlräüö]lig
|
||||
SFX A lig eligem [^aeiouhlräüö]lig
|
||||
SFX A lig eliges [^aeiouhlräüö]lig
|
||||
SFX A erig rig [^hi]erig
|
||||
SFX A erig rige [^hi]erig
|
||||
SFX A erig riger [^hi]erig
|
||||
SFX A erig rigen [^hi]erig
|
||||
SFX A erig rigem [^hi]erig
|
||||
SFX A erig riges [^hi]erig
|
||||
|
||||
|
||||
SFX C Y 100
|
||||
SFX C 0 ere [^elr]
|
||||
SFX C 0 erer [^elr]
|
||||
SFX C 0 eren [^elr]
|
||||
SFX C 0 erem [^elr]
|
||||
SFX C 0 eres [^elr]
|
||||
SFX C 0 re e
|
||||
SFX C 0 rer e
|
||||
SFX C 0 ren e
|
||||
SFX C 0 rem e
|
||||
SFX C 0 res e
|
||||
SFX C 0 ere [^e][lr]
|
||||
SFX C 0 erer [^e][lr]
|
||||
SFX C 0 eren [^e][lr]
|
||||
SFX C 0 erem [^e][lr]
|
||||
SFX C 0 eres [^e][lr]
|
||||
SFX C el lere el
|
||||
SFX C el lerer el
|
||||
SFX C el leren el
|
||||
SFX C el lerem el
|
||||
SFX C el leres el
|
||||
SFX C er rere uer
|
||||
SFX C er rerer uer
|
||||
SFX C er reren uer
|
||||
SFX C er rerem uer
|
||||
SFX C er reres uer
|
||||
SFX C 0 ere [^u]er
|
||||
SFX C 0 erer [^u]er
|
||||
SFX C 0 eren [^u]er
|
||||
SFX C 0 erem [^u]er
|
||||
SFX C 0 eres [^u]er
|
||||
SFX C lig eligere [^aeiouhlräüö]lig
|
||||
SFX C lig eligerer [^aeiouhlräüö]lig
|
||||
SFX C lig eligeren [^aeiouhlräüö]lig
|
||||
SFX C lig eligerem [^aeiouhlräüö]lig
|
||||
SFX C lig eligeres [^aeiouhlräüö]lig
|
||||
SFX C erig rigere [^hi]erig
|
||||
SFX C erig rigerer [^hi]erig
|
||||
SFX C erig rigeren [^hi]erig
|
||||
SFX C erig rigerem [^hi]erig
|
||||
SFX C erig rigeres [^hi]erig
|
||||
SFX C 0 est [kßsuxz]
|
||||
SFX C 0 este [kßsuxz]
|
||||
SFX C 0 ester [kßsuxz]
|
||||
SFX C 0 esten [kßsuxz]
|
||||
SFX C 0 estem [kßsuxz]
|
||||
SFX C 0 estes [kßsuxz]
|
||||
SFX C 0 st et
|
||||
SFX C 0 ste et
|
||||
SFX C 0 ster et
|
||||
SFX C 0 sten et
|
||||
SFX C 0 stem et
|
||||
SFX C 0 stes et
|
||||
SFX C 0 st igt
|
||||
SFX C 0 ste igt
|
||||
SFX C 0 ster igt
|
||||
SFX C 0 sten igt
|
||||
SFX C 0 stem igt
|
||||
SFX C 0 stes igt
|
||||
SFX C 0 est [^i]gt
|
||||
SFX C 0 este [^i]gt
|
||||
SFX C 0 ester [^i]gt
|
||||
SFX C 0 esten [^i]gt
|
||||
SFX C 0 estem [^i]gt
|
||||
SFX C 0 estes [^i]gt
|
||||
SFX C 0 est [^eg]t
|
||||
SFX C 0 este [^eg]t
|
||||
SFX C 0 ester [^eg]t
|
||||
SFX C 0 esten [^eg]t
|
||||
SFX C 0 estem [^eg]t
|
||||
SFX C 0 estes [^eg]t
|
||||
SFX C 0 st [^kßstxz]
|
||||
SFX C 0 ste [^kßstxz]
|
||||
SFX C 0 ster [^kßstxz]
|
||||
SFX C 0 sten [^kßstxz]
|
||||
SFX C 0 stem [^kßstxz]
|
||||
SFX C 0 stes [^kßstxz]
|
||||
SFX C 0 st nd
|
||||
SFX C 0 ste nd
|
||||
SFX C 0 ster nd
|
||||
SFX C 0 sten nd
|
||||
SFX C 0 stem nd
|
||||
SFX C 0 stes nd
|
||||
SFX C 0 est [^n]d
|
||||
SFX C 0 este [^n]d
|
||||
SFX C 0 ester [^n]d
|
||||
SFX C 0 esten [^n]d
|
||||
SFX C 0 estem [^n]d
|
||||
SFX C 0 estes [^n]d
|
||||
SFX C lig eligst [^aeiouhlräüö]lig
|
||||
SFX C lig eligste [^aeiouhlräüö]lig
|
||||
SFX C lig eligster [^aeiouhlräüö]lig
|
||||
SFX C lig eligsten [^aeiouhlräüö]lig
|
||||
SFX C lig eligstem [^aeiouhlräüö]lig
|
||||
SFX C lig eligstes [^aeiouhlräüö]lig
|
||||
SFX C erig rigst [^hi]erig
|
||||
SFX C erig rigste [^hi]erig
|
||||
SFX C erig rigster [^hi]erig
|
||||
SFX C erig rigsten [^hi]erig
|
||||
SFX C erig rigstem [^hi]erig
|
||||
SFX C erig rigstes [^hi]erig
|
||||
|
||||
|
||||
SFX E Y 1
|
||||
SFX E 0 e .
|
||||
|
||||
|
||||
SFX f Y 4
|
||||
SFX f ph f ph
|
||||
SFX f ph fen ph
|
||||
SFX f phie fie phie
|
||||
SFX f phie fien phie
|
||||
|
||||
|
||||
SFX N Y 1
|
||||
SFX N 0 n .
|
||||
|
||||
|
||||
SFX P Y 1
|
||||
SFX P 0 en .
|
||||
|
||||
|
||||
SFX p Y 26
|
||||
SFX p auf äufe auf
|
||||
SFX p auf äufen auf
|
||||
SFX p aus äuser [hH]aus
|
||||
SFX p aus äusern [hH]aus
|
||||
SFX p arkt ärkte [mM]arkt
|
||||
SFX p arkt ärkten [mM]arkt
|
||||
SFX p ang änge ang
|
||||
SFX p ang ängen ang
|
||||
SFX p uß üße uß
|
||||
SFX p uß üßen uß
|
||||
SFX p oß öße oß
|
||||
SFX p oß ößen oß
|
||||
SFX p aum äume aum
|
||||
SFX p aum äumen aum
|
||||
SFX p ag äge ag
|
||||
SFX p ag ägen ag
|
||||
SFX p ug üge ug
|
||||
SFX p ug ügen ug
|
||||
SFX p all älle all
|
||||
SFX p all ällen all
|
||||
SFX p ass ässe ass
|
||||
SFX p ass ässen ass
|
||||
SFX p uss üsse uss
|
||||
SFX p uss üssen uss
|
||||
SFX p oss össe oss
|
||||
SFX p oss össen oss
|
||||
# last ...oss rules are for swiss de_CH only - but do not affect de_DE
|
||||
|
||||
|
||||
SFX R Y 3
|
||||
SFX R 0 er [^e]
|
||||
SFX R 0 ern [^e]
|
||||
SFX R 0 r e
|
||||
|
||||
|
||||
SFX S Y 1
|
||||
SFX S 0 s .
|
||||
|
||||
|
||||
SFX q Y 2
|
||||
SFX q 0 se s
|
||||
SFX q 0 sen s
|
||||
|
||||
|
||||
SFX Q Y 1
|
||||
SFX Q 0 ses s
|
||||
#SFX Q 0 se s
|
||||
#SFX Q 0 sen s
|
||||
|
||||
|
||||
SFX T Y 1
|
||||
SFX T 0 es .
|
||||
|
||||
|
||||
SFX J Y 12
|
||||
SFX J n ung [bgkpßsz]eln
|
||||
SFX J n ungen [bgkpßsz]eln
|
||||
SFX J eln lung eln
|
||||
SFX J n ung ern
|
||||
SFX J en ung en
|
||||
SFX J eln lungen eln
|
||||
SFX J n ungen ern
|
||||
SFX J en ungen en
|
||||
SFX J 0 ung [^n]
|
||||
SFX J 0 ungen [^n]
|
||||
SFX J el lung el
|
||||
SFX J el lungen el
|
||||
|
||||
|
||||
SFX B N 12
|
||||
SFX B n bar e[lr]n
|
||||
SFX B n bare e[lr]n
|
||||
SFX B n baren e[lr]n
|
||||
SFX B n barer e[lr]n
|
||||
SFX B n bares e[lr]n
|
||||
SFX B n barem e[lr]n
|
||||
SFX B en bar en
|
||||
SFX B en bare en
|
||||
SFX B en baren en
|
||||
SFX B en barer en
|
||||
SFX B en bares en
|
||||
SFX B en barem en
|
||||
|
||||
|
||||
SFX D Y 6
|
||||
SFX D 0 d n
|
||||
SFX D 0 de n
|
||||
SFX D 0 den n
|
||||
SFX D 0 der n
|
||||
SFX D 0 des n
|
||||
SFX D 0 dem n
|
||||
|
||||
|
||||
|
||||
SFX W Y 5
|
||||
SFX W en 0 en
|
||||
SFX W n 0 [^e]n
|
||||
SFX W st 0 [^s]st
|
||||
SFX W t 0 sst
|
||||
SFX W t 0 [^s]t
|
||||
|
||||
|
||||
SFX I Y 16
|
||||
SFX I n 0 en
|
||||
SFX I eln le eln
|
||||
SFX I n e eln
|
||||
SFX I ern re ern
|
||||
SFX I n e ern
|
||||
SFX I n t e[lr]n
|
||||
SFX I n t [dt]en
|
||||
SFX I en t [^dimnt]en
|
||||
SFX I en t eien
|
||||
SFX I n t [^e]ien
|
||||
SFX I n t chnen
|
||||
SFX I en t [^c]h[mn]en
|
||||
SFX I n t [^aäehilmnoöuür][mn]en
|
||||
SFX I en t [aäeilmnoöuür][mn]en
|
||||
SFX I n e un
|
||||
SFX I n t un
|
||||
|
||||
|
||||
SFX X Y 26
|
||||
SFX X n t e[lr]n
|
||||
SFX X n t [dtw]en
|
||||
SFX X en t eien
|
||||
SFX X n t [^e]ien
|
||||
SFX X en t [^ditmnw]en
|
||||
SFX X n t chnen
|
||||
SFX X en t [^c]h[mn]en
|
||||
SFX X n t [^aäehilmnoöuür][mn]en
|
||||
SFX X en t [aäeilmnoöuür][mn]en
|
||||
SFX X n t un
|
||||
SFX X st 0 tst
|
||||
SFX X n st e[lr]n
|
||||
SFX X n st [dtw]en
|
||||
SFX X en st [^dimnßstwzx]en
|
||||
SFX X en st eien
|
||||
SFX X n st [^e]ien
|
||||
SFX X n st chnen
|
||||
SFX X en st [^c]h[mn]en
|
||||
SFX X n st [^aäehilmnoöuür][mn]en
|
||||
SFX X en st [aäeilmnoöuür][mn]en
|
||||
SFX X n st un
|
||||
SFX X n st [ßsxz]en
|
||||
SFX X n st ssen
|
||||
SFX X n st schen
|
||||
SFX X t st [^sz]t
|
||||
SFX X t est zt
|
||||
|
||||
|
||||
SFX Y Y 36
|
||||
SFX Y n te e[lr]n
|
||||
SFX Y n te [dtw]en
|
||||
SFX Y en te [^dimntw]en
|
||||
SFX Y en te eien
|
||||
SFX Y n te [^e]ien
|
||||
SFX Y n te chnen
|
||||
SFX Y en te [^c]h[mn]en
|
||||
SFX Y n te [^aäehilmnoöuür][mn]en
|
||||
SFX Y en te [aäeilmnoöuür][mn]en
|
||||
SFX Y n test e[lr]n
|
||||
SFX Y n test [dtw]en
|
||||
SFX Y en test [^dimntw]en
|
||||
SFX Y en test eien
|
||||
SFX Y n test [^e]ien
|
||||
SFX Y n test chnen
|
||||
SFX Y en test [^c]h[mn]en
|
||||
SFX Y n test [^aäehilmnoöuür][mn]en
|
||||
SFX Y en test [aäeilmnoöuür][mn]en
|
||||
SFX Y n tet e[lr]n
|
||||
SFX Y n tet [dtw]en
|
||||
SFX Y en tet [^dimntw]en
|
||||
SFX Y en tet eien
|
||||
SFX Y n tet [^e]ien
|
||||
SFX Y n tet chnen
|
||||
SFX Y en tet [^c]h[mn]en
|
||||
SFX Y n tet [^aäehilmnoöuür][mn]en
|
||||
SFX Y en tet [aäeilmnoöuür][mn]en
|
||||
SFX Y n ten e[lr]n
|
||||
SFX Y n ten [dtw]en
|
||||
SFX Y en ten [^dimntw]en
|
||||
SFX Y en ten eien
|
||||
SFX Y n ten [^e]ien
|
||||
SFX Y n ten chnen
|
||||
SFX Y en ten [^c]h[mn]en
|
||||
SFX Y n ten [^aäehilmnoöuür][mn]en
|
||||
SFX Y en ten [aäeilmnoöuür][mn]en
|
||||
|
||||
|
||||
SFX Z Y 15
|
||||
SFX Z 0 st [^hßsz]
|
||||
SFX Z 0 st [^c]h
|
||||
SFX Z 0 st [^s]ch
|
||||
SFX Z 0 est [dfkstz]
|
||||
SFX Z 0 est ch
|
||||
SFX Z 0 est [au]ß
|
||||
SFX Z 0 est ieß
|
||||
SFX Z 0 est [io]ss
|
||||
SFX Z 0 t [^dt]
|
||||
SFX Z 0 et [dt]
|
||||
SFX Z 0 n e
|
||||
SFX Z 0 en ie
|
||||
SFX Z 0 en [^e]
|
||||
SFX Z 0 est iess
|
||||
SFX Z 0 est [au]ss
|
||||
# last two ...ss rules only used for swiss de_CH - but de_DE is unaffected
|
||||
|
||||
|
||||
SFX O Y 21
|
||||
SFX O n tes e[lr]n
|
||||
SFX O n tes [dtw]en
|
||||
SFX O en tes [^dmntw]en
|
||||
SFX O n tes chnen
|
||||
SFX O en tes [^c]h[mn]en
|
||||
SFX O n tes [^aäehilmnoöuür][mn]en
|
||||
SFX O en tes [aäeilmnoöuür][mn]en
|
||||
SFX O n ter e[lr]n
|
||||
SFX O n ter [dtw]en
|
||||
SFX O en ter [^dmntw]en
|
||||
SFX O n ter chnen
|
||||
SFX O en ter [^c]h[mn]en
|
||||
SFX O n ter [^aäehilmnoöuür][mn]en
|
||||
SFX O en ter [aäeilmnoöuür][mn]en
|
||||
SFX O n tem e[lr]n
|
||||
SFX O n tem [dtw]en
|
||||
SFX O en tem [^dmntw]en
|
||||
SFX O n tem chnen
|
||||
SFX O en tem [^c]h[mn]en
|
||||
SFX O n tem [^aäehilmnoöuür][mn]en
|
||||
SFX O en tem [aäeilmnoöuür][mn]en
|
||||
|
||||
REP 28
|
||||
REP f ph
|
||||
REP ph f
|
||||
REP ß ss
|
||||
REP ss ß
|
||||
REP s ss
|
||||
REP ss s
|
||||
REP i ie
|
||||
REP ie i
|
||||
REP ee e
|
||||
REP o oh
|
||||
REP oh o
|
||||
REP a ah
|
||||
REP ah a
|
||||
REP e eh
|
||||
REP eh e
|
||||
REP ae ä
|
||||
REP oe ö
|
||||
REP ue ü
|
||||
REP Ae Ä
|
||||
REP Oe Ö
|
||||
REP Ue Ü
|
||||
REP d t
|
||||
REP t d
|
||||
REP th t
|
||||
REP t th
|
||||
REP r rh
|
||||
REP ch k
|
||||
REP k ch
|
||||
#REP eee ee-E
|
||||
|
||||
|
||||
# this one will allow "-Eltern" - Hunspell 1.1.5 bug, but CHECKSHARPS obsoletes LANG de_DE
|
||||
#LANG de_DE
|
||||
CHECKSHARPS
|
||||
|
||||
|
||||
COMPOUNDBEGIN x
|
||||
COMPOUNDMIDDLE y
|
||||
COMPOUNDEND z
|
||||
FORBIDDENWORD d
|
||||
|
||||
# Prefixes are allowed at the beginning of compounds,
|
||||
# suffixes are allowed at the end of compounds by default:
|
||||
# (prefix)?(root)+(affix)?
|
||||
# Affixes with COMPOUNDPERMITFLAG may be inside of compounds.
|
||||
COMPOUNDPERMITFLAG c
|
||||
|
||||
ONLYINCOMPOUND o
|
||||
|
||||
# my PSEUDOROOT h(elper) flag
|
||||
NEEDAFFIX h
|
||||
|
||||
# forbid uppercase characters at compound word bounds
|
||||
# BUT I want to take care about it myself ;-)
|
||||
# CHECKCOMPOUNDCASE
|
||||
KEEPCASE w
|
||||
|
||||
# Affixes signed with CIRCUMFIX flag may be on a word when this word also has a prefix with CIRCUMFIX flag and vice versa.
|
||||
# for decapitalizing nouns with fogemorphemes
|
||||
CIRCUMFIX f
|
||||
|
||||
# this one would make a separate dict entry "Denkmalsschutz" invalidate the
|
||||
# compound of "Denkmal"+"schutz". We do not want this feature here...
|
||||
# CHECKCOMPOUNDREP
|
||||
|
||||
# make not all possible suggestions for typos of Flicken or some rare words
|
||||
NOSUGGEST n
|
||||
|
||||
WORDCHARS ß-.
|
||||
|
||||
# - setting this to 2 decreases performance by 1/10 but is needed for "öl" and "ei"
|
||||
# - setting this to 1 for handling Fuge-elements with dashes (Arbeits-) dash will
|
||||
# be a special word but - is handled as a affix now
|
||||
COMPOUNDMIN 2
|
||||
|
||||
# this ones are for Duden R36 (old orthography)
|
||||
#CHECKCOMPOUNDPATTERN 2 #oldspell
|
||||
#CHECKCOMPOUNDPATTERN ee e #oldspell
|
||||
#CHECKCOMPOUNDPATTERN oo o #oldspell
|
||||
# also need oo o
|
||||
|
||||
# this one needs to be flagable to be used for old orthography
|
||||
#CHECKCOMPOUNDTRIPLE
|
||||
|
||||
|
||||
PFX i Y 1
|
||||
PFX i 0 -/coyf .
|
||||
|
||||
SFX j Y 3
|
||||
SFX j 0 0/xoc .
|
||||
SFX j 0 -/zocf .
|
||||
SFX j 0 -/cz .
|
||||
|
||||
# Female forms for compound/Compound words:
|
||||
# attention: [^e][^n] does also filter out "...er" !
|
||||
SFX g Y 12
|
||||
SFX g 0 innen/xyoc [^n]
|
||||
SFX g en innen/xyoc en
|
||||
SFX g 0 Innen/xyoc [^n]
|
||||
SFX g en Innen/xyoc en
|
||||
SFX g 0 innen/xyocf [^n]
|
||||
SFX g en innen/xyocf en
|
||||
SFX g 0 Innen/xyocf [^n]
|
||||
SFX g en Innen/xyocf en
|
||||
SFX g 0 innen-/cz [^n]
|
||||
SFX g en innen-/cz en
|
||||
SFX g 0 Innen-/cz [^n]
|
||||
SFX g en Innen-/cz en
|
||||
|
||||
|
||||
PFX k Y 2
|
||||
PFX k 0 -/coxf .
|
||||
PFX k 0 0/coy .
|
||||
|
||||
SFX e Y 2
|
||||
SFX e 0 0/yoc .
|
||||
SFX e 0 -/zc .
|
||||
|
||||
# for Uppercased end-words to prepend - and lowercase: (Tier/EPSm) (EX: Bettbezüge und *-laken*)
|
||||
# AND
|
||||
# for lowercased end-words to prepend - and re-uppercase : (tier/EPSozm) (EX: Arbeits*-Tier*)
|
||||
#PFX m A -a/co A
|
||||
#PFX m a -/ a
|
||||
PFX m Y 58
|
||||
PFX m A -a A
|
||||
PFX m B -b B
|
||||
PFX m C -c C
|
||||
PFX m D -d D
|
||||
PFX m E -e E
|
||||
PFX m F -f F
|
||||
PFX m G -g G
|
||||
PFX m H -h H
|
||||
PFX m I -i I
|
||||
PFX m J -j J
|
||||
PFX m K -k K
|
||||
PFX m L -l L
|
||||
PFX m M -m M
|
||||
PFX m N -n N
|
||||
PFX m O -o O
|
||||
PFX m P -p P
|
||||
PFX m Q -q Q
|
||||
PFX m R -r R
|
||||
PFX m S -s S
|
||||
PFX m T -t T
|
||||
PFX m U -u U
|
||||
PFX m V -v V
|
||||
PFX m W -w W
|
||||
PFX m X -x X
|
||||
PFX m Y -y Y
|
||||
PFX m Z -z Z
|
||||
PFX m Ä -ä Ä
|
||||
PFX m Ö -ö Ö
|
||||
PFX m Ü -ü Ü
|
||||
PFX m a -A/co a
|
||||
PFX m b -B/co b
|
||||
PFX m c -C/co c
|
||||
PFX m d -D/co d
|
||||
PFX m e -E/co e
|
||||
PFX m f -F/co f
|
||||
PFX m g -G/co g
|
||||
PFX m h -H/co h
|
||||
PFX m i -I/co i
|
||||
PFX m j -J/co j
|
||||
PFX m k -K/co k
|
||||
PFX m l -L/co l
|
||||
PFX m m -M/co m
|
||||
PFX m n -N/co n
|
||||
PFX m o -O/co o
|
||||
PFX m p -P/co p
|
||||
PFX m q -Q/co q
|
||||
PFX m r -R/co r
|
||||
PFX m s -S/co s
|
||||
PFX m t -T/co t
|
||||
PFX m u -U/co u
|
||||
PFX m v -V/co v
|
||||
PFX m w -W/co w
|
||||
PFX m x -X/co x
|
||||
PFX m y -Y/co y
|
||||
PFX m z -Z/co z
|
||||
PFX m ä -Ä/co ä
|
||||
PFX m ö -Ö/co ö
|
||||
PFX m ü -Ü/co ü
|
||||
|
||||
|
||||
# Decapitalizing: (not used ATM... )
|
||||
# /co(f) : compound permit, in coumpount only, (decapitalizing with fogemorphemes)
|
||||
#PFX l Y 29
|
||||
#PFX l A a/co A
|
||||
#PFX l Ä ä/co Ä
|
||||
#PFX l B b/co B
|
||||
#PFX l C c/co C
|
||||
#PFX l D d/co D
|
||||
#PFX l E e/co E
|
||||
#PFX l F f/co F
|
||||
#PFX l G g/co G
|
||||
#PFX l H h/co H
|
||||
#PFX l I i/co I
|
||||
#PFX l J j/co J
|
||||
#PFX l K k/co K
|
||||
#PFX l L l/co L
|
||||
#PFX l M m/co M
|
||||
#PFX l N n/co N
|
||||
#PFX l O o/co O
|
||||
#PFX l Ö ö/co Ö
|
||||
#PFX l P p/co P
|
||||
#PFX l Q q/co Q
|
||||
#PFX l R r/co R
|
||||
#PFX l S s/co S
|
||||
#PFX l T t/co T
|
||||
#PFX l U u/co U
|
||||
#PFX l Ü ü/co Ü
|
||||
#PFX l V v/co V
|
||||
#PFX l W w/co W
|
||||
#PFX l X x/co X
|
||||
#PFX l Y y/co Y
|
||||
#PFX l Z z/co Z
|
||||
|
||||
# private hunspell flags:
|
||||
# --x : not for capmain (rare words)
|
||||
|
||||
# With "BREAK -" some wrong forms are accepted but that is needed for US-Wirtschaft etc.
|
||||
# So enabling this is the lesser evil. No perfect solution found so far...
|
||||
BREAK 2
|
||||
BREAK -
|
||||
BREAK .
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,24 +1,50 @@
|
||||
import nspell, { type NSpell } from 'nspell';
|
||||
import type { HunspellFactory } from 'hunspell-asm';
|
||||
import { NO_LANGUAGE, type DocumentLanguage } from '../storage/documentLanguage';
|
||||
|
||||
export type Checker = NSpell;
|
||||
// Thin engine-agnostic view over a loaded dictionary, so the controller and
|
||||
// extension never touch hunspell-asm directly.
|
||||
export interface Checker {
|
||||
correct(word: string): boolean;
|
||||
suggest(word: string): string[];
|
||||
add(word: string): void;
|
||||
}
|
||||
|
||||
// One in-flight/resolved load per code, so switching back to a language is
|
||||
// instant and concurrent callers share a single fetch.
|
||||
const cache = new Map<string, Promise<Checker | null>>();
|
||||
|
||||
async function fetchText(url: string): Promise<string> {
|
||||
// The wasm module is language-independent; load it once and share it. The
|
||||
// dynamic import keeps hunspell-asm (~780kB, base64-inlined wasm) out of the
|
||||
// initial bundle — Vite splits it into a chunk fetched on first spell-check.
|
||||
let modulePromise: Promise<HunspellFactory> | null = null;
|
||||
function loadFactory(): Promise<HunspellFactory> {
|
||||
if (!modulePromise) modulePromise = import('hunspell-asm').then((m) => m.loadModule());
|
||||
return modulePromise;
|
||||
}
|
||||
|
||||
async function fetchBytes(url: string): Promise<Uint8Array> {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`${res.status} ${res.statusText} for ${url}`);
|
||||
return res.text();
|
||||
return new Uint8Array(await res.arrayBuffer());
|
||||
}
|
||||
|
||||
async function build(code: string): Promise<Checker> {
|
||||
// Vendored assets: public/dictionaries/<code>/<code>.{aff,dic}. BASE_URL keeps
|
||||
// this correct under a non-root deploy base.
|
||||
const base = `${import.meta.env.BASE_URL}dictionaries/${code}/${code}`;
|
||||
const [aff, dic] = await Promise.all([fetchText(`${base}.aff`), fetchText(`${base}.dic`)]);
|
||||
return nspell(aff, dic);
|
||||
const [factory, aff, dic] = await Promise.all([
|
||||
loadFactory(),
|
||||
fetchBytes(`${base}.aff`),
|
||||
fetchBytes(`${base}.dic`),
|
||||
]);
|
||||
const affPath = factory.mountBuffer(aff, `${code}.aff`);
|
||||
const dicPath = factory.mountBuffer(dic, `${code}.dic`);
|
||||
const hunspell = factory.create(affPath, dicPath);
|
||||
return {
|
||||
correct: (word) => hunspell.spell(word),
|
||||
suggest: (word) => hunspell.suggest(word),
|
||||
add: (word) => hunspell.addWord(word),
|
||||
};
|
||||
}
|
||||
|
||||
// Lazily load (and cache) the Hunspell checker for a language. Resolves to null
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
declare module 'nspell' {
|
||||
export interface NSpell {
|
||||
correct(word: string): boolean;
|
||||
suggest(word: string): string[];
|
||||
spell(word: string): { correct: boolean; forbidden: boolean; warn: boolean };
|
||||
add(word: string, model?: string): NSpell;
|
||||
remove(word: string): NSpell;
|
||||
wordCharacters(): string[] | undefined;
|
||||
}
|
||||
export default function nspell(aff: string, dic: string): NSpell;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export interface LanguageDef {
|
||||
// public/dictionaries/<code>/ and appending an entry here.
|
||||
export const LANGUAGES: LanguageDef[] = [
|
||||
{ code: 'en', label: 'English (US)', odf: { language: 'en', country: 'US' } },
|
||||
{ code: 'de', label: 'Deutsch', odf: { language: 'de', country: 'DE' } },
|
||||
];
|
||||
|
||||
export const DEFAULT_LANGUAGE: DocumentLanguage = 'en';
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { loadModule, type Hunspell } from 'hunspell-asm';
|
||||
|
||||
// Exercises the real engine against the vendored dictionaries, mirroring
|
||||
// dictionary.ts's mount+create. Guards German compounds, which rely on the
|
||||
// .aff COMPOUND rules.
|
||||
function dictPath(rel: string): string {
|
||||
return fileURLToPath(new URL(`../../public/dictionaries/${rel}`, import.meta.url));
|
||||
}
|
||||
|
||||
async function makeChecker(code: string): Promise<Hunspell> {
|
||||
const factory = await loadModule();
|
||||
const aff = factory.mountBuffer(readFileSync(dictPath(`${code}/${code}.aff`)), `${code}.aff`);
|
||||
const dic = factory.mountBuffer(readFileSync(dictPath(`${code}/${code}.dic`)), `${code}.dic`);
|
||||
return factory.create(aff, dic);
|
||||
}
|
||||
|
||||
describe('German spell-check (hunspell-asm)', () => {
|
||||
let de: Hunspell;
|
||||
beforeAll(async () => {
|
||||
de = await makeChecker('de');
|
||||
});
|
||||
|
||||
it('accepts compound words that are not standalone dictionary entries', () => {
|
||||
for (const w of ['Fußgänger', 'Krankenversicherung', 'Bundesausbildungsförderungsgesetz', 'Autobahnraststätte']) {
|
||||
expect(de.spell(w), w).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('accepts base words with umlauts and ß', () => {
|
||||
for (const w of ['Straße', 'Universität', 'Häuser', 'schön']) {
|
||||
expect(de.spell(w), w).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('flags a genuine misspelling and suggests the correction', () => {
|
||||
expect(de.spell('Computerx')).toBe(false);
|
||||
expect(de.suggest('Computerx')).toContain('Computer');
|
||||
});
|
||||
|
||||
it('accepts a runtime-added personal word', () => {
|
||||
expect(de.spell('Claudewort')).toBe(false);
|
||||
de.addWord('Claudewort');
|
||||
expect(de.spell('Claudewort')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,15 @@ import pkg from './package.json' with { type: 'json' };
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
define: { __APP_VERSION__: JSON.stringify(pkg.version) },
|
||||
// hunspell-asm's ESM chain calls CJS/UMD deps as functions that a bundler
|
||||
// yields as non-callable namespaces (glue → "runtimeModule is not a function";
|
||||
// nanoid → CANNOT_CALL_NAMESPACE). The CJS builds' require-interop fixes both.
|
||||
resolve: {
|
||||
alias: {
|
||||
'hunspell-asm': 'hunspell-asm/dist/cjs/index.js',
|
||||
'emscripten-wasm-loader': 'emscripten-wasm-loader/dist/cjs/index.js',
|
||||
},
|
||||
},
|
||||
// Test-only config; never enters the production bundle (vitest is dev-only).
|
||||
// jsdom supplies a global DOMParser, so the export/import specs need no setup.
|
||||
test: {
|
||||
|
||||
Reference in new issue
Block a user