Use the [Mycroft](https://github.com/wpm/mycroft) text classification framework. That will cut down on the code here, and prove that Mycroft is viable as a programmatic interface.