Q1.I am trying to get tense of a complete sentence,just don't know how to do it using nlp. Any help appreciated.
Q2 .What all information can be extracted from a sentence using nlp?
Currently I can, I get : 1.Voice of sentence 2.subject object verb 3.POS tags.
Any more info can be extracted please let me know.
The Penn treebank defines VBD
and VBN
as the past tense and the past participle of a verb, respectively. In many sentences, simply getting the POS tags and checking for the presence of these two tags will suffice. In others, however, there may be verbs in multiple tenses while the sentence as a whole is in the past tense. For these cases, you need to use constituency parsing. Stanford NLP also provides a parser. You can use this to detect the outermost verb phrase (tagged as VP
). If a past tense/participle form of a verb is an ancestor of all other verbs in the verb phrase, the tense of your sentence should be marked as past tense.
The example given by Dror yields this:
(ROOT
(S
(NP (PRP I))
(VP (VBD did) (RB n't)
(VP (VB want)
(NP (DT the) (NN dog)
(S
(VP (TO to)
(VP (VB eat)
(NP (PRP$ my) (NN homework))))))))
(. .)))
Even though eat is not past tense, the topmost verb in the verb phrase is correctly tagged VBD
(i.e. past tense).
edit (some additional information):
Complex sentences have what is called the primary tense and a secondary tense. For sentences like "By the time I will reach there, he'd have already left", there is no such thing as 'the complete tense'. You can only distinguish between the primary and the secondary.
If you want information about perfect, continuous, etc., then you will have to derive rules based on the POS tags. E.g. an auxiliary verb in present tense followed by a verb in the past tense will express the present perfect tense (if there are obvious counterexamples, please add to the answer ... I can't think of any right now).