Extract subject using textblob nltk

354 Views Asked by At

I am using textblob nltk to do some action for a given sentence.I am very new to nltk and text processing.I am able to decide the action for the given sentence but I have no idea how to extract the subject

Here is the code

from textblob.classifiers import NaiveBayesClassifier


trainingSet = [
('Get me juice','get'),
('Get me orange', 'get'),
('I want juice', 'get'),
('I dont want orange', 'take'),
('I dont like apple', 'take'),
('I detest watermelon', 'take')
]

cl = NaiveBayesClassifier(trainingSet)

print(cl.classify('I hate pumpkin'))

This gives me the label 'take' but how do I train it to extract the subject too? That is I want the result to be 'take', 'pumpkin'

0

There are 0 best solutions below