Skip to content

Commit

Permalink
Merge pull request #139 from lcnetdev/chinese_names
Browse files Browse the repository at this point in the history
Add personal name handling in Chinese.
  • Loading branch information
scossu authored Oct 13, 2024
2 parents 77169c9 + e38dafa commit 2d43865
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scriptshifter/hooks/chinese/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
2 changes: 2 additions & 0 deletions scriptshifter/tables/data/chinese.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ script_to_roman:
pre_assembly:
-
- chinese.parse_numerals_pre_assembly
-
- chinese.person_name_pre_assembly

map:
"": "ling#0 "
Expand Down

0 comments on commit 2d43865

Please sign in to comment.