The ChatBot creates a dialogue where users can ask questions about some aspects of memory management in C++. After the knowledge base of the chatbot has been loaded from a text file, a knowledge graph representation is created in computer memory, where chatbot answers represent the graph nodes and user queries represent the graph edges. After a user query has been sent to the chatbot, the Levenshtein distance is used to identify the most probable answer. This project uses raw pointers to represent the knowledge graph and interconnections between objects.
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build - Compile:
cmake .. && make - Run it:
./membot.
src -
| `chatgui.h` / `chatgui.cpp`
| `chatlogic.h` / `chatlogic.cpp`
| `chatbot.h` / `chatbot.cpp`
| `graphnodes.h` / `graphnodes.cpp`
| `graphedges.h` / `graphedges.cpp`
-
chatgui.h/chatgui.cpp: In filechatgui.h/chatgui.cpp, this makes_chatLogican exclusive resource to classChatbotPanelDialogusing a smart pointer. -
chatbot.h/chatbot.cpp:ChatBotcomplies with the Rule of Five such as Chatbot constructor methods which allocate / deallocate memory resources on the heap and also copy member data. When sending a query to the ChatBot, it prints a string of the type e.g. "ChatBot Copy Constructor" to the console. Rule of five mehtods are as follows:- ChatBot Constructor/Destructor
- ChatBot Move Constructor
- ChatBot Move Assignment Operator
- ChatBot Copy Constructor
- ChatBot Copy Assignment Operator
-
chatlogic.h/chatlogic.cpp:- adapt the vector
_nodesin a way that the instances ofGraphNodesto which the vector elements refer are exclusively owned by the classChatLogic. - create a local
ChatBotinstance on the stack at the bottom of functionLoadAnswerGraphFromFile. - pass the
ChatBotinstance into the root node by using move semantics. ChatLogichas no ownership relation to theChatBotinstance and thus is no longer responsible for memory allocation and deallocation- the
ChatBotinstance (_chatBot) is used as a communication handle between GUI andChatBotinstance. - When passing the
GraphNodeinstances to functions, contains the changes to classChatLogic.
- adapt the vector
-
graphnodes.h/graphnodes.cpp- each instance of
GraphNodeexclusively owns the outgoingGraphEdgesand holds non-owning references to incomingGraphEdgeswith smart pointers. - When transferring ownership from class
ChatLogic, where all instances ofGraphEdgeare created, into instances ofGraphNode, use move semantics.
- each instance of
| start | end |
|---|---|
![]() |
![]() |
- cmake >= 3.11
- make >= 4.1
- gcc/g++ >= 5.4
- wxWidgets >= 3.0, wxWidgets Binary


