https://github.com/hectorpulido/human-language-toolkit-chatbot
nltk like chatbot in rust
https://github.com/hectorpulido/human-language-toolkit-chatbot
ai chatbot hlp human-language-toolkit nlp
Last synced: 10 months ago
JSON representation
nltk like chatbot in rust
- Host: GitHub
- URL: https://github.com/hectorpulido/human-language-toolkit-chatbot
- Owner: HectorPulido
- License: mit
- Created: 2021-06-13T08:17:34.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-13T08:51:49.000Z (about 5 years ago)
- Last Synced: 2025-07-29T02:52:01.863Z (11 months ago)
- Topics: ai, chatbot, hlp, human-language-toolkit, nlp
- Language: Rust
- Homepage: https://crates.io/crates/human_language_toolkit_chatbot
- Size: 12.7 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HLTK chatbot
This is a regex powered chatbot made in rust, it is based in NLTK https://github.com/nltk/nltk/blob/develop/nltk/chat/util.py
## How to install
add to your Cargo.toml file
```
[dependencies]
...
human_language_toolkit_chatbot = "0.1.0"
...
```
You can find the updated version at https://crates.io/crates/human_language_toolkit_chatbot
## How to use it
You can read from a json file.
``` Rust
use human_language_toolkit_chatbot::{Chatbot, ChatbotError, CompiledChatbot};
...
let suntsu = Chatbot::from_file(String::from("bots/suntsu.json")).unwrap();
...
```
Also you can create the bot by programming.
``` Rust
...
let mut pairs: Vec<(String, Vec)> = Vec::new();
pairs.push((
String::from(r"Hello(.*)"),
vec![
String::from("Hello... I'm glad you could drop by today."),
String::from("Hi there... how are you today?"),
String::from("Hello, how are you feeling today?"),
],
));
pairs.push((
String::from(r"(.*) sorry (.*)"),
vec![
String::from("There are many times when no apology is needed."),
String::from("What feelings do you have when you apologize?"),
],
));
...
let fallback = vec![String::from("Sorry I didn't understand")];
let reflections = Chatbot::default_reflections();
let eliza = Chatbot {
pairs,
fallback,
reflections,
};
// You can save your model in a .json file
match eliza.to_file(String::from("bots/eliza.json")) {
Ok(_) => (),
Err(e) => println!("error at {}", e),
}
let eliza = eliza.compile();
```
You can talk with the bot with the function `respond` but you can also use the `converse` function to make an infinity conversation.
Let's connect 😋