'Join String based on coordinates Python
I am using ocr api (mindee.com), where I give handwritten notes in image format and in response I get the extracted words with confidence and coordinates. Below is the sample of response.
[
{'confidence': 0.51,
'content': 'review',
'polygon': [[0.062, 0.867], [0.176, 0.867], [0.175, 0.894], [0.06, 0.894]]
},
{'confidence': 0.56,
'content': 'with',
'polygon': [[0.209, 0.869], [0.295, 0.869], [0.295, 0.9], [0.208, 0.9]]
},
{'confidence': 0.53,
'content': 'reports',
'polygon': [[0.334, 0.877], [0.455, 0.877], [0.454, 0.918], [0.333, 0.918]]
}
]
These content/extracted words are unordered. So I cannot loop and join the string. coordinates are given, So I thought to join string based on it but not getting any idea.
Can you please explain theoretically or pseudocode how to work with it. I will implement.
Solution 1:[1]
These content/extracted words are unordered.
Why do you think that? They are clearly ordered, because they are in a list. What you need to do is just iterate through the list and take the 'content' each iteration to get the word and join the words together.
If you need the code, just ask :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mbostic |
