waterfieldea / magic8ball

Magic 8 Ball Project
0 stars 0 forks source link

Validate question input #1

Open ramseyboy opened 7 years ago

ramseyboy commented 7 years ago

Right now a user could enter whatever they want into the question request, like 1, #000, .45, a url or whatever and the app would most certainly crash as it's expecting a string.

We should add validation and unit tests (doc tests) for that validation.

waterfieldea commented 7 years ago

OK, I finally got it work for me, in the sense that I put a question in and it returned something. I put in #000 in and it still just pumped something out. Is that because of the way in which we are testing it? I shall investigate validation and unit tests because I know what those are pfffttt. Shot in the dark but is that monitor something or help to not get an error when a user inputs something other than a string?

waterfieldea commented 7 years ago

Since the question is split into a list of strings doesn't that take care of error? If the first indices isn't should, can, will, what, or when then it just defaults to the else statement and pulls from the bank of all responses. So then the issue would be doing something them not putting in one of those key words? Would doing something with a KeyError be a path to explore?

ramseyboy commented 7 years ago

@waterfieldea I think you could just validate the input so that inputs like $ or 1234, (essentially anything that isn't a word) would produce an error. Then you can unit test your validation logic.

ramseyboy commented 7 years ago

next step would be to make sure that the input question is actually a question.. http://stackoverflow.com/questions/17879551/nltk-find-if-a-sentence-is-in-a-questioning-form

ramseyboy commented 7 years ago

also this http://stackoverflow.com/questions/10252448/how-to-check-whether-a-sentence-is-correct-simple-grammar-check-in-python