Determining tense of a sentence Python

后端 未结 3 1851
孤街浪徒
孤街浪徒 2021-01-31 20:30

Following several other posts, [e.g. Detect English verb tenses using NLTK , Identifying verb tenses in python, Python NLTK figure out tense ] I wrote the following code to dete

3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 20:39

    As of http://dev.lexalytics.com/wiki/pmwiki.php?n=Main.POSTags, the tags mean

    MD  Modal verb (can, could, may, must)
    VB  Base verb (take)
    VBC Future tense, conditional
    VBD Past tense (took)
    VBF Future tense
    VBG Gerund, present participle (taking)
    VBN Past participle (taken)
    VBP Present tense (take)
    VBZ Present 3rd person singular (takes)
    

    so that your code would be

    tense["future"] = len([word for word in tagged if word[1] in ["VBC", "VBF"])
    

提交回复
热议问题