Skip to content

Commit

Permalink
Fix pronunciations of "为"
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Feb 3, 2025
1 parent 8a18943 commit 4c36b03
Show file tree
Hide file tree
Showing 20 changed files with 1,929 additions and 1,850 deletions.
1 change: 1 addition & 0 deletions base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def file_size(p: Path) -> str:
fixed_zh: Dict[str, Ldata] = {
f"zh_{scheme}": load_json(f"fixed_zh_{scheme}", "data/fixed")
for scheme in [
"source", # 来源修正
"py", # 汉语拼音修正
"wg", # 威妥玛拼音修正
"gr", # 国语罗马字修正
Expand Down
49 changes: 49 additions & 0 deletions converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# 初始化其他自定义数据
fixed_zh_u = load_json("fixed_zh_universal", "data/fixed")
manyoganas_dict: Ldata = load_json("manyogana") # 万叶假名
wei: Ldata = load_json("wei") # 为


class ConverterError(Exception):
Expand Down Expand Up @@ -284,6 +285,54 @@ def __init__(self, data: Ldata, rep: Ldata = rep_zh, auto_cut: bool = True) -> N
super().__init__(data, rep)
self.auto_cut = auto_cut

def convert(
self,
func: Callable[[str], str],
fix_dict: Optional[Ldata] = None,
rep: Optional[Ldata] = None,
) -> Tuple[Ldata, float]:
"""转换语言数据。
Args:
func (Callable[[str], str): 字符串转换函数
fix_dict (Optional[Dict[str, str]], optional): 修复内容字典
rep (Optional[Dict[str, str]], optional): 替换格式字典
Returns:
Tuple[Dict[str, str], float): (转换结果字典,耗时秒数)
Raises:
ConversionError: 转换过程出错
"""
try:
if not rep:
rep = self.rep
input_dict = self.data
start_time = time.time()

output_dict: Ldata = {}
for k, v in input_dict.items():
try:
string = (
v.replace("为", "位")
if k in wei and func.__name__ != "to_split"
else v
)
output_dict[k] = func(string)
except Exception as e:
raise ConversionError(f"转换{k}时出现错误:{str(e)}") from e

if self.rep is rep_zh:
output_dict.update(fixed_zh_u)

if fix_dict:
output_dict.update(fix_dict)

return output_dict, time.time() - start_time

except Exception as e:
raise ConversionError(f"转换失败:{str(e)}") from e

def segment_str(self, text: str) -> List[str]:
"""根据设置分词或者直接拆分字符串。
Expand Down
5 changes: 5 additions & 0 deletions data/dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
过多 0
未找到 0
不可 0
已为 0
应为 0
位于 0
已达 0
已达成 0

海之 0
谜之 0
Expand Down
1 change: 1 addition & 0 deletions data/fixed/fixed_zh_source.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"advancements.story.enter_the_nether.title": "勇往直下",
"advancements.story.follow_ender_eye.title": "隔墙有眼",
"advancements.story.obtain_armor.title": "整装上阵",
"argument.block.property.unclosed": "方块 属性 应 以 ] 结束",
"block.minecraft.bamboo_button": "竹按钮",
"block.minecraft.bamboo_door": "竹门",
"block.minecraft.bamboo_fence": "竹栅栏",
Expand Down
3 changes: 3 additions & 0 deletions data/phrases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"为": "wéi",
"因为": "yīn wèi",
"为什么": "wèi shén me",
"谁": "shéi",
"菌": "jùn",
"菌丝": "jūn sī",
Expand Down
20 changes: 20 additions & 0 deletions data/wei.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
"advancements.adventure.play_jukebox_in_meadows.description",
"advancements.nether.charge_respawn_anchor.description",
"commands.attribute.modifier.add.success",
"commands.attribute.modifier.remove.success",
"commands.recipe.give.success.multiple",
"commands.recipe.give.success.single",
"commands.scoreboard.players.enable.success.multiple",
"commands.scoreboard.players.enable.success.single",
"commands.tag.add.success.multiple",
"commands.tag.add.success.single",
"commands.test.create.success",
"jigsaw_block.placement_priority.tooltip",
"jigsaw_block.selection_priority.tooltip",
"options.graphics.fancy.tooltip",
"options.japaneseGlyphVariants.tooltip",
"outOfMemory.message",
"pack.incompatible.confirm.new",
"pack.incompatible.confirm.old"
]
338 changes: 169 additions & 169 deletions output/zh_bpmf.json

Large diffs are not rendered by default.

116 changes: 58 additions & 58 deletions output/zh_cy.json

Large diffs are not rendered by default.

376 changes: 188 additions & 188 deletions output/zh_gr.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions output/zh_hm.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"advancements.adventure.ol_betsy.title": "扣下懸刀",
"advancements.adventure.overoverkill.description": "使用重錘一擊造成50顆心的傷害",
"advancements.adventure.overoverkill.title": "天賜良擊",
"advancements.adventure.play_jukebox_in_meadows.description": "用唱片機的音樂聲爲草甸增添生機",
"advancements.adventure.play_jukebox_in_meadows.description": "用唱片機的音樂聲位草甸增添生機",
"advancements.adventure.play_jukebox_in_meadows.title": "音樂之聲",
"advancements.adventure.read_power_from_chiseled_bookshelf.description": "使用紅石比較器獲取雕紋書架的信號強度",
"advancements.adventure.read_power_from_chiseled_bookshelf.title": "知識就是力量",
Expand Down Expand Up @@ -199,7 +199,7 @@
"advancements.nether.all_potions.title": "狂亂的雞尾酒",
"advancements.nether.brew_potion.description": "釀造一瓶藥水",
"advancements.nether.brew_potion.title": "本地釀造廠",
"advancements.nether.charge_respawn_anchor.description": "爲重生錨充滿能量",
"advancements.nether.charge_respawn_anchor.description": "位重生錨充滿能量",
"advancements.nether.charge_respawn_anchor.title": "錨没有九條命",
"advancements.nether.create_beacon.description": "建造並放置一個信標",
"advancements.nether.create_beacon.title": "帶信標回家",
Expand Down Expand Up @@ -2454,8 +2454,8 @@
"commands.attribute.failed.modifier_already_present": "實體%3$s的屬性%2$s已存在修飾符%1$s",
"commands.attribute.failed.no_attribute": "實體%s没有屬性%s",
"commands.attribute.failed.no_modifier": "實體%2$s的屬性%1$s無修飾符%3$s",
"commands.attribute.modifier.add.success": "爲實體%3$s的屬性%2$s添加了修飾符%1$s",
"commands.attribute.modifier.remove.success": "爲實體%3$s的屬性%2$s移除了修飾符%1$s",
"commands.attribute.modifier.add.success": "位實體%3$s的屬性%2$s添加了修飾符%1$s",
"commands.attribute.modifier.remove.success": "位實體%3$s的屬性%2$s移除了修飾符%1$s",
"commands.attribute.modifier.value.get.success": "實體%3$s的屬性%2$s中修飾符%1$s值爲%4$s",
"commands.attribute.value.get.success": "實體%2$s的屬性%1$s的值爲%3$s",
"commands.ban.failed": "無變化,該玩家已被封禁",
Expand Down Expand Up @@ -2703,8 +2703,8 @@
"commands.random.roll": "%s擲出了%s(從%s到%s)",
"commands.random.sample.success": "隨機值:%s",
"commands.recipe.give.failed": "没有新配方被解鎖",
"commands.recipe.give.success.multiple": "已爲%2$s名玩家解鎖了%1$s條配方",
"commands.recipe.give.success.single": "已爲%2$s解鎖了%1$s條配方",
"commands.recipe.give.success.multiple": "已位%2$s名玩家解鎖了%1$s條配方",
"commands.recipe.give.success.single": "已位%2$s解鎖了%1$s條配方",
"commands.recipe.take.failed": "没有可遺忘的配方",
"commands.recipe.take.success.multiple": "已剥奪%2$s名玩家的%1$s條配方",
"commands.recipe.take.success.single": "已剥奪%2$s的%1$s條配方",
Expand Down Expand Up @@ -2759,8 +2759,8 @@
"commands.scoreboard.players.display.numberFormat.set.success.single": "已更改%s在%s中的數字格式",
"commands.scoreboard.players.enable.failed": "無變化,觸發器原已開啓",
"commands.scoreboard.players.enable.invalid": "只能啓用trigger類記分項",
"commands.scoreboard.players.enable.success.multiple": "已爲%2$s個實體啓用了觸發器%1$s",
"commands.scoreboard.players.enable.success.single": "已爲%2$s啓用了觸發器%1$s",
"commands.scoreboard.players.enable.success.multiple": "已位%2$s個實體啓用了觸發器%1$s",
"commands.scoreboard.players.enable.success.single": "已位%2$s啓用了觸發器%1$s",
"commands.scoreboard.players.get.null": "無法獲取%2$s的%1$s的值,其尚未被賦值",
"commands.scoreboard.players.get.success": "%1$s在%3$s記分項裏擁有%2$s分",
"commands.scoreboard.players.list.empty": "没有正被追蹤的實體",
Expand Down Expand Up @@ -2806,8 +2806,8 @@
"commands.summon.invalidPosition": "無效的召喚座標",
"commands.summon.success": "召喚了新的%s",
"commands.tag.add.failed": "對象已擁有此標籤或擁有過多標籤",
"commands.tag.add.success.multiple": "已爲%2$s個實體添加了標籤“%1$s”",
"commands.tag.add.success.single": "已爲%2$s添加了標籤“%1$s”",
"commands.tag.add.success.multiple": "已位%2$s個實體添加了標籤“%1$s”",
"commands.tag.add.success.single": "已位%2$s添加了標籤“%1$s”",
"commands.tag.list.multiple.empty": "%s個實體没有任何標籤",
"commands.tag.list.multiple.success": "%s個實體擁有共計%s項標籤:%s",
"commands.tag.list.single.empty": "%s没有標籤",
Expand Down Expand Up @@ -2859,7 +2859,7 @@
"commands.test.clear.success": "清除了%s個結構",
"commands.test.coordinates": "%s, %s, %s",
"commands.test.coordinates.copy": "單擊複製到剪貼板",
"commands.test.create.success": "已爲測試%s創建測試設置",
"commands.test.create.success": "已位測試%s創建測試設置",
"commands.test.error.no_test_containing_pos": "找不到包含%s, %s, %s的測試實例",
"commands.test.error.no_test_instances": "未找到測試實例",
"commands.test.error.non_existant_test": "測試實例%s不存在",
Expand Down Expand Up @@ -4646,10 +4646,10 @@
"jigsaw_block.levels": "層數:%s",
"jigsaw_block.name": "名稱:",
"jigsaw_block.placement_priority": "放置優先級:",
"jigsaw_block.placement_priority.tooltip": "當此拼圖方塊連接到部件時,此處即爲在更大的結構中各部件處理連接的順序\n\n部件按照優先級由高到低處理,若優先級相同,則按照插入順序處理。",
"jigsaw_block.placement_priority.tooltip": "當此拼圖方塊連接到部件時,此處即位在更大的結構中各部件處理連接的順序\n\n部件按照優先級由高到低處理,若優先級相同,則按照插入順序處理。",
"jigsaw_block.pool": "目標池:",
"jigsaw_block.selection_priority": "選擇優先級:",
"jigsaw_block.selection_priority.tooltip": "當父級片段處理連接時,此處即爲各拼圖方塊嘗試連接目標部件的順序\n\n拼圖方塊將會按照優先級由高到低處理,同級則隨機處理。",
"jigsaw_block.selection_priority.tooltip": "當父級片段處理連接時,此處即位各拼圖方塊嘗試連接目標部件的順序\n\n拼圖方塊將會按照優先級由高到低處理,同級則隨機處理。",
"jigsaw_block.target": "目標名稱:",
"jukebox_song.minecraft.11": "C418 - 11",
"jukebox_song.minecraft.13": "C418 - 13",
Expand Down Expand Up @@ -5457,7 +5457,7 @@
"options.graphics.fabulous": "極佳!",
"options.graphics.fabulous.tooltip": "%s畫質使用屏幕着色器繪製天氣、雲以及半透明方塊和水後面的粒子。\n這也許會在便攜設備和4K顯示屏上造成嚴重的性能負擔。",
"options.graphics.fancy": "高品質",
"options.graphics.fancy.tooltip": "高品質畫質會爲大多數設備平衡性能和質量\n天氣、雲和粒子可能不會在半透明方塊或水的後面顯示。",
"options.graphics.fancy.tooltip": "高品質畫質會位大多數設備平衡性能和質量\n天氣、雲和粒子可能不會在半透明方塊或水的後面顯示。",
"options.graphics.fast": "流暢",
"options.graphics.fast.tooltip": "流暢畫質將減少雨雪的可見數量。\n樹葉等方塊的透明效果將被禁用。",
"options.graphics.warning.accept": "在不受支持的情况下繼續",
Expand All @@ -5483,7 +5483,7 @@
"options.inactivityFpsLimit.minimized.tooltip": "僅在遊戲窗口最小化時限制幀率。",
"options.invertMouse": "鼠標反轉",
"options.japaneseGlyphVariants": "日本字形變體",
"options.japaneseGlyphVariants.tooltip": "在默認字體中爲CJK字符使用日本字形",
"options.japaneseGlyphVariants.tooltip": "在默認字體中位CJK字符使用日本字形",
"options.key.hold": "按住",
"options.key.toggle": "切換",
"options.language": "語言…",
Expand Down Expand Up @@ -5571,7 +5571,7 @@
"options.viewBobbing": "視角摇晃",
"options.visible": "顯示",
"options.vsync": "垂直同步",
"outOfMemory.message": "Minecraft已耗盡内存。\n\n原因可能是遊戲存在漏洞,或分配給Java虚擬機的内存過少。\n\n爲避免世界損壞,當前遊戲已退出。我們已嘗試騰出内存,讓你可以回到主菜單並繼續遊戲,但這不一定奏效。\n\n如果你再次看見此消息,請重啓遊戲。",
"outOfMemory.message": "Minecraft已耗盡内存。\n\n原因可能是遊戲存在漏洞,或分配給Java虚擬機的内存過少。\n\n位避免世界損壞,當前遊戲已退出。我們已嘗試騰出内存,讓你可以回到主菜單並繼續遊戲,但這不一定奏效。\n\n如果你再次看見此消息,請重啓遊戲。",
"outOfMemory.title": "内存溢出!",
"pack.available.title": "可用",
"pack.copyFailure": "複製包失敗",
Expand All @@ -5581,8 +5581,8 @@
"pack.dropRejected.title": "所添加的内容不是包",
"pack.folderInfo": "(請將包放在這裏)",
"pack.incompatible": "不兼容",
"pack.incompatible.confirm.new": "這個包是爲更新的Minecraft版本所打造的,在此版本可能不會正常工作。",
"pack.incompatible.confirm.old": "這個包是爲更舊的Minecraft版本所打造的,在此版本可能不會正常工作。",
"pack.incompatible.confirm.new": "這個包是位更新的Minecraft版本所打造的,在此版本可能不會正常工作。",
"pack.incompatible.confirm.old": "這個包是位更舊的Minecraft版本所打造的,在此版本可能不會正常工作。",
"pack.incompatible.confirm.title": "你確定要加載此包嗎?",
"pack.incompatible.new": "(適用於新版本的Minecraft)",
"pack.incompatible.old": "(適用於舊版本的Minecraft)",
Expand Down
Loading

0 comments on commit 4c36b03

Please sign in to comment.