Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract Predicate and subject from a sentence using NLP Libraries?

I want to find predicate and subject from a sentence using Natural Language Processing Libraries. Is this technique have any name in the world of NLP or Is there any way to do that?

Example : He likes child. Result: (He, likes child)

like image 612
user6750923 Avatar asked Sep 01 '16 03:09

user6750923


People also ask

How do you find the subject and predicate of an object in a sentence?

Subject, predicate, and objects are the three different components when breaking down a sentence. The subject is the "who" or "what" of the sentence, the predicate is the verb, and the object is any noun or concept that is part of the action of the subject.

How do you find the subject of a sentence in Python?

It follows subject-verb-object model. To mark the subject, write a rule set with POS tags. Tag the sentence I[NOUN] shot[VERB] an elephant[NOUN] . If you see the first noun is subject, then there is a verb and then there is an object.

What is subject and predicate?

Every complete sentence contains two parts: a subject and a predicate. The subject is what (or whom) the sentence is about, while the predicate tells something about the subject.


1 Answers

Yes you can do that with Word Dependency Parsing which is available in spaCy NLP. Here is the visualization using spaCy displaCy:

enter image description here

from that visualization, you can extract the word "He" as subject since its dependency property is "nsubj" or "normal subject", the word "likes" is predicate since its dependency property is "root" that means no dependency to other word in the sentence, and the word "childs" as an object since its dependency property is "dobj" or direct object.

You can access that visualization directly here

like image 183
Syauqi Haris Avatar answered Nov 05 '22 09:11

Syauqi Haris