Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if a sentence is a question (interrogative)?

Tags:

Is there an open source Java library/algorithm for finding if a particular piece of text is a question or not?
I am working on a question answering system that needs to analyze if the text input by user is a question.
I think the problem can probably be solved by using opensource NLP libraries but its obviously more complicated than simple part of speech tagging. So if someone can instead tell the algorithm for it by using an existing opensource NLP library, that would be good too.
Also let me know if you know a library/toolkit that uses data mining to solve this problem. Although it will be difficult to get sufficient data for training purposes, I will be able to use stack exchange data for training.

like image 492
nabeelmukhtar Avatar asked Aug 26 '10 09:08

nabeelmukhtar


People also ask

What is an interrogative question sentence?

An interrogative sentence asks a direct question and is punctuated at the end with a question mark. It is one of the four basic types of sentences, and it's a highly useful one. Could you imagine life without questions?

Are all questions interrogative sentences?

There are three basic question types and they are all interrogative sentences: Yes/No question: the answer is "yes or no", for example: Do you want dinner? (No thank you.)

What are the 5 interrogative question words?

They are: who, which, whom, what and whose. These are also known as wh-words.

What is the difference between a question and an interrogative sentence?

This paper explores the relation between interrogative, a category of grammatical form, and question, a category of meaning. Interrogative contrasts with declarative, imperative, etc., in the system of clause type (not sentence type); a question defines a set of answers.


1 Answers

In a syntactic parse of a question, the correct structure will be in the form of:

(SBARQ (WH+ (W+) ...)        (SQ ...*            (V+) ...*)        (?)) 

So, using anyone of the syntactic parsers available, a tree with an SBARQ node having an embedded SQ (optionally) will be an indicator the input is a question. The WH+ node (WHNP/WHADVP/WHADJP) contains the question stem (who/what/when/where/why/how) and the SQ holds the inverted phrase.

i.e.:

(SBARQ    (WHNP      (WP What))    (SQ      (VBZ is)      (NP        (DT the)        (NN question)))   (. ?)) 

Of course, having a lot of preceeding clauses will cause errors in the parse (that can be worked around), as will really poorly-written questions. For example, the title of this post "How to find out if a sentence is a question?" will have an SBARQ, but not an SQ.

like image 52
msbmsb Avatar answered Oct 28 '22 11:10

msbmsb