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
|
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) {
|
match si_pron().get(thecase) {
|
||||||
Some(case) =>
|
Some(case) =>
|
||||||
match case.get(word) {
|
match case.get(word) {
|
||||||
Some(sing) =>
|
Some(sing) =>
|
||||||
match sing.get(gender) {
|
match sing.get(gender.unwrap_or("N/A")) {
|
||||||
Some(specific) => specific.clone(),
|
Some(specific) => specific.clone(),
|
||||||
None => sing.clone().values().next().unwrap().clone(),
|
None => sing.clone().values().next().unwrap().clone(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ fn test_bysize() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_si_pron() {
|
fn test_si_pron() {
|
||||||
assert_eq!("him", get_si_pron("acc", "them", "masculine"));
|
assert_eq!("him", get_si_pron("acc", "them", Some("masculine")));
|
||||||
assert_eq!("her", get_si_pron("acc", "them", "feminine"));
|
assert_eq!("her", get_si_pron("acc", "them", Some("feminine")));
|
||||||
assert_eq!("it", get_si_pron("acc", "them", "neuter"));
|
assert_eq!("it", get_si_pron("acc", "them", Some("neuter")));
|
||||||
assert_eq!("themselves", get_si_pron("acc", "itself", "themselves"));
|
assert_eq!("themselves", get_si_pron("acc", "itself", None));
|
||||||
assert_ne!("him", get_si_pron("acc", "them", "feminine"));
|
assert_ne!("him", get_si_pron("acc", "them", Some("feminine")));
|
||||||
assert_ne!("her", get_si_pron("acc", "them", "masculine"));
|
assert_ne!("her", get_si_pron("acc", "them", Some("masculine")));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue