-use std::{env, ops::Add};
+use std::{
+ env::{self, VarError},
+ ops::Add,
+};
use anyhow::anyhow;
use hypher::hyphenate;
use crate::save::Save;
async fn call_inference_service(word: &str) -> anyhow::Result<String> {
- let server: Result<String, anyhow::Error> =
- env::var("PHONEMIZER").or_else(|_| Ok("http://localhost:8000/".to_string()));
- Ok(
- reqwest::get(format!("{}?grapheme={}", server.unwrap(), word))
- .await?
- .text()
- .await?,
- )
+ let server: String = env::var("PHONEMIZER")
+ .or_else(|_| Ok::<String, VarError>("http://localhost:8000/".to_string()))
+ .unwrap();
+
+ let url = reqwest::Url::parse_with_params(&server, &[("grapheme", word)])?;
+
+ Ok(reqwest::get(url).await?.text().await?)
}
impl Save<'_> {
}
// we finally just need to compute the end of the word which matches the sound
- let found = completed_syllabes.drain(i+1..).join("");
+ let found = completed_syllabes.drain(i + 1..).join("");
println!("{} is equivalent to {}", completion, found);
Ok(format!("{} ({})", found, word))