Using Python Spacy, how to extract entity from simple passive voice sentence? In the follow sentence, my intention is to extract both "John” from the sentence as nsubjpass and .ent_.
I am answering to my question because I will ask question on complex sentences later on so that someone can review the answer to the simple sentence and then help me to answer on the complex sentences.
code
each_sentence = "John was accused of crimes by David"
doc=nlp(each_sentence)
passive_toks=[tok for tok in doc if (tok.dep_ == "nsubjpass") ]
if passive_toks != []:
print(passive_toks)
Result:
[John]
0
AudioBubble
On
Go through the spacy 2.0 nightly build. It should have the solution you're looking for.
I am answering to my question because I will ask question on complex sentences later on so that someone can review the answer to the simple sentence and then help me to answer on the complex sentences.
code
Result:
[John]