mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 10:16:34 +00:00
Dev: word template extractor
This commit is contained in:
parent
9459f7438c
commit
fab8a2574f
46
dev_tools/word_template_extractor.py
Normal file
46
dev_tools/word_template_extractor.py
Normal file
@ -0,0 +1,46 @@
|
||||
import re
|
||||
|
||||
from dev_tools.slpp import slpp
|
||||
|
||||
"""
|
||||
This file is used to extract `word_template.lua`, aka, the blacklist words file.
|
||||
|
||||
Git clone the repository here, https://github.com/Dimbreath/AzurLaneData, to get the decrypted scripts.
|
||||
Then put your filepath here, like `<your_folder>/<server>/sharecfg/word_template.lua`
|
||||
Server list: en-US, ja-JP, ko-KR, zh-CN, zh-TW
|
||||
"""
|
||||
file = ''
|
||||
count = 0
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
text = f.read()
|
||||
|
||||
|
||||
def extract(dic, word_list):
|
||||
"""
|
||||
Args:
|
||||
dic (dict):
|
||||
word_list (list[str]):
|
||||
"""
|
||||
global count
|
||||
for word, data in dic.items():
|
||||
word = str(word)
|
||||
if data.get('this', False):
|
||||
new = word_list + [word]
|
||||
new = ''.join(new)
|
||||
count += 1
|
||||
print(new)
|
||||
else:
|
||||
new = word_list + [word]
|
||||
extract(data, word_list=new)
|
||||
|
||||
|
||||
# CN server
|
||||
for result in re.findall('word_template = (.*?)return', text, re.DOTALL):
|
||||
pg = slpp.decode(result)
|
||||
extract(pg, word_list=[])
|
||||
# Other server
|
||||
for result in re.findall('uv0\.{0,1}(.*?)end', text, re.DOTALL):
|
||||
pg = slpp.decode('{%s}' % result)
|
||||
extract(pg, word_list=[])
|
||||
|
||||
print(f'Total count: {count}')
|
Loading…
Reference in New Issue
Block a user