There are a couple of ways you could do this. Technically you could build all of this in one page (no back-end coding required). But I guess this kind of depends on how many words you want to generate a response for. If it's a large list then you probably want a back-end and you'll probably want to use a database at that.
The other thing would be how specific you want the matching to be. Now I don't know what this page is going to be for but using your example, if someone types "apple" they will get "fruit". But what if they type in "apples" or "some apples"? Again, since I don't know what this page is for I don't know how many different words or combinations people would be entering into this textbox. But it is still something to consider when writing a script. Plus as I read your post again I can't help but wonder if you want a list of words that get matched to their own specific phrases, or do you want a list of words and everything else that doesn't match gets your "this is not a fruit" message?
For example, do you want something like:
apple, banana, orange, grape, watermelon = fruit
everything else = this is not a fruit
Or are you looking for something more or less like
apple = fruit
banana = fruit
orange = fruit
grape = fruit
watermelon = fruit
cabbage = this is not a fruit
Once I better understand what you are looking for I can help you get some code that will do the job.