0

I am using online library and able to fetch words from an image with their locations.

Now I want to form sentences exactly like which are in image.

Any idea how can I do that?

Earlier i used the distance between two words and if there are pretty close then it means it is a part of a sentence but this approach is not working fine Please help

This is the json I am receiving I have...

"WordText": "Word 1", "Left": 106, "Top": 91, "Height": 9, "Width": 11 }, { "WordText": "Word 2", "Left": 121, "Top": 90, "Height": 13, "Width": 51 } . . . More Words

himanshu sangal
  • 41
  • 1
  • 11

1 Answers1

0

I don't if I am understanding your problem correctly, but I'm assuming each dictionary in your json is giving you the coordinates for a word.

My approach would be to first find the difference in pixels for the space between any 2 words, and you use this value to detect the sequence of words.

For example: img1 = {'coordinates': 'information'} img2 = {'coordinates': 'information'} space_value = 10 # for example

if img1['Height'] == img2['Height'] and (img1['Left'] + img1['Width'] + space_value) == img2['Left']: next_word = True