I have this JSON
{
"journal.pbio.0050304.xml": {
"sentence": [
[
{"entity_group": "literal", "score": 0.9961686, "word": "The anterioru2013posterior (Au2013P) axis ", "start": 0, "end": 299}
],
[
{"entity_group": "literal", "score": 0.9932352, "word": "RA, Fgfs, and Wnts are all produced at the posterior of the embryo, and might therefore be expected to form posterior-", "start": 0, "end": 118},
{"entity_group": "metaphoric", "score": 0.874372, "word": "to", "start": 118, "end": 120},
{"entity_group": "literal", "score": 0.99049604, "word": "-anterior gradients (for Fgf8", "start": 120, "end": 149},
{"entity_group": "metaphoric", "score": 0.9993481, "word": "this", "start": 150, "end": 154}
]
]
},
"journal.pbio.0050093.xml": {
"sentence": [
[
{"entity_group": "literal", "score": 0.9961686, "word": "The anterioru2013posterior (Au2013P) axis ", "start": 0, "end": 299}
]
]
}
}
And I would like to take only entity groups, start and end and convert them into tuples, like this:
[(0, 299, 'literal'),(186, 194, 'literal'), ('metaphoric', 196, 199)]
, and so on. How can I do it?
2
Answers
Something like this?
Result:
You just need to iterate first over the dictionary values then the lists and sub-lists as follows:
Output: