Skip to content
Advertisement

How to use spacy to do Name Entity recognition on CSV file

I have tried so many things to do name entity recognition on a column in my csv file, i tried ne_chunk but i am unable to get the result of my ne_chunk in columns like so

JavaScript

Instead after using this code,

JavaScript

i got this error

JavaScript

So, i am wondering if i could do this using spaCy which is another thing that i have no clue about. Can anyone help?

Advertisement

Answer

It seems that you are checking the chunks incorrectly, that’s why you get a key error. I’m guessing a little about what you want to do, but this creates new columns for each NER type returned by NLTK. It would be a little cleaner to predefined and zero each NER type column (as this gives you NaN if NERs don’t exist).

JavaScript

If all you want is the counts the following is more performant and doesn’t have NaNs:

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