Skip to content

Commit

Permalink
feat: ensure earlier pairs take priority when building revconvs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowee committed Jul 4, 2023
1 parent 1b67824 commit 7c46f87
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ mod opencc {
};
}
pub(crate) use load_opencc_to;

pub fn parse_opencc_to(
out_conv: &mut HashMap<String, String>,
out_revconv: &mut HashMap<String, String>,
Expand All @@ -443,9 +442,14 @@ mod opencc {
let mut it = line.split_whitespace();
if let (Some(f), Some(t)) = (it.next(), it.next()) {
out_conv.insert(f.to_owned(), t.to_owned());
out_revconv.insert(t.to_owned(), f.to_owned());
// TODO: one-to-many mapping?
if !out_revconv.contains_key(t) {
out_revconv.insert(t.to_owned(), f.to_owned());
}
for tt in it {
out_revconv.insert(tt.to_owned(), f.to_owned());
if !out_revconv.contains_key(t) {
out_revconv.insert(tt.to_owned(), f.to_owned());
}
}
}
}
Expand Down

0 comments on commit 7c46f87

Please sign in to comment.