Crates.io | machinebox |
lib.rs | machinebox |
version | 0.5.0 |
source | src |
created_at | 2018-02-07 13:55:37.041354 |
updated_at | 2018-04-07 17:02:04.563795 |
description | A client SDK for communicating with machinebox boxes |
homepage | https://github.com/encabulators/machinebox |
repository | https://github.com/encabulators/machinebox |
max_upload_size | |
id | 50029 |
size | 100,499 |
machinebox is a Rust client for the machinebox.io suite of machines. It provides a simple means of accessing the machines, exposing common functionality to all machines as well as box-specific functionality. Each "box" or "box type" is separated into its own module and struct.
The following is a list of the modules corresponding to machinebox types and which ones have been implemented so far:
To use features, simply call the appropriate function on the corresponding box:
extern crate machinebox;
use machinebox::textbox::Textbox;
use machinebox::BoxClient;
// Make sure you actually have a textbox running here...
let tb = Textbox::new("http://localhost:8080");
let analysis = tb.check("Pay William $200 tomorrow");
if let Ok(res) = analysis {
let money = res.sentences[0].entities.iter().find(|e| e.entity_type == "money");
match money {
Some(val) => println!("You specified {}", val.text),
None => println!("You didn't indicate money"),
}
}
The above code will analyse the phrase Pay William $200 tomorrow
, flagging
tomorrow
as a date and 200
as an entity of type money
.
If you run the tests locally, you'll need RUST_TEST_THREADS=1
because the mock HTTP server
persists throughout the lifetime of the test run.