Update: 初学记、佩文韵府 and 五车韵瑞
This commit is contained in:
24
佩文韵府/fix_remaining.py
Normal file
24
佩文韵府/fix_remaining.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import json
|
||||
|
||||
print("Loading...")
|
||||
with open('peiwenyunfu.json', 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
for rhyme, r_data in data.items():
|
||||
if rhyme in ["metadata", "preface"]: continue
|
||||
|
||||
if "对语" in r_data and r_data["对语"]:
|
||||
r_data["对语"] = r_data["对语"].replace("丨", rhyme)
|
||||
if "摘句" in r_data and r_data["摘句"]:
|
||||
r_data["摘句"] = r_data["摘句"].replace("丨", rhyme)
|
||||
|
||||
if "词条" in r_data:
|
||||
new_citiao = {}
|
||||
for word, content in r_data["词条"].items():
|
||||
new_word = word.replace("丨", rhyme)
|
||||
new_citiao[new_word] = content
|
||||
r_data["词条"] = new_citiao
|
||||
|
||||
with open('peiwenyunfu.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
print("Done!")
|
||||
Reference in New Issue
Block a user