fr-spell 1.0.1
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/LICENSE +21 -0
- package/README.cn.md +165 -0
- package/README.fr.md +165 -0
- package/README.md +165 -0
- package/benchmark/checklist_adje_100.json +702 -0
- package/benchmark/checklist_lemma_verb_100.json +402 -0
- package/benchmark/checklist_noun_100.json +702 -0
- package/benchmark/checklist_verb_100.json +702 -0
- package/benchmark/generate-checklists.js +192 -0
- package/benchmark/run-benchmark.js +123 -0
- package/models/small/derive_form_model.int8.onnx +0 -0
- package/models/small/derive_form_vocab.json +74 -0
- package/models/small/lemma_type_labels.json +47 -0
- package/models/small/lemma_type_model.int8.onnx +0 -0
- package/models/small/lemma_type_vocab.json +244 -0
- package/package.json +50 -0
- package/scripts/help.js +54 -0
- package/src/frspell.js +9 -0
- package/src/module/Predictor.js +416 -0
- package/test/test.js +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Davy Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.cn.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# FR-SPELL
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [中文](README.cn.md) | [Français](README.fr.md)
|
|
4
|
+
|
|
5
|
+
FR-SPELL 是一个用于法语词形还原与派生形态生成的 npm 包。
|
|
6
|
+
支持能力如下:
|
|
7
|
+
|
|
8
|
+
- 将动词变位形式预测为词元(lemma)
|
|
9
|
+
- 名词词形生成
|
|
10
|
+
- 形容词词形生成
|
|
11
|
+
- 动词词形生成
|
|
12
|
+
|
|
13
|
+
该包基于 ONNX Runtime 与 INT8 量化模型,兼顾高速度与小体积。
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install fr-spell
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 集成到你的项目
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { FrSpell } from 'fr-spell';
|
|
25
|
+
|
|
26
|
+
const predictor = await FrSpell();
|
|
27
|
+
|
|
28
|
+
const lemma = await predictor.lemma('mangeons');
|
|
29
|
+
const noun = await predictor.nounDerive('chat', 'THD_PLF');
|
|
30
|
+
const adje = await predictor.adjeDerive('beau', 'THD_F');
|
|
31
|
+
const verb = await predictor.verbDerive('manger', 'FST_PL', 'INDI', 'PRES');
|
|
32
|
+
|
|
33
|
+
console.log(lemma);
|
|
34
|
+
console.log(noun);
|
|
35
|
+
console.log(adje);
|
|
36
|
+
console.log(verb);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
示例运行输出:
|
|
40
|
+
|
|
41
|
+
```txt
|
|
42
|
+
{ input: 'mangeons', lemma: 'manger', wordType: 'VERB', confidence: 0.9965604285, timeMs: 3.89 }
|
|
43
|
+
{ lemma: 'chat', wordType: 'NOUN', person: 'THD_PLF', mode: 'ALL', tense: 'ALL', output: 'chattes', confidence: 0.9997230679, timeMs: 5.06 }
|
|
44
|
+
{ lemma: 'beau', wordType: 'ADJE', person: 'THD_F', mode: 'ALL', tense: 'ALL', output: 'belle', confidence: 0.9999751771, timeMs: 3.08 }
|
|
45
|
+
{ lemma: 'manger', wordType: 'VERB', person: 'FST_PL', mode: 'INDI', tense: 'PRES', output: 'mangeons', confidence: 0.9999864523, timeMs: 4.79 }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 预测参数说明
|
|
49
|
+
|
|
50
|
+
词元预测(lemma):
|
|
51
|
+
|
|
52
|
+
- API:`predictor.lemma(input)`
|
|
53
|
+
- `input`:字符串,输入变位/屈折后的词形,例如 `mangeons`
|
|
54
|
+
|
|
55
|
+
派生预测(derive):
|
|
56
|
+
|
|
57
|
+
- 名词 API:`predictor.nounDerive(lemma, person)`
|
|
58
|
+
- 形容词 API:`predictor.adjeDerive(lemma, person)`
|
|
59
|
+
- 动词 API:`predictor.verbDerive(lemma, person, mode, tense)`
|
|
60
|
+
- 通用 API:`predictor.derive(lemma, wordType, person, mode, tense)`
|
|
61
|
+
|
|
62
|
+
可用 `wordType`:
|
|
63
|
+
|
|
64
|
+
- `NOUN`(名词)
|
|
65
|
+
- `ADJE`(形容词)
|
|
66
|
+
- `VERB`(动词)
|
|
67
|
+
|
|
68
|
+
可用 `person`:
|
|
69
|
+
|
|
70
|
+
- `FST`(第一人称单数)
|
|
71
|
+
- `SND`(第二人称单数)
|
|
72
|
+
- `THD_M`(第三人称阳性单数)
|
|
73
|
+
- `THD_F`(第三人称阴性单数)
|
|
74
|
+
- `FST_PL`(第一人称复数)
|
|
75
|
+
- `SND_PL`(第二人称复数)
|
|
76
|
+
- `THD_PLM`(第三人称阳性复数)
|
|
77
|
+
- `THD_PLF`(第三人称阴性复数)
|
|
78
|
+
|
|
79
|
+
可用 `mode`:
|
|
80
|
+
|
|
81
|
+
- `INDI`(陈述式)
|
|
82
|
+
- `SUBJ`(虚拟式)
|
|
83
|
+
- `COND`(条件式)
|
|
84
|
+
- `PART`(分词式)
|
|
85
|
+
- `IMPE`(命令式)
|
|
86
|
+
- `INFI`(不定式)
|
|
87
|
+
|
|
88
|
+
当前实现支持的 `tense` 仅有:
|
|
89
|
+
|
|
90
|
+
- `PRES`(现在时)
|
|
91
|
+
- `IMPA`(未完成过去时)
|
|
92
|
+
- `FUTU`(将来时)
|
|
93
|
+
- `PASS`(过去时)
|
|
94
|
+
|
|
95
|
+
说明:
|
|
96
|
+
|
|
97
|
+
- 参考定义文件中还有更多时态名称,但本包实现目前只支持 `PRES`、`IMPA`、`FUTU`、`PASS`。
|
|
98
|
+
- 对于名词/形容词派生,用户输入时不需要 `mode` 与 `tense`。
|
|
99
|
+
|
|
100
|
+
## 运行测试
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npm test
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
该命令会执行 test/test.js,并输出示例预测结果。
|
|
107
|
+
|
|
108
|
+
## 查看帮助
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm run help
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
该命令会输出参数速查说明,覆盖 `lemma`、`nounDerive`、`adjeDerive`、`verbDerive`、`derive` 及 person/mode/tense 可用值。
|
|
115
|
+
|
|
116
|
+
## 运行基准测试
|
|
117
|
+
|
|
118
|
+
1) 先生成检查清单 JSON(每类 100 条):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm run benchmark:prepare
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2) 运行全部基准测试:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run benchmark
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
3) 可选:按单项运行:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run benchmark:lemma
|
|
134
|
+
npm run benchmark:noun
|
|
135
|
+
npm run benchmark:verb
|
|
136
|
+
npm run benchmark:adje
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 基准结果(最近一次本地运行)
|
|
140
|
+
|
|
141
|
+
基准命令:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run benchmark
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
结果:
|
|
148
|
+
|
|
149
|
+
- 由变位预测词元:99/100,准确率 99.00%,平均 16.46 ms
|
|
150
|
+
- 名词派生:99/100,准确率 99.00%,平均 17.33 ms
|
|
151
|
+
- 动词派生:100/100,准确率 100.00%,平均 17.12 ms
|
|
152
|
+
- 形容词派生:100/100,准确率 100.00%,平均 17.34 ms
|
|
153
|
+
|
|
154
|
+
## 模型体积
|
|
155
|
+
|
|
156
|
+
- 词元 ONNX 模型:models/small/lemma_type_model.int8.onnx = 0.96 MB
|
|
157
|
+
- 派生 ONNX 模型:models/small/derive_form_model.int8.onnx = 0.91 MB
|
|
158
|
+
- ONNX 总体积:约 1.87 MB
|
|
159
|
+
|
|
160
|
+
## 为什么它非常适合 Web 前端产品
|
|
161
|
+
|
|
162
|
+
- 法语关键形态任务具有高准确率
|
|
163
|
+
- 单次请求延迟低(本地基准平均约 16 到 17 ms)
|
|
164
|
+
- ONNX 体积小(总计约 1.87 MB)
|
|
165
|
+
- 非常适合为 Web 前端功能提供后端推理能力,例如实时写作辅助、语法提示与词元感知检索
|
package/README.fr.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# FR-SPELL
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [中文](README.cn.md) | [Français](README.fr.md)
|
|
4
|
+
|
|
5
|
+
FR-SPELL est un package npm pour la prédiction de lemme en français et la génération de formes dérivées.
|
|
6
|
+
Fonctionnalités prises en charge :
|
|
7
|
+
|
|
8
|
+
- prédiction du lemme à partir d'une forme conjuguée
|
|
9
|
+
- génération de formes nominales
|
|
10
|
+
- génération de formes adjectivales
|
|
11
|
+
- génération de formes verbales
|
|
12
|
+
|
|
13
|
+
Le package s'appuie sur ONNX Runtime et des modèles INT8 quantifiés pour offrir une grande vitesse avec une empreinte mémoire réduite.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install fr-spell
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Intégration dans votre projet
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { FrSpell } from 'fr-spell';
|
|
25
|
+
|
|
26
|
+
const predictor = await FrSpell();
|
|
27
|
+
|
|
28
|
+
const lemma = await predictor.lemma('mangeons');
|
|
29
|
+
const noun = await predictor.nounDerive('chat', 'THD_PLF');
|
|
30
|
+
const adje = await predictor.adjeDerive('beau', 'THD_F');
|
|
31
|
+
const verb = await predictor.verbDerive('manger', 'FST_PL', 'INDI', 'PRES');
|
|
32
|
+
|
|
33
|
+
console.log(lemma);
|
|
34
|
+
console.log(noun);
|
|
35
|
+
console.log(adje);
|
|
36
|
+
console.log(verb);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Exemple de sortie a l'execution :
|
|
40
|
+
|
|
41
|
+
```txt
|
|
42
|
+
{ input: 'mangeons', lemma: 'manger', wordType: 'VERB', confidence: 0.9965604285, timeMs: 3.89 }
|
|
43
|
+
{ lemma: 'chat', wordType: 'NOUN', person: 'THD_PLF', mode: 'ALL', tense: 'ALL', output: 'chattes', confidence: 0.9997230679, timeMs: 5.06 }
|
|
44
|
+
{ lemma: 'beau', wordType: 'ADJE', person: 'THD_F', mode: 'ALL', tense: 'ALL', output: 'belle', confidence: 0.9999751771, timeMs: 3.08 }
|
|
45
|
+
{ lemma: 'manger', wordType: 'VERB', person: 'FST_PL', mode: 'INDI', tense: 'PRES', output: 'mangeons', confidence: 0.9999864523, timeMs: 4.79 }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Parametres de prediction
|
|
49
|
+
|
|
50
|
+
Prediction de lemme :
|
|
51
|
+
|
|
52
|
+
- API : `predictor.lemma(input)`
|
|
53
|
+
- `input` : chaine de caracteres, forme flechie/conjuguee, par exemple `mangeons`
|
|
54
|
+
|
|
55
|
+
Prediction de derive :
|
|
56
|
+
|
|
57
|
+
- API nom : `predictor.nounDerive(lemma, person)`
|
|
58
|
+
- API adjectif : `predictor.adjeDerive(lemma, person)`
|
|
59
|
+
- API verbe : `predictor.verbDerive(lemma, person, mode, tense)`
|
|
60
|
+
- API generique : `predictor.derive(lemma, wordType, person, mode, tense)`
|
|
61
|
+
|
|
62
|
+
Valeurs `wordType` autorisees :
|
|
63
|
+
|
|
64
|
+
- `NOUN` (nom)
|
|
65
|
+
- `ADJE` (adjectif)
|
|
66
|
+
- `VERB` (verbe)
|
|
67
|
+
|
|
68
|
+
Valeurs `person` autorisees :
|
|
69
|
+
|
|
70
|
+
- `FST` (1re personne du singulier)
|
|
71
|
+
- `SND` (2e personne du singulier)
|
|
72
|
+
- `THD_M` (3e personne masculine du singulier)
|
|
73
|
+
- `THD_F` (3e personne feminine du singulier)
|
|
74
|
+
- `FST_PL` (1re personne du pluriel)
|
|
75
|
+
- `SND_PL` (2e personne du pluriel)
|
|
76
|
+
- `THD_PLM` (3e personne masculine du pluriel)
|
|
77
|
+
- `THD_PLF` (3e personne feminine du pluriel)
|
|
78
|
+
|
|
79
|
+
Valeurs `mode` autorisees :
|
|
80
|
+
|
|
81
|
+
- `INDI` (indicatif)
|
|
82
|
+
- `SUBJ` (subjonctif)
|
|
83
|
+
- `COND` (conditionnel)
|
|
84
|
+
- `PART` (participe)
|
|
85
|
+
- `IMPE` (imperatif)
|
|
86
|
+
- `INFI` (infinitif)
|
|
87
|
+
|
|
88
|
+
Valeurs `tense` prises en charge dans l'implementation actuelle :
|
|
89
|
+
|
|
90
|
+
- `PRES` (present)
|
|
91
|
+
- `IMPA` (imparfait)
|
|
92
|
+
- `FUTU` (futur)
|
|
93
|
+
- `PASS` (passe)
|
|
94
|
+
|
|
95
|
+
Note :
|
|
96
|
+
|
|
97
|
+
- 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
|
+
- Pour les appels nom/adjectif, `mode` et `tense` ne sont pas requis dans l'entree utilisateur.
|
|
99
|
+
|
|
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
|
+
## Afficher l'aide
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm run help
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
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
|
+
|
|
116
|
+
## Exécuter les benchmarks
|
|
117
|
+
|
|
118
|
+
1) Générer les fichiers JSON de checklist (100 éléments chacun) :
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm run benchmark:prepare
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2) Exécuter toutes les suites de benchmark :
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run benchmark
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
3) Optionnel : exécuter une suite spécifique :
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run benchmark:lemma
|
|
134
|
+
npm run benchmark:noun
|
|
135
|
+
npm run benchmark:verb
|
|
136
|
+
npm run benchmark:adje
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Résultats de benchmark (dernier run local)
|
|
140
|
+
|
|
141
|
+
Commande de benchmark :
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run benchmark
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Résultats :
|
|
148
|
+
|
|
149
|
+
- lemme depuis une conjugaison : 99/100, précision 99.00 %, moyenne 16.46 ms
|
|
150
|
+
- dérivation nominale : 99/100, précision 99.00 %, moyenne 17.33 ms
|
|
151
|
+
- dérivation verbale : 100/100, précision 100.00 %, moyenne 17.12 ms
|
|
152
|
+
- dérivation adjectivale : 100/100, précision 100.00 %, moyenne 17.34 ms
|
|
153
|
+
|
|
154
|
+
## Taille des modèles
|
|
155
|
+
|
|
156
|
+
- modèle ONNX lemme : models/small/lemma_type_model.int8.onnx = 0.96 MB
|
|
157
|
+
- modèle ONNX dérivation : models/small/derive_form_model.int8.onnx = 0.91 MB
|
|
158
|
+
- taille totale ONNX : environ 1.87 MB
|
|
159
|
+
|
|
160
|
+
## Pourquoi c'est idéal pour des produits web frontend
|
|
161
|
+
|
|
162
|
+
- excellente précision sur les tâches clés de morphologie française
|
|
163
|
+
- faible latence par requête (environ 16 à 17 ms en moyenne sur benchmark local)
|
|
164
|
+
- empreinte ONNX très compacte (environ 1.87 MB au total)
|
|
165
|
+
- parfait pour alimenter des fonctionnalités frontend via une inférence backend : assistance à l'écriture en temps réel, suggestions grammaticales et recherche basée sur le lemme
|
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# FR-SPELL
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [中文](README.cn.md) | [Français](README.fr.md)
|
|
4
|
+
|
|
5
|
+
FR-SPELL is an npm package for French lemma prediction and derivative form generation.
|
|
6
|
+
It supports:
|
|
7
|
+
|
|
8
|
+
- conjugation to lemma prediction
|
|
9
|
+
- noun form generation
|
|
10
|
+
- adjective form generation
|
|
11
|
+
- verb form generation
|
|
12
|
+
|
|
13
|
+
The package runs with ONNX Runtime and quantized INT8 models for high speed and small model footprint.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install fr-spell
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Integrate Into Your Project
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { FrSpell } from 'fr-spell';
|
|
25
|
+
|
|
26
|
+
const predictor = await FrSpell();
|
|
27
|
+
|
|
28
|
+
const lemma = await predictor.lemma('mangeons');
|
|
29
|
+
const noun = await predictor.nounDerive('chat', 'THD_PLF');
|
|
30
|
+
const adje = await predictor.adjeDerive('beau', 'THD_F');
|
|
31
|
+
const verb = await predictor.verbDerive('manger', 'FST_PL', 'INDI', 'PRES');
|
|
32
|
+
|
|
33
|
+
console.log(lemma);
|
|
34
|
+
console.log(noun);
|
|
35
|
+
console.log(adje);
|
|
36
|
+
console.log(verb);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Sample runtime output:
|
|
40
|
+
|
|
41
|
+
```txt
|
|
42
|
+
{ input: 'mangeons', lemma: 'manger', wordType: 'VERB', confidence: 0.9965604285, timeMs: 3.89 }
|
|
43
|
+
{ lemma: 'chat', wordType: 'NOUN', person: 'THD_PLF', mode: 'ALL', tense: 'ALL', output: 'chattes', confidence: 0.9997230679, timeMs: 5.06 }
|
|
44
|
+
{ lemma: 'beau', wordType: 'ADJE', person: 'THD_F', mode: 'ALL', tense: 'ALL', output: 'belle', confidence: 0.9999751771, timeMs: 3.08 }
|
|
45
|
+
{ lemma: 'manger', wordType: 'VERB', person: 'FST_PL', mode: 'INDI', tense: 'PRES', output: 'mangeons', confidence: 0.9999864523, timeMs: 4.79 }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Prediction Parameters
|
|
49
|
+
|
|
50
|
+
Lemma prediction:
|
|
51
|
+
|
|
52
|
+
- API: `predictor.lemma(input)`
|
|
53
|
+
- `input`: string, inflected/conjugated word form, for example `mangeons`
|
|
54
|
+
|
|
55
|
+
Derive prediction:
|
|
56
|
+
|
|
57
|
+
- Noun API: `predictor.nounDerive(lemma, person)`
|
|
58
|
+
- Adjective API: `predictor.adjeDerive(lemma, person)`
|
|
59
|
+
- Verb API: `predictor.verbDerive(lemma, person, mode, tense)`
|
|
60
|
+
- Generic API: `predictor.derive(lemma, wordType, person, mode, tense)`
|
|
61
|
+
|
|
62
|
+
Allowed `wordType` values:
|
|
63
|
+
|
|
64
|
+
- `NOUN` (noun)
|
|
65
|
+
- `ADJE` (adjective)
|
|
66
|
+
- `VERB` (verb)
|
|
67
|
+
|
|
68
|
+
Allowed `person` values:
|
|
69
|
+
|
|
70
|
+
- `FST` (1st person singular)
|
|
71
|
+
- `SND` (2nd person singular)
|
|
72
|
+
- `THD_M` (3rd person masculine singular)
|
|
73
|
+
- `THD_F` (3rd person feminine singular)
|
|
74
|
+
- `FST_PL` (1st person plural)
|
|
75
|
+
- `SND_PL` (2nd person plural)
|
|
76
|
+
- `THD_PLM` (3rd person masculine plural)
|
|
77
|
+
- `THD_PLF` (3rd person feminine plural)
|
|
78
|
+
|
|
79
|
+
Allowed `mode` values:
|
|
80
|
+
|
|
81
|
+
- `INDI` (indicative)
|
|
82
|
+
- `SUBJ` (subjunctive)
|
|
83
|
+
- `COND` (conditional)
|
|
84
|
+
- `PART` (participle)
|
|
85
|
+
- `IMPE` (imperative)
|
|
86
|
+
- `INFI` (infinitive)
|
|
87
|
+
|
|
88
|
+
Allowed `tense` values in current implementation:
|
|
89
|
+
|
|
90
|
+
- `PRES` (present)
|
|
91
|
+
- `IMPA` (imperfect)
|
|
92
|
+
- `FUTU` (future)
|
|
93
|
+
- `PASS` (past)
|
|
94
|
+
|
|
95
|
+
Note:
|
|
96
|
+
|
|
97
|
+
- The original grammar definition file includes more tense names, but this package implementation currently supports only `PRES`, `IMPA`, `FUTU`, `PASS`.
|
|
98
|
+
- For noun/adjective derive calls, `mode` and `tense` are not required in user input.
|
|
99
|
+
|
|
100
|
+
## Run Test
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npm test
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This executes test/test.js and prints sample prediction outputs.
|
|
107
|
+
|
|
108
|
+
## Run Help
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm run help
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This prints a quick parameter reference for `lemma`, `nounDerive`, `adjeDerive`, `verbDerive`, and `derive`, including allowed person/mode/tense values.
|
|
115
|
+
|
|
116
|
+
## Run Benchmark
|
|
117
|
+
|
|
118
|
+
1) Prepare checklist JSON files (100 items each):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm run benchmark:prepare
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2) Run all benchmark suites:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run benchmark
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
3) Optional single-suite runs:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run benchmark:lemma
|
|
134
|
+
npm run benchmark:noun
|
|
135
|
+
npm run benchmark:verb
|
|
136
|
+
npm run benchmark:adje
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Benchmark Result (Latest Local Run)
|
|
140
|
+
|
|
141
|
+
Benchmark command:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run benchmark
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Results:
|
|
148
|
+
|
|
149
|
+
- lemma from conjugation: 99/100, accuracy 99.00%, average 16.46 ms
|
|
150
|
+
- noun derive: 99/100, accuracy 99.00%, average 17.33 ms
|
|
151
|
+
- verb derive: 100/100, accuracy 100.00%, average 17.12 ms
|
|
152
|
+
- adjective derive: 100/100, accuracy 100.00%, average 17.34 ms
|
|
153
|
+
|
|
154
|
+
## Model Size
|
|
155
|
+
|
|
156
|
+
- lemma ONNX model: models/small/lemma_type_model.int8.onnx = 0.96 MB
|
|
157
|
+
- derive ONNX model: models/small/derive_form_model.int8.onnx = 0.91 MB
|
|
158
|
+
- total ONNX model size: about 1.87 MB
|
|
159
|
+
|
|
160
|
+
## Why It Is Great For Web Frontend Products
|
|
161
|
+
|
|
162
|
+
- high accuracy for key French morphology tasks
|
|
163
|
+
- low per-request latency (about 16 to 17 ms average in local benchmark)
|
|
164
|
+
- very small ONNX footprint (about 1.87 MB total)
|
|
165
|
+
- ideal for backend inference powering web frontend features such as live writing assistance, grammar hints, and lemma-aware search
|