Get Instant Help From 5000+ Experts For

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
Implementing a Simple Chatbot in C - Project Requirements and Specifications


Chatbots – computer programs that can respond to queries typed in natural language – have recently become a popular addition to web sites  and other interactive applications.


The aim of this project is to implement a simple chatbot that can respond to simple queries made up of a single question word (called the  intent) and an object (called the entity). The chatbot will be able to answer questions such as Where is the printer? or What is C? by identifying  the intent (where or what) and entity (printer or C) then looking up the answer corresponding to this pair in a simple database. The chatbot will  also be able to learn new answers by asking questions of the user. If a user asks a question for which the database does not contain an answer,  the user will be given the option to supply an answer that can be used to respond to the same question in future. (This simulates having the  chatbot refer the unknown question to a third party who does know the answer.)


Your team is required to implement, in C, a chatbot of the kind described in the introduction. The chatbot will converse in the console using a  command-line-like interface; no graphical UI is required.


On each iteration of the main loop of the program (implemented for you in the main  function in the skeleton code), the program will display a prompt and wait for the user to type a question or instruction.


Firstly, your chatbot  should recognise some stock words and phrases to which it can give rote replies. These phrases will be referred to as smalltalk in the remainder  of this document. For example, the chatbot may reply “hello” whenever the user types “hello” or “hi”. Your chatbot should have at least five  items of smalltalk.


Apart from smalltalk, the chatbot will understand only a very simplified form of English in which all sentences are composed of only two parts,  called the intent and the entity, in that order.

. The intent represents what the user wants to do or to know. It may be a verb instructing the chatbot to do something, or a question word like  what, where, etc.


. The entity is a noun phrase representing the object to which the instruction or question refers.


The table below describes the intents and entities that must be understood by your chatbot.





For example, the user might type in Where is UOM?, which consists of an intent “WHERE” and an entity“UOM”. The chatbot might answer UOM  is located in Melbourne, Australia.


The chatbot will start without any knowledge of any entities, but can learn about them by asking the user. If someone asks it a question for  which it does not know the answer, the chatbot will print I don’t know followed by the question. The user may then type in answer. If the user  types an answer, the chatbot will thereafter user this answer. If the user simply presses ‘enter’ without typing anything, the chatbot will ignore  the response. In either case, the chatbot will then go back to waiting for more questions.


A conversation might therefore proceed as follows:


Chatbot: Hello.


Me: What is the Accounting Cluster?


Chatbot: I don’t know. What is the Accounting Cluster?


Me: The Accounting Cluster teaches accounting and in-depth understanding of business issues and processes.


Chatbot: Thank you.


Me: What is the ICT Cluster?


Chatbot: The Accounting Cluster teaches accounting and in-depth understanding of business issues and processes.


Some more detailed sample output is given at the end of this specification sheet.


Once the chatbot has learned some entities, they can be saved to disk using the SAVE intent, and recalled using the LOAD intent. The RESET  intent will erase all of the chatbot’s knowledge, leaving only the smalltalk in memory (but it will not erase any of the files created by SAVE, so  that they can be re-loaded later).


The LOAD intent should append all of the entities and responses in the file to whatever entities and responses already exist in the chatbot’s  memory. If an entity in the file is the same as one that is already in memory, the corresponding response from the file should replace the  response currently in memory. 



The skeleton program provided to you gives some guidance on how to structure a program of this kind and some hints on how it can be implemented. It consists of a header file, chat1002.h, that containsall of the type definitions and function prototypes for the program together with three modules as follows:

  • main.c contains the main loop and some utility functions. It prompts the user to type in a question, gathers the response, and divides it into words. You should not need to modify this file.
  • chatbot.c implements the behaviour of the chatbot. It is required to:
  1. Recognise smalltalk and provide an appropriate response.
  1. Otherwise, identify the intent and entity in each line of input from the user.
  1. If the intent is an instruction, carry it out.
  1. If the intent is a question, search the knowledge base (see below) for an answer.
  1. If the knowledge base does not contain an answer, ask the user for an answer, and add the new answer to the knowledge base.
  • knowledge.c implements the chatbot’s knowledge base, as described in the next section. For each question intent understood by the chatbot, the knowledge base should support
  1. Searching the knowledge base for an answer corresponding to the entity in the question.
  1. Adding a new entity with a corresponding answer to the question.
  1. Erasing the existing entities and answers.

A detailed explanation of what each function should do is given in a comment at the start of the function. Refer also to the comment at the top of chatbot.c for how that module works.

You may alter the skeleton code if you wish but do be sure to update any comments in the code so that they reflect what the modified code does.

Conceptually, the knowledge base consists of a single list for every question intent understood by the chatbot. Each element in the list consists  of an entity together with the answer to the question for that entity. Each list may be of arbitrary length; in particular it may grow indefinitely as  the chatbot learns more answers to more questions. It is up to you to decide how these lists should be implemented, and your implementation  should be described in the report that accompanies your submission.

You may assume that no entity is longer than MAX_ENTITY characters and that no answer is longer than MAX_RESPONSE characters, as defined in chat1002.h.

Different questions may refer to the same entity with different answers. Where is UOM?, for example, might have the answer already described,  while What is UOM? might explain that UOM is  the University of Melbourne, a university in Melbourne, Australia. An entity need not be  associated with an answer to all question intents; Who is UOM?, for example, need not be understood even if Where is UOM? and What is UOM? are.

Entities may be matched using simple a case-insensitive string matching algorithm, such as the one implemented by compare_token() in main.c. You do not need to perform expansion of acronyms, stemming, etc. or any other sophisticated types of matching (these require the use  of third party libraries in C)

sales chat
sales chat