I am new to Python dictionaries, i'm trying to extract the numbers as positions inside the dictionary value denotations, sub category 'span'. The dictionary looks like this:
z = {'denotations': [{'id': ['OMIM:254500', 'MESH:D009101', 'BERN:106985601'],
'obj': 'disease',
'span': {'begin': 96, 'end': 112}},
{'id': ['OMIM:254450', 'MESH:D055728', 'BERN:106922101'],
'obj': 'disease',
'span': {'begin': 266, 'end': 268}},
{'id': ['OMIM:254450', 'MESH:D055728', 'BERN:106922101'],
'obj': 'disease',
'span': {'begin': 351, 'end': 353}}],
'logits': {'disease': [[{'end': 112,
'id': 'OMIM:254500\tMESH:D009101\tBERN:106985601',
'start': 96},
0.9999999403953552],
[{'end': 268,
'id': 'OMIM:254450\tMESH:D055728\tBERN:106922101',
'start': 266},
0.9999996423721313],
[{'end': 353,
'id': 'OMIM:254450\tMESH:D055728\tBERN:106922101',
'start': 351},
0.9999995231628418]]}
I'm only interested in the denotations category, more so the numbers held inside span.
I can only manage to extract the denotation information print(z["denotations"]) and I'm a bit stuck on how to go further into the dictionary, example:
Is it possible to extract the span information:
print(z['span'])
Output:
'span': {'begin': 96, 'end': 112}},
'span': {'begin': 266, 'end': 268}},
'span': {'begin': 351, 'end': 353}}]
or even store just the numbers as positions?
positions = ([96,112],[266, 268], [351, 353])