@3sln/emon-ppocr 0.3.0-preview.1 → 0.3.0-preview.2

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.md CHANGED
@@ -33,24 +33,28 @@ third-party CDN URL defaults. URLs are fetched only when explicitly supplied.
33
33
 
34
34
  ```js
35
35
  import { Emon } from '@3sln/emon';
36
- import { ppocrPort, ppocrLexicon } from '@3sln/emon-ppocr';
36
+ import { ppocrEngine, ppocrLexicon } from '@3sln/emon-ppocr';
37
+ import { tesseractAdapter } from '@3sln/emon/tesseract';
37
38
 
38
39
  // Supplied by the application:
39
40
  // optionalWasm: compiled WebAssembly.Module, bytes, or a hosted URL
40
- // incumbent: the existing tesseractPort(...) fulfiller
41
+ // tesseract: the Tesseract adapter, tesseractAdapter(...)
41
42
  // createCore: tesseract-core-simd-lstm.wasm.js's factory
42
43
  // coreOptions: local locateFile or wasmBinary for that factory
43
44
  // englishData: pinned tessdata_fast eng.traineddata URL or bytes
44
45
  // modelSources: { 'ch_PP-OCRv5_det_mobile.onnx': URL_or_bytes, ... }
45
46
  const lexicon = ppocrLexicon({ createCore, coreOptions, traineddata: englishData });
46
- const ocr = ppocrPort({
47
- incumbent, wasm: optionalWasm, lexicon,
47
+ const emon = await Emon.load(optionalWasm);
48
+ const engines = emon.engines();
49
+ await engines.add(tesseract);
50
+ await engines.add(ppocrEngine({
51
+ wasm: optionalWasm, lexicon,
48
52
  loadOrt: () => import('onnxruntime-web/wasm'),
49
53
  wasmPaths: new URL('/vendor/ort-1.22.0/', location.href).href,
50
54
  ortWasm: new URL('/vendor/ort-1.22.0/ort-wasm-simd-threaded.wasm', location.href),
51
55
  models: modelSources,
52
- });
53
- const emon = await Emon.load(optionalWasm);
56
+ }));
57
+ const ocr = engines.port();
54
58
  const model = await emon.convert(input, {
55
59
  ocrEngine: 'ppocr', ports: { ocr }, record: true,
56
60
  producer: ocr.producer,
@@ -74,7 +78,7 @@ In Node, supply filesystem bytes for the wasm modules, models and traineddata,
74
78
  and a filesystem directory for `wasmPaths`; the adapter does not read files.
75
79
  The Node and browser qualification drivers provide executable examples.
76
80
  The dedicated dictionary instance never recognizes or learns document words.
77
- Ordinary OCR requests continue to use the incumbent fulfiller.
81
+ Ordinary OCR requests go to the Tesseract adapter: the registry routes each request to the engine it names.
78
82
 
79
83
  ORT and its three sessions load on the first PP request. The configuration is
80
84
  fixed to the hash-pinned ORT 1.22.0 ordinary SIMD wasm build, one thread,