fr-spell 1.0.3 → 1.0.4

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.
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import fs from 'node:fs/promises';
8
+ import fsSync from 'node:fs';
8
9
  import path from 'node:path';
9
10
  import { fileURLToPath } from 'node:url';
10
11
  import * as ort from 'onnxruntime-node';
@@ -80,7 +81,14 @@ function normalizeEnumToken(value, fallback) {
80
81
  }
81
82
 
82
83
  const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
83
- const PACKAGE_ROOT = path.resolve(MODULE_DIR, '..', '..');
84
+ const PACKAGE_ROOT_CANDIDATES = [
85
+ path.resolve(MODULE_DIR, '..'),
86
+ path.resolve(MODULE_DIR, '..', '..'),
87
+ ];
88
+ const PACKAGE_ROOT =
89
+ PACKAGE_ROOT_CANDIDATES.find((candidate) =>
90
+ fsSync.existsSync(path.join(candidate, 'models', 'community', 'lemma_type_vocab.json')),
91
+ ) || PACKAGE_ROOT_CANDIDATES[0];
84
92
 
85
93
  const DEFAULT_MODEL_PATHS = {
86
94
  lemmaModelPath: path.resolve(PACKAGE_ROOT, 'models/community/lemma_type_model.int8.onnx'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fr-spell",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
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
6
  "main": "./index.js",