Reputation: 23
I have a text based dataset where I am looking to apply SpaCy's EntityRecognizer to each row for a specific column.
I can apply the general spaCy pipeline by doing something like this:
df['new_col'] = df['col'].apply(lambda x: nlp(x))
How do I just apply just the entity recongnizer and get its values?
Upvotes: 2
Views: 4698
Reputation: 51
In Spacy a doc have a attribute .ents
witch return a generator on its named entities.
So you can use :
df['new_col'] = df['col'].apply(lambda x: list(nlp(x).ents))
Upvotes: 5