This commit is contained in:
bridge
2025-11-13 18:57:16 +08:00
parent 62fa84a809
commit 3a8032124f
5 changed files with 122 additions and 11 deletions

View File

@@ -130,3 +130,30 @@ def normalize_item_name(name: str) -> str:
s = s.rstrip(" -").strip()
return s
def normalize_weapon_type(name: str) -> str:
"""
规范化兵器类型名称映射到标准的WeaponType枚举值。
处理格式:
- 去除空格和多余符号
- ""/"剑类"/"剑兵器" -> ""
Args:
name: 兵器类型名称
Returns:
规范化后的兵器类型名称WeaponType.value
Examples:
>>> normalize_weapon_type("")
''
>>> normalize_weapon_type("刀类")
''
"""
s = str(name).strip()
# 移除常见后缀
for suffix in ["", "兵器", "武器"]:
if s.endswith(suffix):
s = s[:-len(suffix)].strip()
return s