Skip to content

Commit

Permalink
expansion(kRSGeneric): Fix double apostrophe values with kRSUnicode (
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Dec 10, 2023
2 parents cd24cbc + 7a219a4 commit f21e437
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ $ pipx install --suffix=@next unihan-etl --pip-args '\--pre' --force

<!-- Maintainers, insert changes / features for the next release here -->

### Bug fix

- Expansions: Fix loading of double apostrophe values via `kRSUnicode` via `kRSGeneric` (#304)

## unihan-etl 0.30.0post0 (2023-11-26)

### CI
Expand Down
11 changes: 9 additions & 2 deletions src/unihan_etl/expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,18 @@ class kRSGenericDict(t.TypedDict):


def _expand_kRSGeneric(value: t.List[str]) -> t.List[kRSGenericDict]:
"""Expand kRSGeneric field."""
"""Expand kRSGeneric field.
Examples
--------
>>> _expand_kRSGeneric(['5.10', "213''.0"]) # doctest: +NORMALIZE_WHITESPACE
[{'radical': 5, 'strokes': 10, 'simplified': False},
{'radical': 213, 'strokes': 0, 'simplified': False}]
"""
pattern = re.compile(
r"""
(?P<radical>[1-9][0-9]{0,2})
(?P<simplified>\'?)\.
(?P<simplified>\'{0,2})\.
(?P<strokes>-?[0-9]{1,2})
""",
re.X,
Expand Down

0 comments on commit f21e437

Please sign in to comment.