Detect English verb tenses using NLTK

前端 未结 2 1351
终归单人心
终归单人心 2021-02-04 08:28

I am looking for a way given an English text count verb phrases in it in past, present and future tenses. For now I am using NLTK, do a POS (Part-Of-Speech) tagging, and then co

2条回答
  •  一整个雨季
    2021-02-04 08:38

    Thee exact answer depends on which chunker you intend to use, but list comprehensions will take you a long way. This gets you the number of verb phrases using a non-existent chunker.

    len([phrase for phrase in nltk.Chunker(sentence) if phrase[1] == 'VP'])
    

    You can take a more fine-grained approach to detect numbers of tenses.

提交回复
热议问题