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
ID STORY PERSON NE NP NN VB GE
1 Washington, a police officer James... 1 0 0 0 0 1
Instead after using this code,
news=pd.read_csv("news.csv")
news['tokenize'] = news.apply(lambda row: nltk.word_tokenize(row['STORY']), axis=1)
news['pos_tags'] = news.apply(lambda row: nltk.pos_tag(row['tokenize']), axis=1)
news['entityrecog']=news.apply(lambda row: nltk.ne_chunk(row['pos_tags']), axis=1)
tag_count_df = pd.DataFrame(news['entityrecognition'].map(lambda x: Counter(tag[1] for tag in x)).to_list())
news=pd.concat([news, tag_count_df], axis=1).fillna(0).drop(['entityrecognition'], axis=1)
news.to_csv("news.csv")
i got this error
IndexError : list index out of range
So, i am wondering if i could do this using spaCy which is another thing that i have no clue about. Can anyone help?