I need to ensure that certain strings are valid questions. I am thinking of how to write this myself, but without being pretty limiting it is actually a fairly complex bit of analysis, and I'm sure it must have been done many times before.
I'm not just talking about starting with an interrogatory word and ending with a question mark. For example I would like all these to pass:
I would love to get hold of an existing js lib (or port something) that does this for me. I've been looking around for a while but have found nothing.
Alex K in the comments under my question gave me the exact answer I needed.
Awesome! :-)
Edit:
As requested, here is a working example.
In your terminal, with npm installed, type the following:
npm install compromise
Now to test if a string (myString) contains a question you would use the following:
var nlp = require('compromise');
var containsQuestion = nlp(myString).questions().data().length === 1;
(In the above case, multiple questions also results in a negative result)