Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine subject, object and other words?

I'm trying to implement application that can determine meaning of sentence, by dividing it to smaller pieces. So I need to know what words are subject, object etc. so that my program can know how to handle this sentence.

like image 221
newbie Avatar asked Aug 23 '09 10:08

newbie


People also ask

How do you determine what the subject of a sentence is?

The subject of the sentence is what (or whom) the sentence is about. In the sentence “The cat is sleeping in the sun,” the word cat is the subject. A predicate is the part of a sentence, or a clause, that tells what the subject is doing or what the subject is.

How do you determine the object of the sentence?

The object of a sentence is the person or thing that receives the action of the verb. It is the who or what that the subject does something to.

How do you find the subject and object of a question?

In subject questions where we want to find information about the subject, we do not use the auxiliary verb do/does/did. In object questions where we want to find information about the object, we use the auxiliary verb do/does/did. Study the sentence given below. John broke a window.


1 Answers

You should look at the Natural Language Toolkit, which is for exactly this sort of thing.

See this section of the manual: Categorizing and Tagging Words - here's an extract:

>>> text = nltk.word_tokenize("And now for something completely different")
>>> nltk.pos_tag(text)
[('And', 'CC'), ('now', 'RB'), ('for', 'IN'), ('something', 'NN'),
('completely', 'RB'), ('different', 'JJ')]

"Here we see that and is CC, a coordinating conjunction; now and completely are RB, or adverbs; for is IN, a preposition; something is NN, a noun; and different is JJ, an adjective."

like image 184
RichieHindle Avatar answered Sep 18 '22 17:09

RichieHindle