Java Chatbot - Artificial Intelligence

Java Chatbot - Artificial Intelligence

 A Chatbot is an application designed to simulate the conversation with human users, especially over the Internet. Internally it uses any NLP (Natural Language Processing) system to interpret the human interactions and reply back with meaningful information.

AIML (Artificial Intelligence Markup Language) is an XML dialect for creating natural language software agents. It contains the basic rules which Natural Language Understanding (NLU) unit uses internally. It can be think of as a heart of the engine. The more rules we add in AIML – the more intelligent our Chatbot will be.

It’s important to know the difference between NLP and NLU. NLP refers to all systems that work together to handle end-to-end interactions between machines and humans in the preferred language of the human. In other words, NLP lets people and machines talk to each other “naturally”. NLU is actually a subset of the wider world of NLP. It helps in parsing unstructured inputs e.g. mispronunciations, swapped words, contractions, colloquialisms, and other quirks.

Download Unzip the program-ab distribution

We need to first unzip the program-ab distribution to a convenient folder. We will need to take Ab.jar and existing AIML rules from it.

Create eclipse project

Create eclipse maven project to start the development. So let’s create a maven project with .

Create project and import AIML library

Create eclipse maven project to start the development. Choose packaging as jar and GAV coordinate as your choice and import to eclipse. Now create a folder lib in the base folder and copy the Ab.jar from the program-ab distribution to this folder.

Add AIML to classpath

To add AIML to classpath, add Ab.jar to deployment assembly in eclipse. Alternatively you can install this jar into your local maven repository and then use it.

Add below AIML maven dependency to pom.xml. Now build the maven project by command mvn clean install

Copy default AIML rules

Copy the bots folder from program-ab directory into the resources folder of your maven project. This folder contains default AIML sets that we will use initially. Later we will see how we can add our custom rules into our Chatbot.

So finally after configuring the project it should be like as shown in below snapshot


Now create a simple java program i.e. Chatbot.java. It’s main() method will invoke the chat program which will run on the command prompt. Basic structure of this program will be to introduce a infinite loop and in each loop take a user input from command prompt and then we will ask program-ab API to give the answer of the input provided by user.

Now lets try to run our first command for chatbot program

More interactions in chatbot


I don't know if this is still up because its been 4 years. I tried what you did but I am having a problem when I try to run the program it says: Exception in thread "main" java.lang.NoClassDefFoundError: org/alicebot/ab/MagicBooleans at com.Main.main(Main.java:21) Caused by: java.lang.ClassNotFoundException: org.alicebot.ab.MagicBooleans at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) I have already add the jar file into my maven repository, and pom file.

Like
Reply

To view or add a comment, sign in

More articles by 🧿 Saral Saxena - PMP®

Others also viewed

Explore content categories