ocr-document-classification
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -65,2 +65,14 @@ "use strict"; | ||
const documentDictionary = { ...defaultDocumentDictionary, ...customDocumentDictionary }; | ||
let progress = 0; | ||
const worker = await Tesseract.createWorker("nor+eng", 2, { | ||
logger: (m) => { | ||
if (m.status === "recognizing text") { | ||
progress = m.progress * 0.8; | ||
if (onProgress) onProgress(progress); | ||
} | ||
} | ||
}); | ||
await worker.setParameters({ | ||
tessedit_pageseg_mode: Tesseract.PSM.AUTO_OSD | ||
}); | ||
const reader = new FileReader(); | ||
@@ -71,11 +83,5 @@ return new Promise((resolve, reject) => { | ||
try { | ||
let progress = 0; | ||
if (onProgress) onProgress(progress); | ||
const { data: { text } } = await Tesseract.recognize(imageDataUrl, "nor+eng", { | ||
logger: (m) => { | ||
if (m.status === "recognizing text") { | ||
progress = m.progress * 0.8; | ||
if (onProgress) onProgress(progress); | ||
} | ||
} | ||
const { data: { text } } = await worker.recognize(imageDataUrl, { | ||
rotateAuto: true | ||
}); | ||
@@ -82,0 +88,0 @@ const targetWords = Array.from(new Set(Object.values(documentDictionary).flat(2))); |
{ | ||
"name": "ocr-document-classification", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Document classification using tesseract.js and string-similarity-js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -44,14 +44,12 @@ # OCR Document Classification | ||
```javascript | ||
const defaultDocumentDictionary: documentDictionary = { | ||
'BEVIS PÅ FØRSTEGANGSTJENESTE': [ | ||
['førstegangstjeneste', 'bevis', 'avtjent'], | ||
['attest', 'førstegangstjeneste'], | ||
], | ||
POLITIATTEST: [ | ||
['politiattest', 'politidistrikt'], | ||
['police certificate'], | ||
], | ||
KOMPETANSEBEVIS: [['omfatter', 'opplæring', 'utdanningsprogram']], | ||
LEGEERKLÆRING: [['legeerklæring', 'fødselsnummer']], | ||
}; | ||
const defaultDocumentDictionary: documentDictionary = { | ||
BEVISPAFORSTEGANGSTJENESTE: [ | ||
['førstegangstjeneste', 'bevis', 'avtjent'], | ||
['attest', 'førstegangstjeneste'], | ||
['fullført', 'førstegangstjeneste'], | ||
], | ||
POLITIATTEST: [['politiattest', 'politidistrikt'], ['police certificate']], | ||
KOMPETANSEBEVIS: [['omfatter', 'opplæring', 'utdanningsprogram']], | ||
LEGEERKLERING: [['legeerklæring', 'fødselsnummer']], | ||
} | ||
``` | ||
@@ -58,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12411
197
128