text_summarize/lib.rs
1use std::error::Error;
2use reqwest::blocking::multipart;
3const URL: &'static str = "http://esummarizer.com/main/getsummary";
4
5pub fn summarize_text(text: &str) -> Result<String, Box<dyn Error>> {
6 let form = multipart::Form::new()
7 .text("text", text.to_string())
8 .text("nbsentences", "5");
9
10 let client = reqwest::blocking::Client::new();
11 let resp = client
12 .post(URL)
13 .multipart(form)
14 .send()?;
15 let text = resp.text()?;
16 Ok(text)
17}