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).
Basically the tense of a sentence in English is determined by the form of the verb that is the head of the sentence. You may read more about this topic in this post about The Contextors’ Tense Conjugator. Identifying the head verb and its form is possible using a parser.
The kind of information that can be extracted from a sentence depends on the analysis you perform. You can extract other components of the sentence such as prepositional complements, predicative complements and adjuncts, as well as other grammatical attributes such as aspect, secondary tense, modality and polarity. Some sentences contains embedded clauses, like in the example below from the Contextors API. In this case, you may want to extract this information also from the embedded clause.
I want complete tense eg: simple present OR present perfect continuous tense ... as far as i know I cannot get simply from POS tags
Note that what you have in your examples above are not examples of tense, they are rather examples of certain tense/aspect configurations. While tense by itself (past, present, future) places an eventuality in time, aspect categories (progressive, continuous, perfective, and the like) rather relate the eventuality to the flow of time (i.e. whether it is bounded/completed, whether it was a continuous event, etc). Thus, tense and aspect are two distinct grammatical categories. In English, they both form part of the verbal complex, which makes it easy to confuse them as well as find/analyze them in a single method. In many other languages, they are realized separately (distinct structural positions, functional items, constructions, etc.). Beware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With