Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Balearica committed Aug 24, 2024
1 parent 63dd4da commit b81b9ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions js/modifyOCR.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,11 @@ export function combineOCRPage(pageA, pageB, pageMetricsObj, replaceFontSize = f
// (possibly on the other side of the page) just because vertical overlap exists.
if (match && matchXOverlap === 0 && matchXDist > 2 * yDistMin && pageB.dims.width * 0.05 < matchXDist) match = undefined;

const wordsNew = lineNew.words;

if (match) {
const { words } = match;

for (let j = 0; j < wordsNew.length; j++) {
const wordNew = wordsNew[j];
for (let j = 0; j < lineNew.words.length; j++) {
const wordNew = lineNew.words[j];
wordNew.line = match;
const wordBoxNew = wordNew.bbox;

Expand Down Expand Up @@ -167,8 +165,8 @@ export function combineOCRPage(pageA, pageB, pageMetricsObj, replaceFontSize = f
// Recalculate bounding box for line
ocr.updateLineBbox(match);
} else {
for (let j = 0; j < wordsNew.length; j++) {
const wordNew = wordsNew[j];
for (let j = 0; j < lineNew.words.length; j++) {
const wordNew = lineNew.words[j];

// Replace id (which is likely duplicative) with unique id
if (editWordIds) wordNew.id += getRandomAlphanum(3);
Expand Down
4 changes: 2 additions & 2 deletions js/recognizeConvert.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const compareOCR = async (ocrA, ocrB, options) => {
const ocrArr = [];
/** @type {Array<?EvalMetrics>} */
const metricsArr = [];
/** @type {Array<?CompDebugBrowser | CompDebugNode>} */
/** @type {Array<Array<CompDebugBrowser | CompDebugNode>>} */
const debugImageArr = [];

// Render binarized versions of images
Expand All @@ -93,7 +93,7 @@ export const compareOCR = async (ocrA, ocrB, options) => {

metricsArr[i] = res.metrics;

debugImageArr[i] = res.debug;
if (res.debugImg) debugImageArr[i] = res.debugImg;
};

// This function is run in the main thread in Node.js, with no mechanism for queuing jobs.
Expand Down

0 comments on commit b81b9ec

Please sign in to comment.