gcp_cloud_vision_lines
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "gcp_cloud_vision_lines", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "This utility breaks down a full text annotation response from the Google cloud vision API into a neatly parsed Array with each element representing a single line of text, with coords and height and width dimensions.", | ||
@@ -28,3 +28,6 @@ "main": "src/index.js", | ||
}, | ||
"homepage": "https://github.com/craig-coles/GCP_cloud_vision_lines#readme" | ||
"homepage": "https://github.com/craig-coles/GCP_cloud_vision_lines#readme", | ||
"dependencies": { | ||
"array-flatten": "^2.1.2" | ||
} | ||
} |
@@ -7,14 +7,31 @@ const arrayFlatten = require("array-flatten"); | ||
function pipe(...fns) { | ||
return x => { | ||
return fns.reduce((v, f) => { | ||
return f(v); | ||
}, x); | ||
}; | ||
} | ||
exports = module.exports = { cloudVisionLines }; | ||
function cloudVisionLines(fullTextAnnotation) { | ||
const wordsObjects = buildWordObjectsFromSymbols( | ||
getWordsFromParagraphs( | ||
getParagraphsFromTextBlocks(getBlocksFromTextObj(fullTextAnnotation)) | ||
) | ||
// const wordsObjects = buildWordObjectsFromSymbols( | ||
// getWordsFromParagraphs( | ||
// getParagraphsFromTextBlocks(getBlocksFromTextObj(fullTextAnnotation)) | ||
// ) | ||
// ); | ||
// const lines = buildLinesFromWordObjects(wordsObjects); | ||
const lineObjects = pipe( | ||
getBlocksFromTextObj, | ||
getParagraphsFromTextBlocks, | ||
getWordsFromParagraphs, | ||
buildWordObjectsFromSymbols, | ||
buildLinesFromWordObjects | ||
); | ||
const lines = buildLinesFromWordObjects(wordsObjects); | ||
return lines; | ||
//return lines; | ||
return lineObjects(fullTextAnnotation); | ||
} | ||
@@ -21,0 +38,0 @@ |
6919
116
1
+ Addedarray-flatten@^2.1.2
+ Addedarray-flatten@2.1.2(transitive)