📢 "Simple ChatGPT using String Matching Algorithms and Regular Expression"
- Program Description
- Required Program
- How to Run The Program
- Progress Report
- Folders and Files Description
- Author
- Extra
In this assignment, the program is required to develop a simple ChatGPT application by applying the simplest QA approach. The search for the most similar question to the question given by the user is done using the Knuth-Morris-Pratt (KMP) and Boyer-Moore (BM) string matching algorithms. Regex is used to determine the format of the question. If there is no exact match between the user's question and the questions in the database through the KMP or BM algorithms, then the chatbot will use the most similar question with at least 90% similarity. If there is no question with a similarity above 90%, then the chatbot will provide a maximum of 3 options for the most similar questions to be selected by the user. The similarity calculation is calculated using Levenshtein Distance. This application should also have several features such as text questions, calculator, date feature, add question and answer to the database, and delete question from the database. The classification is done using regex and is classified like everyday language.
Aspect | Required Program | Reference Link |
---|---|---|
Backend | Go (Golang) | Go (Golang) |
Go Fiber | Go Fiber | |
Air | Air | |
PostgreSQL | PostgreSQL | |
Docker | Docker | |
Frontend | ReactJS | ReactJS |
Chakra UI | ChakraUI |
- Change the current directory to
backend
folder
cd backend
- Make .env file with this criteria
DB_HOST = db
DB_USERNAME = username
DB_NAME = your_db_name
DB_PASSWORD = password
- Compose your docker containers
Your local server should serve at port 5000 for the backend services and port 5432 for the Postgres database
docker compose up
- Interract with Endpoints (Look up the documentation)
https://docs.google.com/document/d/1_3Z_u122nycifeYYGF1Ud6ceMrI4KzqmiWVB5Tq0-vA/edit?usp=sharing
- Change the current directory to
frontend
folder
cd frontend
- Install node modules and dependencies
npm install
- Start the program
The program should be automatically opened in a new browser tab. However, in case it does not, you can access the running program onlocalhost:3000
npm start
Features | Yes | No |
---|---|---|
Adding questions and answers to database | ✓ | |
Removing questions and answers to database | ✓ | |
Mathematical calculation queries | ✓ | |
Date-related queries | ✓ | |
Queries with multiple questions and multiple answers | ✓ | |
Play games with the bot | ✓ |
Backend
├───algorithms
│ ├───calculator
| ├───calculator.go
| └───deque.go
│ ├───date
| ├───date.go
│ └───utils
| ├───boyer_moore.go
| ├───knuth_morris_pratt.go
| └───levenshtein_distance.go
├───cmd
| ├───main.go
| └───routes.go
├───database
| └───database.go
├───extra
| ├───random_pick.go
| └───rock_paper_scissor.go
├───handlers
│ ├───chat_session
| ├───create_chat_session.go
| ├───delete_chat_session.go
| └───get_chat_session.go
│ ├───messages
| ├───get_chat_messages.go
| └───message_handler.go
│ ├───query_utils
| ├───query_utils.go
│ ├───question_answer
| └───get_qa.go
│ └───user_query
| ├───qa_regex_handler.go
| └───qa_string_matching_handler.go
├───models
| ├───message.go
| ├───question_answer.go
| └───session.go
├───test
| ├───boyermoore_test.go
| ├───calculator_test.go
| ├───levenshtein_test.go
| ├───random_pick_test.go
| └───rps_test.go
├───.air.toml
├───.env
├───docker-compose.yml
├───Dockerfile
├───go.mod
└───go.sum
Name | Student ID | Role / Job Desk |
---|---|---|
Juan Christopher Santoso | 13521116 | Fullstack Developer |
Nicholas Liem | 13521135 | Backend Developer |
Nathania Calista Djunaedi | 13521139 | Frontend Developer |
This repository is used to deploy the backend part of the website. However, the frontend part is not deleted from this repository to facilitate local deployment. The repository used to deploy the frontend part of the program can be accessed through this link.