From e38dafa02273458b3252ce13279e8e2dbe4985ba Mon Sep 17 00:00:00 2001 From: scossu Date: Sat, 12 Oct 2024 20:15:58 -0400 Subject: [PATCH] Add personal name handling in Chinese. --- scriptshifter/hooks/chinese/__init__.py | 17 +++++++++++++++++ scriptshifter/tables/data/chinese.yml | 2 ++ 2 files changed, 19 insertions(+) diff --git a/scriptshifter/hooks/chinese/__init__.py b/scriptshifter/hooks/chinese/__init__.py index ae670a3..7f95ccd 100644 --- a/scriptshifter/hooks/chinese/__init__.py +++ b/scriptshifter/hooks/chinese/__init__.py @@ -127,3 +127,20 @@ def parse_numerals_pre_assembly(ctx): # Skip main transliterate function joining. return normalize_spacing_post_assembly(ctx) + + +def person_name_pre_assembly(ctx): + """ + Parse a personal name from a specific MARC field. + """ + if not ctx.options.get("marc_field") in ("100", "600", "700", "800"): + return + + ctx.dest_ls[0] = ctx.dest_ls[0].capitalize().strip() + ", " + ctx.dest_ls[1] = ctx.dest_ls[1].capitalize() + if len(ctx.dest_ls) > 2: + ctx.dest_ls[1] = ctx.dest_ls[1].strip() + if ctx.dest_ls[2][0] in "aeiou": + ctx.dest_ls[1] += "'" + ctx.dest_ls[1] += ctx_ls[2] + del(ctx_ls[2]) diff --git a/scriptshifter/tables/data/chinese.yml b/scriptshifter/tables/data/chinese.yml index a846713..dd668af 100644 --- a/scriptshifter/tables/data/chinese.yml +++ b/scriptshifter/tables/data/chinese.yml @@ -31,6 +31,8 @@ script_to_roman: pre_assembly: - - chinese.parse_numerals_pre_assembly + - + - chinese.person_name_pre_assembly map: "〇": "ling#0 "