年数中文只返回数字写法,不带年单位
This commit is contained in:
@@ -201,7 +201,7 @@ def arabic_to_chinese_year(num: int) -> str:
|
|||||||
|
|
||||||
|
|
||||||
# === 年数(纪年计数)转中文 ===
|
# === 年数(纪年计数)转中文 ===
|
||||||
# 规则(纪年计数体,用于"年数中文"字段):
|
# 规则(纪年计数体,用于"年数中文"字段;只返回数字写法本身,单位"年"由前端自行拼接):
|
||||||
# 1. 首位 1 → "元"(元年):民国元年、康熙元年、建元元年。
|
# 1. 首位 1 → "元"(元年):民国元年、康熙元年、建元元年。
|
||||||
# 2. 10-19 → 十、十一…十九(不写"一十")。
|
# 2. 10-19 → 十、十一…十九(不写"一十")。
|
||||||
# 3. 20-49 且十位即最高位 → 廿/卅/卌 缩写:20→廿、21→廿一、26→廿六、35→卅五、40→卌、49→卌九。
|
# 3. 20-49 且十位即最高位 → 廿/卅/卌 缩写:20→廿、21→廿一、26→廿六、35→卅五、40→卌、49→卌九。
|
||||||
@@ -909,13 +909,13 @@ def extract_era_years(text):
|
|||||||
if result.get("公元") is not None:
|
if result.get("公元") is not None:
|
||||||
result.setdefault("干支", gregorian_to_ganzhi(result["公元"]))
|
result.setdefault("干支", gregorian_to_ganzhi(result["公元"]))
|
||||||
|
|
||||||
# 年数中文:纪年计数的中文写法(廿/卅/卌、空位作〇、首位1作元)。
|
# 年数中文:纪年计数的中文写法(廿/卅/卌、空位作〇、首位1作元),只给数字写法本身、不带"年"单位。
|
||||||
# 统一在收尾处补齐,任何新增的产生"年数"的分支都会自动带上该字段。
|
# 统一在收尾处补齐,任何新增的产生"年数"的分支都会自动带上该字段。
|
||||||
for i, result in enumerate(results):
|
for i, result in enumerate(results):
|
||||||
if "年数" in result:
|
if "年数" in result:
|
||||||
results[i] = _insert_after(
|
results[i] = _insert_after(
|
||||||
result, "年数", "年数中文",
|
result, "年数", "年数中文",
|
||||||
f"{arabic_to_chinese_count(result['年数'])}年",
|
arabic_to_chinese_count(result["年数"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
# === 收尾:原文剔除标注符号;位置换算为 UTF-16 码元(JS 前端索引) ===
|
# === 收尾:原文剔除标注符号;位置换算为 UTF-16 码元(JS 前端索引) ===
|
||||||
|
|||||||
Reference in New Issue
Block a user