How to Extract Subject, Verb and Object by NLP

Top'p Kullawattana
18 min readMay 5, 2020

Arguments: subject-related (Subject Dependency)

  1. nsubj (nominal subject) : Nominal subject is a non-clausal constituent in the subject position of an active verb. A nonclausal constituent with the SBJ function tag is considered a NSUBJ.

Example Sentence in Choi & Palmer (2012) :

[She and I] came home together

  • NSUBJ (came, She)

[Earlier] was better

  • NSUBJ(was, Earlier)

Example Sentence in Spacy :

Earlier was better.

  • ADVMOD(was, Earlier)

This house is pretty.

  • NSUBJ (is, house)

She grew older.

  • NSUBJ (grew, she)

2. nsubjpass (passive nominal subject) : A nominal passive subject is a non-clausal constituent in the subject position of a passive verb. A non-clausal constituent with the SBJ function tag that depends on a passive verb is considered a NSUBJPASS.

Example Sentence in Choi & Palmer (2012) :

I [am] drawn to her.

  • NSUBJPASS (drawn, I)

We will [get] married.

  • NSUBJPASS (married, We)

She will [become] nationalized.

  • NSUBJPASS (nationalized, She)

The car was bought [by John].

  • NSUBJPASS (bought, car)

3. csubj (clausal subject) : A clausal subject is a clause in the subject position of an active verb. A clause with a SBJ function tag is considered a CSUBJ.

Example Sentence in Choi & Palmer (2012) :

[Whether she liked me] doesn’t matter

  • CSUBJ (matter, liked)

Example Sentence in Spacy :

What you have to say is not important.

  • CSUBJ (is, have)

4. csubjpass (clausal passive subject) : A clausal passive subject is a clause in the subject position of a passive verb. A clause with the SBJ function tag that depends on a passive verb is considered a CSUBJPASS.

Example Sentence in Choi & Palmer (2012) :

[Whoever misbehaves] will be dismissed

  • CSUBJPASS (dismissed, misbehaves)

Example Sentence in Spacy :

Whether you come will be recorded.

  • CSUBJPASS (recorded, come)

5. agent (agent) : An agent is the complement of a passive verb that is the surface subject of its active form. In our approach, the preposition by is included as a part of AGENT .

Example Sentence in Choi & Palmer (2012) :

The car was bought [by John]

  • AGENT (bought, by)
  • POBJ (by, John)

Example Sentence in Spacy :

decisions made by those

  • AGENT (made, by)
  • POBJ (by, those)

Example Sentence in Spacy :

this was not carried out by immigrants

  • AGENT (carried, by)
  • POBJ (by, immigrants)

6. expl (expletive) : An expletive is an existential there in the subject position.

Example Sentence in Choi & Palmer (2012) :

There was an explosion

  • EXPL (was, There)

Example Sentence in Spacy :

There seems to be a mistake.

  • EXPL (seems, There)

Arguments: object-related (Object Dependency)

  1. dobj (direct object) : A direct object is a noun phrase that is the accusative object of a (di)transitive verb.

Example Sentence in Choi & Palmer (2012) :

She bought me [these books]

  • DOBJ (bought, books)

Example Sentence in Spacy :

Minorities face inequalities.

  • DOBJ (face, inequalities)

She gave her a book.

  • DOBJ (gave, book)

2. dative (indirect object) : An indirect object is a noun phrase that is the dative object of a ditransitive verb.

Example Sentence in Choi & Palmer (2012) :

She bought [me] these books

  • IOBJ (bought, me)

She bought these books [for me]

  • PREP (bought, for)

Example Sentence in Spacy :

She bought me these books.

  • DATIVE (bought, me)

She bought me these books for me.

  • DATIVE (bought, for)
  • POBJ (for, me)

She gave her a book.

  • DATIVE (gave, her)

She gave a book to her.

  • DATIVE (gave, to)
  • POBJ (to, her)

3. attr (attribute) : An attribute is a noun phrase that is a non-VP predicate usually following a copula verb.

Example Sentence in Choi & Palmer (2012) :

This product is [a global brand]

  • ATTR (is, brand)

Example Sentence in Spacy :

This is our house.

  • ATTR (is, house)

Beliefs are part of a legacy.

  • ATTR (are, part)

Boys will be boys.

  • ATTR (be, boys)

4. oprd (object predicate) : An object predicate is a non-VP predicate in a small clause that functions like the predicate of an object. Section 3.4 describes how object predicates are derived.

Example Sentence in Choi & Palmer (2012) :

She calls [me] [her friend]

  • DOBJ (calls, me)
  • OPRD (calls, friend)

I am considered [her friend]

  • OPRD (considered, friend)

Example Sentence in Spacy :

She seems tired.

  • OPRD (seems, tired).

She grows older every day.

  • ACOMP (grows, older).

OTHERS DEPENDENCY

Auxiliaries

  1. AUX (auxiliary) : An auxiliary is an auxiliary or modal verb that gives further information about the main verb (e.g., tense, aspect). The preposition to, used for infinitive, is also considered an AUX. Auxiliary verbs for passive verbs are assigned with a separate dependency label AUXPASS

Example Sentence in Choi & Palmer (2012) :

I [have] [been] seeing her

  • AUX (seeing, have)
  • AUX (seeing, been)

Example Sentence in Spacy :

I decided to go home.

  • AUX (go, to)

Boys will be boys.

  • ATTR (be, will)

I don’t like to be bothered.

  • AUX (bothered, to)

2. AUXPASS (passive auxiliary) : A passive auxiliary is an auxiliary verb, be, become, or get, that modifies a passive verb.

Example Sentence in Choi & Palmer (2012) :

I [am] drawn to her.

  • AUXPASS (drawn, am)

Example Sentence in Spacy :

I am struck by her beauty.

  • AUXPASS (struck, am)

I don’t like to be bothered.

  • AUXPASS (bothered, be)

Hyphenation

3. COMPOUND (modifier in hyphenation) : A modifier in hyphenation is a constituent preceding a hyphen, which modifies a constituent following the hyphen

Example Sentence in Choi & Palmer (2012) :

New-York Times

  • HMOD (York, New)

Example Sentence in Spacy :

New-York Times

  • COMPOUND (York, New)

pen-friend

  • COMPOUND (friend, pen)

tee-shirt

  • COMPOUND (shirt, tee)

4. PUNCT (hyphen) : A hyphen modifies a constituent following the hyphen.

Example Sentence in Choi & Palmer (2012) :

New-York Times

  • HYPH (York, -)

Example Sentence in Spacy :

New-York Times

  • PUNCT (York, -)

pen-friend

  • PUNCT (friend, -)

tee-shirt

  • PUNCT (shirt, -)

Complements

5. ACOMP (adjectival complement) : An adjectival complement is an adjective phrase that modifies the head of a VP|SINV| SQ, that is usually a verb.

Example Sentence in Choi & Palmer (2012) :

She looks [so beautiful]

  • ACOMP (looks, beautiful)

Are you [worried].

  • ACOMP (Are, worried)

[Most important] is your heart.

  • ACOMP (is, important)
  • NSUBJ (is, heart)

Example Sentence in Spacy :

She grew older.

  • ACOMP (grew, older)

I am not sure.

  • ACOMP (am, sure)

6. CCOMP (clausal complement) : A clausal complement is a clause with an internal subject that modifies the head of an ADJP|ADVP|NML| NP|WHNP|VP|SINV| SQ. For NML|NP|WHNP, a clause is considered a CCOMP if it is neither a infinitival modifier, a participial modifier, nor a relative clause modifier.

Example Sentence in Choi & Palmer (2012) :

She said [(that) she wanted to go]

  • CCOMP (said, wanted)

I am not sure [what she wanted]

  • CCOMP (sure, wanted)

Example Sentence in Spacy :

