Extract consecutive entities into Dataframe

Dear Spacy contributors and community.

I am quite new to spacy and python, and even being newbie, I am really liking how spacy works and it is awesome to see spacy in good hands. Believe me or not, without spacy I would be in a very challenging environment. I appreciate your hard work. Sincerely, thank you very much all

Back to my question:

I am able to build custom entitles like this, I need to extract entity labels ECHO followed by it is consecutive Result


I am quite not figuring out how can I reach the below df

Expected result should look like that:


Much appreciate prompt response thank you :slight_smile:

Hi and thanks! This forum is dedicated to questions around our annotation tool Prodigy, so it's not really a place for general usage questions around spaCy. For this we recommend Stack Overflow: https://stackoverflow.com/questions/tagged/spacy

To solve your problem, check out the docs on accessing entity annotations via the doc.ents: https://spacy.io/usage/linguistic-features#named-entities-101 This gives you all named entities in order as a list. From there on, the task becomes just a regular Python programming question and not really specific to spaCy: you loop over the entities, collect all entities of type ECHO, up to the first RESULT, then all entities of type RESULT up to the next ECHO, and so on.

Thank you Ines, I do apologize for off topic question