I am currently working on creating a JSON file that stores matched words from a text like this
servicepoint 200135644 watchid 7038842
Each servicepoint and watchid should be added to the Object table only once using the following code:
function readfile() {
Tesseract.recognize('form.png', 'ara', {
logger: m => console.log(m)
}).then(({ data: { text } }) => {
console.log(text); /* this line here */
var obj = {
table: []
};
const info = ['servicepoint', 'watchid'];
for (k = 0; k < info.length; k++) {
var result = text.match(new RegExp(info[k] + '\\s+(\\w+)'))[1];
obj.table.push({
servicepoint: /* Need to add the number after servicepoint here */ ,
watchid: /* Also need to include the number after watchid in the Object table*/
});
}
var json = JSON.stringify(obj); /* Convert the object table to a JSON file*/
var fs = require('fs'); /* Then write a JSON file containing the data*/
fs.writeFile('myjsonfile.json', json, 'utf8', callback);
})
};