gender is optional
This commit is contained in:
parent
195dc16f3d
commit
bec968ac26
2 changed files with 8 additions and 8 deletions
|
|
@ -2136,12 +2136,12 @@ fn si_pron() -> HashMap<String, HashMap<String, HashMap<String, String>>> {
|
|||
si_pron
|
||||
}
|
||||
|
||||
pub fn get_si_pron(thecase: &str, word: &str, gender: &str) -> String {
|
||||
pub fn get_si_pron(thecase: &str, word: &str, gender: Option<&str>) -> String {
|
||||
match si_pron().get(thecase) {
|
||||
Some(case) =>
|
||||
match case.get(word) {
|
||||
Some(sing) =>
|
||||
match sing.get(gender) {
|
||||
match sing.get(gender.unwrap_or("N/A")) {
|
||||
Some(specific) => specific.clone(),
|
||||
None => sing.clone().values().next().unwrap().clone(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ fn test_bysize() {
|
|||
|
||||
#[test]
|
||||
fn test_si_pron() {
|
||||
assert_eq!("him", get_si_pron("acc", "them", "masculine"));
|
||||
assert_eq!("her", get_si_pron("acc", "them", "feminine"));
|
||||
assert_eq!("it", get_si_pron("acc", "them", "neuter"));
|
||||
assert_eq!("themselves", get_si_pron("acc", "itself", "themselves"));
|
||||
assert_ne!("him", get_si_pron("acc", "them", "feminine"));
|
||||
assert_ne!("her", get_si_pron("acc", "them", "masculine"));
|
||||
assert_eq!("him", get_si_pron("acc", "them", Some("masculine")));
|
||||
assert_eq!("her", get_si_pron("acc", "them", Some("feminine")));
|
||||
assert_eq!("it", get_si_pron("acc", "them", Some("neuter")));
|
||||
assert_eq!("themselves", get_si_pron("acc", "itself", None));
|
||||
assert_ne!("him", get_si_pron("acc", "them", Some("feminine")));
|
||||
assert_ne!("her", get_si_pron("acc", "them", Some("masculine")));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue