I have an array of words with their coordinates in the document, I want to turn them into sentences. For example this:
[
{
"bounds": [
{
"x": 10,
"y": 10
},
{
"x": 15,
"y": 10
},
{
"x": 15,
"y": 15
},
{
"x": 10,
"y": 15
}
],
"desc": "Hey"
},
{
"bounds": [
{
"x": 18,
"y": 10
},
{
"x": 24,
"y": 10
},
{
"x": 24,
"y": 15
},
{
"x": 18,
"y": 15
}
],
"desc": "Name"
},
{
"bounds": [
{
"x": 18,
"y": 20
},
{
"x": 24,
"y": 20
},
{
"x": 24,
"y": 25
},
{
"x": 18,
"y": 25
}
],
"desc": "What"
},
{
"bounds": [
{
"x": 18,
"y": 20
},
{
"x": 24,
"y": 20
},
{
"x": 24,
"y": 25
},
{
"x": 18,
"y": 25
}
],
"desc": "Sup"
}
]
Should Have turned into this:
Hey Name
What Sup
- The coordinates are not accurate just an example, also the algorithm needs to deal with words that are in the middle of sentences and other extreme cases.
What it the best way I can do it (Ideally implemented with JavaScript)?