Skip to content
Advertisement

Create a NER dictionary from a given text

I have the following variable

JavaScript

data[1]['entities'][0] = (48, 54, 'Category 1') stands for (start_offset, end_offset, entity).

I want to read each word of data[0] and tag it according to data[1] entities. I am expecting to have as final output,

JavaScript

Here, ‘O’ stands for ‘OutOfEntity’, ‘S’ stands for ‘Start’, ‘B’ stands for ‘Between’, and ‘E’ stands for ‘End’ and are unique for every given text.


I tried the following:

JavaScript

The output will be

JavaScript

From this point, I am stuck on how to deal with ‘O’ entities. Also, I want to build more efficient and readable code. I think dictionary data structure is not going to work more efficiently because I can have the same words which they’ll be as keys.

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement