Frage

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.

War es hilfreich?

Lösung

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).

Andere Tipps

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.

enter image description here

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.

8 years later but maybe someone is still searching for another solution. As part of my study I actually tried to distinguish the tense including the tense aspect (for instance future simple, present perfect progressive, future perfect,...) in a sentence using the dependency parser of the Stanford Core NLP and a deterministic program I put together after a lot of research on english grammar. I'm a beginner programmer and not a linguist. However, I got a weighted f1-score of 89,75% on my test data which isnt bad. So if anyone wants to build on that foundation, heres the logic I implemented displayed as a flow chart: flow chart to distinguish tense aspects

If anyone is interested, I could also send the paper I wrote about it. Its in german, but I could translate relevant parts if needed. Don't know if this answer helps anyone, but since I spend so much time with this question, I thought I'd share the results :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top