He reported that the findings were flawed

  • CCOMP (reported, were)

She decided that she would give up.

  • CCOMP (decided, give)

She said that she wanted to go.

  • CCOMP (said, wanted)

7. XCOMP (open clausal complement) : An open clausal complement is a clause without an internal subject that modifies the head of an ADJP|ADVP|VP|SINV|SQ.

Example Sentence in Choi & Palmer (2012) :

I want [to go]

  • XCOMP(want, go)

It is too soon [to go]

  • XCOMP (soon, go)

Example Sentence in Spacy :

She decided to leave.

  • XCOMP (decided, leave)

It helps reinforce the knowledge.

  • XCOMP (helps, reinforce)

Class women began demanding more rights.

  • XCOMP (began, demanding)

I want to avoid looking that direction.

  • XCOMP (want, avoid)
  • XCOMP (avoid, looking)

too difficult to think about it

  • XCOMP (difficult, think)

I hate wasting my time.

  • XCOMP (hate, wasting)

8. MARK (complementizer) : A complementizer is a subordinating conjunction, if, that, or whether, that introduces a clausal complement (Section 4.8.2). A COMPLM is assigned when a clausal complement is found (see the line 6 of is Clausal Complement

Example Sentence in Choi & Palmer (2012) :

She said [that] she wanted to go.

  • COMPLM (wanted, that)

Example Sentence in Spacy :

She said that she wanted to go.

  • MARK (wanted, that)

If you want we can go there.

  • MARK (want, if)

Whether it rains or not is not important.

  • MARK (rains, whether)

Modifiers: adverbial related

9. ADVCL (adverbial clause modifier) : An adverbial clause modifier is a clause that acts like an adverbial modifier. A clause with an adverbial function tag (see has AdverbialTag(C)) is considered an ADVCL. Additionally, a subordinate clause or an open clause is considered an ADVCL if it does not satisfy any other dependency relation

Example Sentence in Choi & Palmer (2012) :

She came [as she promised]

  • ADVCL (came, promised)

Example Sentence in Spacy :

I rained as it was supposed to.

  • ADVCL (rained, supposed)

I view him as he was my own dad.

  • ADVCL (view, was)

10. ADVMOD (adverbial modifier) : An adverbial modifier is an adverb or an adverb phrase that modifies the meaning of another word. Other grammatical categories can also be ADVMOD if they modify adjectives.

Example Sentence in Choi & Palmer (2012) :

I did [not] know her.

  • ADVMOD (know, not)

I’m not sure [any] more.

  • ADVMOD (more, any)

She is [so] beautiful.

  • ADVMOD (beautiful, so)

Example Sentence in Spacy :

I did not know her.

  • NEG (know, not)

It seems rather interesting.

  • ADVMOD (interesting, rather)

I would rather go elsewhere.

  • ADVMOD (go, rather)
  • ADVMOD (go, elsewhere)

11. MARK (maker) : A marker is a subordinating conjunction (e.g., although, because, while) that introduces an adverbial clause modifier

Example Sentence in Choi & Palmer (2012) :

She came [as she promised]

  • MARK(promised, as)

She came [because she liked me]

  • MARK (liked, because)

Example Sentence in Spacy :

She said that she wanted to go.

  • MARK (wanted, that)

If you want we can go there.

  • MARK (want, if)

Whether it rains or not is not important.

  • MARK (rains, whether)

12. NEG (negation modifier) : A negation modifier is an adverb that gives negative meaning to its head.

Example Sentence in Choi & Palmer (2012) :

She decided not to come

  • NEG (come, not)

Example Sentence in Spacy :

I did not know her.

  • NEG (know, not)

13. NPADVMOD (noun phrase as adverbial modifier) : An adverbial noun phrase modifier is a noun phrase that acts like an adverbial modifier. A noun phrase with an adverbial function tag (see hasAdverbialTag(C)) is considered an NPADVMOD. Moreover, a noun phrase modifying either an adjective or an adverb is also considered an NPADVMOD.

Example Sentence in Choi & Palmer (2012) :

Three times [a week].

  • NPADVMOD (times, week)

It is [a bit] surprising.

  • NPADVMOD (surprising, bit)

She lives [next door].

  • NPADVMOD (lives, door)

Example Sentence in Spacy :

Three pounds a kilo

  • NPADVMOD (pounds, kilo)

Twice a year

  • NPADVMOD (twice, year)

14. CONJ (conjunct) : A conjunct is a dependent of the leftmost conjunct in coordination. The leftmost conjunct becomes the head of a coordinated phrase.

Example Sentence in Choi & Palmer (2012) :

John, [Mary], and [Sam].

  • CONJ (John, Mary)
  • CONJ (John, Sam)

Example Sentence in Spacy :

Aims and objectives of this study

  • CONJ (aims, objectives)

Ladies and gentleman, here it comes.

  • CONJ (ladies, gentleman)

15. CC (coordinating conjunction) : A coordinating conjunction is a dependent of the leftmost conjunct in coordination.

Example Sentence in Choi & Palmer (2012) :

John, Mary, [and] Sam.

  • CC (John, and)

Example Sentence in Spacy :

Aims and objectives of this study

  • CC (Aims, and)

Ladies and gentleman, here it comes.

  • CONJ (Ladies, and)

16. PRECONJ (pre-correlative conjunction) : A pre-correlative conjunction is the first part of a correlative conjunction that becomes a dependent of the first conjunct in coordination.

Example Sentence in Choi & Palmer (2012) :

[Either] John [or] Mary.

  • PRECONJ (John, Either)
  • CC (John, or)
  • CONJ (John, Mary)

Example Sentence in Spacy :

Either your life or nothing

  • PRECONJ (life, Either)

Modifiers: noun phrase related

17. NMOD (modifier of nominal) : A modifier of nominal is any unclassified dependent that modifies the head of a noun phrase.

Example Sentence in Spacy :

  • NMOD (assessors, be)
  • NMOD (companies, food)

Note: examples from parsed text using SpaCy not from SpaCy visualizer

18. APPOS (appositional modifier) : An appositional modifier of an NML|NP is a noun phrase immediately preceded by another noun phrase, which gives additional information to its preceding noun phrase. A noun phrase with an adverbial function tag

Example Sentence in Choi & Palmer (2012) :

John, [my brother].

  • APPOS(John, bother)

He [himself] bought the car.

  • APPOS(He, himself)

Example Sentence in Spacy :

This lady, a brilliant teacher, lives here.

  • APPOS (Lady, teacher)

19. DET (determiner) : A determiner is a word token whose pos tag is DT|WDT|WP that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

[What] kind of movie is this

  • DET (movie, What)

[The] US military

  • DET (military, The)

Example Sentence in Spacy :

Which book is the best?

  • DET (book, Which)

This is an apple.

  • DET (apple, an)

Every student here is enagged

  • DET (student, every)

20. ACL (infinitival modifier) : An infinitival modifier is an infinitive clause or phrase that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

I have too much homework [to do].

  • INFMOD (homework, do)

I made an effort [to come].

  • INFMOD (effort, come)

Example Sentence in Spacy :

I have too much homework to do.

  • RELCL (homework, do)

I made an effort to come.

  • ACL (effort, come)

very hard concept to define

  • ACL (concept, define)

cultural ideas running through society

  • ACL (ideas, running)

with the ability to chose your own way

  • ACL (ability, choose)

21. COMPOUND (noun compound modifier) : A noun compound modifier is any noun that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

The [US] military

  • PREDET(military, US)

The [video] camera

  • PREDET(camera, video)

Example Sentence in Spacy :

I went to a video shop.

  • COMPOUND (shop, video)

I love orange juice.

  • COMPOUND (juice, orange)

He is at the petrol station.

  • COMPOUND (station, petrol)

Seven million dollars

  • COMPOUND (million, seven)

22. NUM (numeric modifier) : A numeric modifier is any number or quantifier phrase that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

[One] nation, [fifty] states

  • NUM (nation, One)
  • NUM (states, fifty)

Example Sentence in Spacy :

Thirty more days.

  • NUM (days, thirty)
  • AMOD (days, more)

23. ACL (participial modifier) : A participial modifier is a clause or phrase whose head is a verb in a participial form (e.g., gerund, past participle) that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

I went to the party [hosted by her]

  • PARTMOD (party, hosted)

Example Sentence in Spacy :

I went to the party hosted by her.

  • ACL (party, hosted)

The idea mentioned in the report

  • ACL (idea, mentioned)

students encouraged by their teachers

  • ACL (students, encouraged)

a car driving down the road

  • ACL (car, driving)

24. CASE (possessive modifier) : A possessive modifier is a word token whose pos tag is POS that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

John[’s] car

  • NMOD (John, ’s)

Example Sentence in Spacy :

John’s car

  • CASE (John, ’s)
  • POSS (John, car)

Mother’s birthday

  • CASE (Mother, ’s)
  • POSS (Mother, birthday)

25. PREDET (predeterminer) : A predeterminer is a word token whose pos tag is PDT that modifies the head of a noun phrase.

Example Sentence in Choi & Palmer (2012) :

[Such] a beautiful woman

  • PREDET (woman, Such)

[All] the books we read

  • PREDET (books, All)

Example Sentence in Spacy :

Such a beautiful woman

  • PREDET (woman, such)

We had such a good time together

  • PREDET (time, such)

All the books we read.

  • PREDET (books, All)

Both the girls went out

  • PREDET (girls, both)

26. RELCL (relative clause modifier) : A relative clause modifier is a either relative clause or a reduced relative clause that modifies the head of an NML|NP|WHNP

Example Sentence in Choi & Palmer (2012) :

I bought the car [(that) I wanted].

  • RCMOD (car, wanted)

Example Sentence in Spacy :

I bought the car that I wanted.

  • RELCL (car, wanted)

I came to a conclusion that sounds plausible.

  • RELCL (conclusion, sounds)

For comparison: I was so excited that I could not sleep.

  • CCOMP (excited, sleep)

Modifiers: prepositional phrase related

27. PCOMP (complement of a preposition) : A complement of a preposition is any dependent that is not a POBJ but modifies the head of a prepositional phrase.

Example Sentence in Choi & Palmer (2012) :

I agree with [what you said].

  • PCOMP (with, said)

Example Sentence in Spacy :

I talk about where it would fit best.

  • PCOMP (about, fit)

28. POBJ (object of a preposition) : An object of a preposition is a noun phrase that modifies the head of a prepositional phrase, which is usually a preposition but can be a verb in a participial form such as VBG.

Example Sentence in Choi & Palmer (2012) :

On [the table].

  • POBJ (On, table)

Given us.

  • POBJ (Given, us)

Example Sentence in Spacy :

The kids playing on their computers.

  • POBJ (on, computers)

the uses that statistics do have in sociology

  • POBJ (in, sociology)

29. PREP (prepositional modifier) : A prepositional modifier is any prepositional phrase that modifies the meaning of its head.

Example Sentence in Choi & Palmer (2012) :

Thank you [for coming [to my house]]

  • PREP (Thank, for)
  • PREP (coming, to)

Please put your coat [on the table]

  • PREP (put, on)

Example Sentence in Spacy :

impacts that it had upon women

  • PREP (had, upon)

We bought it in the sale.

  • PREP (bought, in)

A discussion about your future

  • PREP (discussion, about)

Modifiers: quantifier phrase related

30. NUMMOD (number compound modifier) : A number compound modifier is a cardinal number that modifies the head of a quantifier phrase.

Example Sentence in Choi & Palmer (2012) :

[Seven] million dollars

  • NUMBER (million, seven)

Example Sentence in Spacy :

Seven million dollars

  • COMPOUND (million, seven)

Seven big cakes

  • NUMMOD (cakes, seven)

I could have done it in half his time

  • NUMMOD (time, half)

31. QUANTMOD (quantifier phrase modifier) : A quantifier phrase modifier is a dependent of the head of a quantifier phrase.

Example Sentence in Choi & Palmer (2012) :

[More] [than] five

  • QUANTMOD (five, than)

[Five] [to] six

  • QUANTMOD (six, Five)
  • QUANTMOD (six, to)

Example Sentence in Spacy :

Less than seven

  • QUANTMOD (seven, than)

Hundred to thousand

  • QUANTMOD (thousand, hundred)
  • QUANTMOD (thousand, to)

Modifiers: Miscellaneous

32. AMOD (adjectival modifier) : An adjectival modifier is an adjective or an adjective phrase that modifies the meaning of another word, usually a noun.

Example Sentence in Choi & Palmer (2012) :

A [beautiful] girl.

  • AMOD (girl, beautiful)

[How many] people came.

  • AMOD (people, many)

Example Sentence in Spacy :

These are some key issues

  • AMOD (issues, key)

Many more days

  • AMOD (days, many)
  • AMOD (days, more)

33. DEP (unclassified dependent) : An unclassified dependent is a dependent that does not satisfy conditions for any other dependency.

Example Sentence in Spacy :

  • DEP (are, use)
  • DEP (is, both)

Note: examples from parsed text using SpaCy not from SpaCy visualizer

34. INTJ (interjection) : An interjection is an expression made by the speaker of an utterance.

Example Sentence in Choi & Palmer (2012) :

[Well], it is my birthday

  • INTJ (is, Well)

I [um] will throw a party

  • INTJ (throw, um)

Example Sentence in Spacy :

Like, you know, it was very nice.

  • INTJ (was, like)

35. META (meta modifier) : A meta modifier is code (1), embedded (2), or meta (3) information that is randomly inserted in a phrase or clause.

Example Sentence in Choi & Palmer (2012) :

[choijd] My first visit.

  • META (visit, choijd)

Example Sentence in Spacy :

  • META (thought, ii)
  • META (put, iii)

Note: examples from parsed text using SpaCy not from SpaCy visualizer

36. PARATAXIS (parenthetical modifier) : A parenthetical modifier is an embedded chunk, often but not necessarily surrounded by parenthetical notations (e.g,. brackets, quotes, commas, etc.), which gives side information to its head

Example Sentence in Choi & Palmer (2012) :

She[, I mean,] Mary was here

  • PARATAXIS (was, mean)

Example Sentence in Spacy :

Like, you know, it was very nice.

  • PARATAXIS (was, know)

37. POSS (possession modifier) : A possession modifier is either a possessive determiner (PRP$) or a NML|NP|WHNP containing a possessive ending that modifies the head of a ADJP|NML|NP|QP|WHNP.

Example Sentence in Choi & Palmer (2012) :

I bought [his] car.

  • POSS (car, his)

I bought [John’s] car.

  • POSS (car, John)

Example Sentence in Spacy :

Mother’s birthday

  • POSS (Mother, birthday)
  • CASE (Mother, ’s)

38. PRT (particle) : A particle is a preposition in a phrasal verb that forms a verb-particle construction.

Example Sentence in Choi & Palmer (2012) :

Shut [down] the machine

  • PRT(Shut, down)

Shut the machine [down]

  • PRT(Shut, down)

Example Sentence in Spacy :

She gave up her dancing lessons.

  • PRT (gave, up)

I have to put the meeting off.

  • PRT (put, off)

39. PUNCT (punctuation) : Any punctuation is assigned the dependency label PUNCT.

Example Sentence in Spacy :

pen-friend

  • PUNCT (friend, -)

tee-shirt

  • PUNCT (shirt, -)

40. ROOT

--

--

Top'p Kullawattana

Coding Stylist of Kept by Krungsri, I have experience of 10 years in the design and implementation of enterprise applications.