Replace substrings with entity class names

This might be an obvious question. Sorry in advance. I am trying to use this model to perform NER. The sample output is as follows: [ { "entity_group": "ORG", "score": 0.8827372789382935, "word": "DEF", "start": 5, "end": 8 }, { "entity_group": "ORG", "score": 0.9999775886535645, "word": "ABC", "start": 65, "end": 68 }, { "entity_group": "ORG", "score": 0.9560933113098145, "word": "YZD", "start": 101, "end": 104 } ]

Based on this information, I would like to replace the identified entities with their entity class names. Is there a function to do so? I thought about using pure python to replace things iteratively but this would change the 'start’s and 'end’s for subsequent tokens. Sorry again if this is a very obvious question as I am new to the library. Any help is greatly appreciated

An example

Input: “Elvis is a good singer in the United States”
Desired Output: "[PER] is a good singer in the [LOC]