Above is an excerpt from an actual chatbot that I wrote
(pretty quickly) using a python NLTK (Natural Language
ToolKit), which is I might add... just a super cool
package. I only tinkered with the package contents, but
the implications are huge. The fullscreenshot is here.
I've posted the script here if
you're interested in viewing the sourcecode. You'll need
to Python installed, of course, and you'll also have to pip
install nltk to download the correct dependencies
for the program.
What is it?
I don't mean it pejoratively when I say that this chatbot is a chatbot in it's simplest form. Circa the 1990's this chatbot takes input from the user and responds with pre-coded text that. It doesn't handle grammar especially well, and can be confused by capitalization. I also had to change the unicode formatting (still to a universal font type) because a piece of grammar I couldn't find on line 60 key throwing the ASCII encoding. Font encoding is line 2.
It's possible to download and use a "corpus" and some fancy learning algorithms to make a learning bot, but this really extends beyond the function of this project, which is currently halfway through its development. The first half was building a functional bot (done). I'm especially proud of the fact that if you ask the bot to tell you any kind of joke, the bot will respond with a really bad joke (generally about pirates because I didn't feel like loading more than a couple dozen jokes into the language repository). I'll clean it up once part II of this project is completely.
Part II
The original vision for this chatbot program was to host it on my EC2 instance and open it up in an interactive session on this page. Let's pretend that the technology to do this is in... an early development phase, to be optimistic. Several apps (Skult especially and Trinket) allow some sort of modular porting for Python into a web app (Python isn't natively compatible with HTML--who know?!). The best possible format for this "vision" would be to uproot my whole page, rewrite it with a php engine, plot it on an EC2 server (which would ironically be a lot cheaper but take a ludicrously higher amount of labor to deploy, modify, and maintain--not to mention open it up to a MUCH higher level of vulnerability). So that option is out.
The easiest, which is by no means easy still, would be to convert the entire project to Javascript. This is probably the direction I'm headed in. I'll either need to rebuild the whole project with an equivalent dependency package (I'm not sure what Java uses for NLTK, but I'm sure there's something) *or* use a program like Transcrypt to run python inside Java. Although I'll be honest, using HTML to run a Java applet to run a Python package... doesn't sound clean or efficient. I don't like it. So I'll probably just end up re-writing the entire thing in java and count a (sort-of) 2 part win. I'll become slightly proficient in Java, which I generally avoid because I find the syntax confusing, and I'll have learned forever that if I'm developing for webpage deployment to never ever ever use Python again.