How to check if a sentence is a question with spacy?

Viewed 2034

I am using spacy library to build a chat bot. How do I check if a document is a question with a certain confidence? I know how to do relevance, but not sure how to filter statements from questions.

I am looking for something like below:

spacy.load('en_core_web_lg')('Is this a question?').is_question
1 Answers

My first response is to suggest looking for question marks at the end of the sentence.

Otherwise, most questions start with {is, does, do, what, when, where, who, why, what, how}.

There is a more complex answer involving the inclusion of auxiliary verbs and their placement relative to the verb, but if your data is well-formed, this may be sufficient (and fast).

Related