Compare commits
2
Commits
v0.1.0
...
20eef0c0b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20eef0c0b0
|
||
|
|
af063645c7
|
+3
-3
@@ -21,7 +21,7 @@ pub mod wikipedia_infobox_analyzer {
|
||||
}
|
||||
|
||||
/// Creates an ascii infobox out of the properties
|
||||
pub fn format_infobox_from_used_properties(name: String, properties: Vec<String>) -> String {
|
||||
pub fn format_infobox_from_used_properties(name: String, properties: Vec<u64>) -> String {
|
||||
let mut ascii_table = AsciiTable::default();
|
||||
ascii_table.set_max_width(26);
|
||||
ascii_table
|
||||
@@ -29,7 +29,7 @@ pub mod wikipedia_infobox_analyzer {
|
||||
.set_header(name)
|
||||
.set_align(Align::Left);
|
||||
|
||||
let data: Vec<Vec<&String>> = properties.iter().map(|v| vec![v]).collect();
|
||||
let data: Vec<Vec<String>> = properties.iter().map(|v| vec![format!("P{v}")]).collect();
|
||||
ascii_table.format(data)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
format_infobox_from_used_properties(
|
||||
"Earth".to_string(),
|
||||
vec!["P31".to_string(), "P361".to_string(), "P571".to_string()]
|
||||
vec![31, 361, 571]
|
||||
),
|
||||
concat![
|
||||
"┌───────┐\n",
|
||||
|
||||
+9
-5
@@ -15,14 +15,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args = Cli::from_args();
|
||||
|
||||
// Input to the program
|
||||
let qid = fetch_wiki_item_by_article_title(
|
||||
args.wikipedia_article_title,
|
||||
args.wikipedia_language_code,
|
||||
);
|
||||
let _template_file = std::fs::read_to_string(&args.infobox_template_file)?;
|
||||
let title = args.wikipedia_article_title;
|
||||
let language = args.wikipedia_language_code;
|
||||
let _template = std::fs::read_to_string(&args.infobox_template_file)?;
|
||||
|
||||
let qid = fetch_wiki_item_by_article_title(title.clone(), language.clone());
|
||||
|
||||
let properties = fetch_properties_for_wiki_item(qid);
|
||||
let table = format_infobox_from_used_properties(title.clone(), properties);
|
||||
|
||||
println!("Qid: {qid}");
|
||||
println!("Template file exists");
|
||||
println!("{table}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user