Last active
May 16, 2022 14:51
-
-
Save cbc02009/2db21c1810912218ee0de136be979645 to your computer and use it in GitHub Desktop.
code example for adding guesses to list of titles and authors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct BookInfo { | |
pub titles: Vec<String>, | |
pub authors: Vec<String>, | |
} | |
fn populate_book_info(file_name: &str) -> BookInfo { | |
//binfo may have entries in titles or authors | |
//depending on regex results | |
let mut binfo = BookInfo::from(file_name); | |
let title = binfo.titles.get(0).cloned(); | |
let auth1 = binfo.authors.get(0).cloned(); | |
let auth2 = binfo.authors.get(1).cloned(); | |
if let Some(t) = title { | |
if let Some(k) = translate_kana(&*t) { | |
binfo.authors.push(k); | |
} | |
if let Some(k) = translate_kanji(&*t) { | |
binfo.authors.push(k); | |
} | |
} | |
if let Some(a1) = auth1 { | |
if let Some(k) = translate_kana(&*a1) { | |
binfo.authors.push(k); | |
} | |
if let Some(k) = translate_kanji(&*a1) { | |
binfo.authors.push(k); | |
} | |
} | |
if let Some(a2) = auth2 { | |
if let Some(k) = translate_kanji(&*a2) { | |
binfo.authors.push(k); | |
} | |
if let Some(k) = translate_kanji(&*a2) { | |
binfo.authors.push(k); | |
} | |
} | |
binfo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment