clean up wikipedia extract more

This commit is contained in:
mat 2024-01-09 18:02:55 -06:00
parent d518204c87
commit 6476a0f2f8

View File

@ -74,11 +74,17 @@ pub fn parse_response(body: &str) -> eyre::Result<EngineResponse> {
return Ok(EngineResponse::new()); return Ok(EngineResponse::new());
} }
let extract = extract let mut previous_extract = "".to_string();
let mut extract = extract.clone();
while previous_extract != extract {
previous_extract = extract.clone();
extract = extract
.replace("(, ", "(")
.replace("(; ", "(") .replace("(; ", "(")
.replace("( ; ", "(") .replace("( ; ", "(")
.replace("( )", "") .replace("( )", "")
.replace("()", ""); .replace("()", "");
}
let page_title = title.replace(' ', "_"); let page_title = title.replace(' ', "_");
let page_url = format!("https://en.wikipedia.org/wiki/{page_title}"); let page_url = format!("https://en.wikipedia.org/wiki/{page_title}");