Skip to content
Advertisement

Identify subject in sentences using spacy in advanced cases

I’m trying to identify the subject in a sentence. I tried to use some of the code here:

JavaScript

This returns the results:

  • the det
  • python nsubjpass
  • can aux
  • be auxpass
  • used ROOT
  • to aux
  • find xcomp
  • objects dobj

I would think in this case the python would be the subject, in most cases that would be the _dep would be nsubj, but its nsubjpass. So if nsubj is not present I can check for nsubjpass but are there any other _dep it could be?

Is there a more robust way to determine subject?

Advertisement

Answer

Your sentence is a passive voice example. nsubjpass is the subject when using passive voice

You can find the list of dep_ by calling

JavaScript

I can see there are 2 more subject types:

JavaScript

One possible way to determine the subject:

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