Extract token knowledge from text.
!python -m spacy download en_core_web_sm
TokenKnowledgeExtractor
is used to extract token based information or knowledge i.e lemma, pos, tags, noun_chunks etc. We have used spacy package to extract information.
token_ke = TokenKnowledgeExtractor(nlp)
input_text = """
Days of riots and looting in South Africa have left more than 70 people dead, hurt thousands of businesses and damaged major infrastructure in some of the worst civil unrest since the end of white minority rule in 1994.
The unrest started after former President Jacob Zuma handed himself over last week to start a 15-month prison sentence for contempt of court.
JOHANNESBURG, July 14 (Reuters) - Days of riots and looting in South Africa have left more than 70 people dead, hurt thousands of businesses and damaged major infrastructure in some of the worst civil unrest since the end of white minority rule in 1994.
What is driving the violence?
ZUMA'S JAILING
The unrest started after former President Jacob Zuma handed himself over last week to start a 15-month prison sentence for contempt of court.
Zuma supporters, who believe he is the victim of a political witch-hunt, burned tyres and blocked roads in his home province of KwaZulu-Natal.
Support for Zuma stems partly from his image as a man of the people during his nine years in power until 2018, and because some see his jailing as an attack on the nation's largest ethnic group, the Zulu.
Although many wealthy and middle-class South Africans were overjoyed when Zuma was ousted after multiple sleaze and graft allegations, he still retains loyal followings in KwaZulu-Natal and some poor, rural areas.
"""
extracted_info = token_ke.extract(input_text)
extracted_info['sents'][2]