fr-spell 1.0.2 → 1.0.3
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.
- package/README.cn.md +17 -63
- package/README.fr.md +17 -63
- package/README.md +17 -63
- package/package.json +17 -16
- package/benchmark/checklist_adje_100.json +0 -702
- package/benchmark/checklist_lemma_verb_100.json +0 -402
- package/benchmark/checklist_noun_100.json +0 -702
- package/benchmark/checklist_verb_100.json +0 -702
- package/benchmark/generate-checklists.js +0 -192
- package/benchmark/run-benchmark.js +0 -123
- package/dist/models/community/derive_form_model.int8.onnx +0 -0
- package/dist/models/community/derive_form_vocab.json +0 -74
- package/dist/models/community/lemma_type_labels.json +0 -47
- package/dist/models/community/lemma_type_model.int8.onnx +0 -0
- package/dist/models/community/lemma_type_vocab.json +0 -244
- package/scripts/build.js +0 -53
- package/src/frspell.browser.global.js +0 -9
- package/src/module/Predictor.browser.js +0 -428
- package/test/test.js +0 -21
- /package/{dist/frspell.browser.js → frspell.browser.js} +0 -0
- /package/{src/frspell.js → index.js} +0 -0
- /package/{src/module → module}/Predictor.js +0 -0
package/README.cn.md
CHANGED
|
@@ -45,6 +45,23 @@ console.log(verb);
|
|
|
45
45
|
{ lemma: 'manger', wordType: 'VERB', person: 'FST_PL', mode: 'INDI', tense: 'PRES', output: 'mangeons', confidence: 0.9999864523, timeMs: 4.79 }
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## 浏览器用法
|
|
49
|
+
|
|
50
|
+
直接使用本包内的浏览器 Bundle 与模型资源:
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script src="./frspell.browser.js"></script>
|
|
54
|
+
<script>
|
|
55
|
+
(async () => {
|
|
56
|
+
const predictor = await window.FrSpell({
|
|
57
|
+
modelBasePath: './models/community'
|
|
58
|
+
});
|
|
59
|
+
const result = await predictor.lemma('mangeons');
|
|
60
|
+
console.log(result);
|
|
61
|
+
})();
|
|
62
|
+
</script>
|
|
63
|
+
```
|
|
64
|
+
|
|
48
65
|
## 预测参数说明
|
|
49
66
|
|
|
50
67
|
词元预测(lemma):
|
|
@@ -97,14 +114,6 @@ console.log(verb);
|
|
|
97
114
|
- 参考定义文件中还有更多时态名称,但本包实现目前只支持 `PRES`、`IMPA`、`FUTU`、`PASS`。
|
|
98
115
|
- 对于名词/形容词派生,用户输入时不需要 `mode` 与 `tense`。
|
|
99
116
|
|
|
100
|
-
## 运行测试
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
npm test
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
该命令会执行 test/test.js,并输出示例预测结果。
|
|
107
|
-
|
|
108
117
|
## 查看帮助
|
|
109
118
|
|
|
110
119
|
```bash
|
|
@@ -113,63 +122,8 @@ npm run help
|
|
|
113
122
|
|
|
114
123
|
该命令会输出参数速查说明,覆盖 `lemma`、`nounDerive`、`adjeDerive`、`verbDerive`、`derive` 及 person/mode/tense 可用值。
|
|
115
124
|
|
|
116
|
-
## 构建浏览器 Bundle
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm run build
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
构建产物:
|
|
123
|
-
|
|
124
|
-
- `dist/frspell.browser.js`(单个 JS 文件,挂载 `window.FrSpell`)
|
|
125
|
-
- `dist/models/community/*.onnx|*.json`(模型与词表等必需资源)
|
|
126
|
-
|
|
127
|
-
构建完成后,将整个 `dist` 文件夹复制到前端项目中,然后使用:
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<script src="./dist/frspell.browser.js"></script>
|
|
131
|
-
<script>
|
|
132
|
-
(async () => {
|
|
133
|
-
const predictor = await window.FrSpell({
|
|
134
|
-
modelBasePath: './dist/models/community'
|
|
135
|
-
});
|
|
136
|
-
const result = await predictor.lemma('mangeons');
|
|
137
|
-
console.log(result);
|
|
138
|
-
})();
|
|
139
|
-
</script>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## 运行基准测试
|
|
143
|
-
|
|
144
|
-
1) 先生成检查清单 JSON(每类 100 条):
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
npm run benchmark:prepare
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
2) 运行全部基准测试:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
npm run benchmark
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
3) 可选:按单项运行:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npm run benchmark:lemma
|
|
160
|
-
npm run benchmark:noun
|
|
161
|
-
npm run benchmark:verb
|
|
162
|
-
npm run benchmark:adje
|
|
163
|
-
```
|
|
164
|
-
|
|
165
125
|
## 基准结果(最近一次本地运行)
|
|
166
126
|
|
|
167
|
-
基准命令:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npm run benchmark
|
|
171
|
-
```
|
|
172
|
-
|
|
173
127
|
结果:
|
|
174
128
|
|
|
175
129
|
- 由变位预测词元:97/100,准确率 97.00%,平均 22.21 ms
|
package/README.fr.md
CHANGED
|
@@ -45,6 +45,23 @@ Exemple de sortie a l'execution :
|
|
|
45
45
|
{ lemma: 'manger', wordType: 'VERB', person: 'FST_PL', mode: 'INDI', tense: 'PRES', output: 'mangeons', confidence: 0.9999864523, timeMs: 4.79 }
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Utilisation navigateur
|
|
49
|
+
|
|
50
|
+
Utilisez directement le bundle navigateur et les ressources modele inclus dans ce package :
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script src="./frspell.browser.js"></script>
|
|
54
|
+
<script>
|
|
55
|
+
(async () => {
|
|
56
|
+
const predictor = await window.FrSpell({
|
|
57
|
+
modelBasePath: './models/community'
|
|
58
|
+
});
|
|
59
|
+
const result = await predictor.lemma('mangeons');
|
|
60
|
+
console.log(result);
|
|
61
|
+
})();
|
|
62
|
+
</script>
|
|
63
|
+
```
|
|
64
|
+
|
|
48
65
|
## Parametres de prediction
|
|
49
66
|
|
|
50
67
|
Prediction de lemme :
|
|
@@ -97,14 +114,6 @@ Note :
|
|
|
97
114
|
- Le fichier de definitions d'origine contient plus de noms de temps, mais ce package prend actuellement en charge uniquement `PRES`, `IMPA`, `FUTU`, `PASS`.
|
|
98
115
|
- Pour les appels nom/adjectif, `mode` et `tense` ne sont pas requis dans l'entree utilisateur.
|
|
99
116
|
|
|
100
|
-
## Exécuter les tests
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
npm test
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
Cette commande exécute test/test.js et affiche des exemples de prédiction.
|
|
107
|
-
|
|
108
117
|
## Afficher l'aide
|
|
109
118
|
|
|
110
119
|
```bash
|
|
@@ -113,63 +122,8 @@ npm run help
|
|
|
113
122
|
|
|
114
123
|
Cette commande affiche un guide rapide des paramètres pour `lemma`, `nounDerive`, `adjeDerive`, `verbDerive` et `derive`, avec les valeurs autorisées de person/mode/tense.
|
|
115
124
|
|
|
116
|
-
## Construire le bundle navigateur
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm run build
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Sortie de build :
|
|
123
|
-
|
|
124
|
-
- `dist/frspell.browser.js` (fichier JS unique, expose `window.FrSpell`)
|
|
125
|
-
- `dist/models/community/*.onnx|*.json` (ressources modèle et vocabulaire requises)
|
|
126
|
-
|
|
127
|
-
Après le build, copiez tout le dossier `dist` dans votre projet frontend, puis utilisez :
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<script src="./dist/frspell.browser.js"></script>
|
|
131
|
-
<script>
|
|
132
|
-
(async () => {
|
|
133
|
-
const predictor = await window.FrSpell({
|
|
134
|
-
modelBasePath: './dist/models/community'
|
|
135
|
-
});
|
|
136
|
-
const result = await predictor.lemma('mangeons');
|
|
137
|
-
console.log(result);
|
|
138
|
-
})();
|
|
139
|
-
</script>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Exécuter les benchmarks
|
|
143
|
-
|
|
144
|
-
1) Générer les fichiers JSON de checklist (100 éléments chacun) :
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
npm run benchmark:prepare
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
2) Exécuter toutes les suites de benchmark :
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
npm run benchmark
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
3) Optionnel : exécuter une suite spécifique :
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npm run benchmark:lemma
|
|
160
|
-
npm run benchmark:noun
|
|
161
|
-
npm run benchmark:verb
|
|
162
|
-
npm run benchmark:adje
|
|
163
|
-
```
|
|
164
|
-
|
|
165
125
|
## Résultats de benchmark (dernier run local)
|
|
166
126
|
|
|
167
|
-
Commande de benchmark :
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npm run benchmark
|
|
171
|
-
```
|
|
172
|
-
|
|
173
127
|
Résultats :
|
|
174
128
|
|
|
175
129
|
- lemme depuis une conjugaison : 97/100, précision 97.00 %, moyenne 22.21 ms
|
package/README.md
CHANGED
|
@@ -45,6 +45,23 @@ Sample runtime output:
|
|
|
45
45
|
{ lemma: 'manger', wordType: 'VERB', person: 'FST_PL', mode: 'INDI', tense: 'PRES', output: 'mangeons', confidence: 0.9999864523, timeMs: 4.79 }
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Browser Usage
|
|
49
|
+
|
|
50
|
+
Use the browser bundle and model assets included in this package:
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script src="./frspell.browser.js"></script>
|
|
54
|
+
<script>
|
|
55
|
+
(async () => {
|
|
56
|
+
const predictor = await window.FrSpell({
|
|
57
|
+
modelBasePath: './models/community'
|
|
58
|
+
});
|
|
59
|
+
const result = await predictor.lemma('mangeons');
|
|
60
|
+
console.log(result);
|
|
61
|
+
})();
|
|
62
|
+
</script>
|
|
63
|
+
```
|
|
64
|
+
|
|
48
65
|
## Prediction Parameters
|
|
49
66
|
|
|
50
67
|
Lemma prediction:
|
|
@@ -97,14 +114,6 @@ Note:
|
|
|
97
114
|
- The original grammar definition file includes more tense names, but this package implementation currently supports only `PRES`, `IMPA`, `FUTU`, `PASS`.
|
|
98
115
|
- For noun/adjective derive calls, `mode` and `tense` are not required in user input.
|
|
99
116
|
|
|
100
|
-
## Run Test
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
npm test
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
This executes test/test.js and prints sample prediction outputs.
|
|
107
|
-
|
|
108
117
|
## Run Help
|
|
109
118
|
|
|
110
119
|
```bash
|
|
@@ -113,63 +122,8 @@ npm run help
|
|
|
113
122
|
|
|
114
123
|
This prints a quick parameter reference for `lemma`, `nounDerive`, `adjeDerive`, `verbDerive`, and `derive`, including allowed person/mode/tense values.
|
|
115
124
|
|
|
116
|
-
## Build Browser Bundle
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm run build
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Build output:
|
|
123
|
-
|
|
124
|
-
- `dist/frspell.browser.js` (single JS bundle, attach `window.FrSpell`)
|
|
125
|
-
- `dist/models/community/*.onnx|*.json` (required model and vocab assets)
|
|
126
|
-
|
|
127
|
-
After build, copy the whole `dist` folder into your frontend project, then use:
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<script src="./dist/frspell.browser.js"></script>
|
|
131
|
-
<script>
|
|
132
|
-
(async () => {
|
|
133
|
-
const predictor = await window.FrSpell({
|
|
134
|
-
modelBasePath: './dist/models/community'
|
|
135
|
-
});
|
|
136
|
-
const result = await predictor.lemma('mangeons');
|
|
137
|
-
console.log(result);
|
|
138
|
-
})();
|
|
139
|
-
</script>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Run Benchmark
|
|
143
|
-
|
|
144
|
-
1) Prepare checklist JSON files (100 items each):
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
npm run benchmark:prepare
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
2) Run all benchmark suites:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
npm run benchmark
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
3) Optional single-suite runs:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npm run benchmark:lemma
|
|
160
|
-
npm run benchmark:noun
|
|
161
|
-
npm run benchmark:verb
|
|
162
|
-
npm run benchmark:adje
|
|
163
|
-
```
|
|
164
|
-
|
|
165
125
|
## Benchmark Result (Latest Local Run)
|
|
166
126
|
|
|
167
|
-
Benchmark command:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npm run benchmark
|
|
171
|
-
```
|
|
172
|
-
|
|
173
127
|
Results:
|
|
174
128
|
|
|
175
129
|
- lemma from conjugation: 97/100, accuracy 97.00%, average 22.21 ms
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fr-spell",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Lightweight French lemmatization and conjugation. Convert between nouns, verbs, and adjectives using fast, quantized INT8 ONNX models under 2MB.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./
|
|
6
|
+
"main": "./index.js",
|
|
7
7
|
"exports": {
|
|
8
|
-
".": "./
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./browser": "./frspell.browser.js"
|
|
9
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"frspell.browser.js",
|
|
14
|
+
"module",
|
|
15
|
+
"models",
|
|
16
|
+
"scripts/help.js",
|
|
17
|
+
"README.md",
|
|
18
|
+
"README.cn.md",
|
|
19
|
+
"README.fr.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
10
22
|
"scripts": {
|
|
11
|
-
"help": "node scripts/help.js"
|
|
12
|
-
"build": "node scripts/build.js",
|
|
13
|
-
"test": "node test/test.js",
|
|
14
|
-
"benchmark:prepare": "node benchmark/generate-checklists.js",
|
|
15
|
-
"benchmark": "node benchmark/run-benchmark.js",
|
|
16
|
-
"benchmark:lemma": "node benchmark/run-benchmark.js lemma",
|
|
17
|
-
"benchmark:noun": "node benchmark/run-benchmark.js noun",
|
|
18
|
-
"benchmark:verb": "node benchmark/run-benchmark.js verb",
|
|
19
|
-
"benchmark:adje": "node benchmark/run-benchmark.js adje"
|
|
23
|
+
"help": "node scripts/help.js"
|
|
20
24
|
},
|
|
21
25
|
"repository": {
|
|
22
26
|
"type": "git",
|
|
@@ -48,8 +52,5 @@
|
|
|
48
52
|
"dependencies": {
|
|
49
53
|
"onnxruntime-node": "^1.24.3",
|
|
50
54
|
"onnxruntime-web": "^1.24.3"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"esbuild": "^0.25.10"
|
|
54
55
|
}
|
|
55
56
|
}
|