Datasets:

Languages:
Chinese
Tags:
Not-For-All-Audiences
License:
File size: 5,885 Bytes
0da991e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
def get_all_files_in_directory(directory, ext=''):
    import os
    import re
    custom_sort_key_re = re.compile('([0-9]+)')

    def custom_sort_key(s):
        # 将字符串中的数字部分转换为整数,然后进行排序
        return [int(x) if x.isdigit() else x for x in custom_sort_key_re.split(s)]

    all_files = []
    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith(ext):
                file_path = os.path.join(root, file)
                all_files.append(file_path)
    return sorted(all_files, key=custom_sort_key)


def clearT():
    import unicodedata
    from opencc import OpenCC

    def full2half(input_str):
        return ''.join([unicodedata.normalize('NFKC', char) for char in input_str])

    cc = OpenCC('t2s')  # 't2s'表示繁体转简体

    def _clearT(s):
        s = cc.convert(full2half(s))
        return s.strip().replace('\n', '\\n')

    return _clearT


clearT = clearT()


# =================

a = get_all_files_in_directory(r'E:\tmp\玉响未来_\scn\scn', ext='.txt.json')
b = r'E:\tmp\玉响未来_\text'

# =================

# =================

sc = {}

_n = {
    "睦季": "睦季",
    "白": "白",
    "由岐奈": "由岐奈",
    "美陀璃": "美陀璃",
    "保安": "保安",
    "花子": "花子",
    "红河童": "红河童",
    "另一种红河童": "另一种红河童",
    "其他红河童": "其他红河童",
    "蒔奈": "莳奈",
    "人狼": "人狼",
    "莳奈": "莳奈",
    "猿妖": "猿妖",
    "フェレス": "玩偶",
    "女学生": "女学生",
    "六神石的妖异": "六神石的妖异",
    "其他妖异": "其他妖异",
    "六神石妖异": "六神石妖异",
    "古树": "古树",
    "旁边的古树": "旁边的古树",
    "更旁边的古树": "更旁边的古树",
    "大樹": "大树",
    "权现大人": "权现大人",
    "マダム・リュスト": "信",
    "男学生": "男学生",
    "龙胆": "龙胆",
    "槌渊的狮子": "槌渊的狮子",
    "村民": "村民",
    "老女": "老女",
    "乳母": "乳母",
    "乌鸦妖异": "乌鸦妖异",
    "狐狸妖异": "狐狸妖异",
    "水妖": "水妖",
    "其他水妖": "其他水妖",
    "山中妖异": "山中妖异",
    "みだり": "声音",
    "倾谈者": "倾谈者",
    "オシラサマ": "御白大人",
    "留斯特夫人": "留斯特夫人",
    "玛丽安娜": "玛丽安娜",
    "红": "红",
    "菲蕾丝": "菲蕾丝",
    "幼年红河童": "幼年红河童",
    "二人": "二人",
    "岩神": "岩神",
    "罗汉大神": "罗汉大神",
    "其他罗汉大神": "其他罗汉大神",
    "枥曲": "枥曲",
    "枥曲之女": "枥曲之女",
    "枥曲灵树": "枥曲灵树",
    "山姥": "山姥",
    "班主任": "班主任",
    "班同学": "班同学",
    "「说是突然跑出一只大猴子,好危险的ー」": "女性的声音",
    "广纪": "广纪",
    "千寻": "千寻",
    "广纪&千寻": "广纪&千寻",
    "「睦季哥哥让我们赶紧回来」": "广纪的声音",
    "但是,站在门口的却是那些孩子们。": "千寻的声音",
    "紅": "红",
    "老生老气的声音": "老生老气的声音",
    "女性的声音": "女性的声音",
    "其他女性的声音": "其他女性的声音",
    "ヤマウバ": "山姥的声音",
    "月亮大人": "月亮大人",
    "蛇哥哥": "蛇哥哥",
    "蛇弟弟": "蛇弟弟",
    "妻子锅": "妻子锅",
    "污秽者": "污秽者",
    "手紙": "手纸",
    "「这就叫姜还是老的辣啊」": "白&美陀璃",
    "警備員": "警备员",
    "穢れた者": "雄釜",
    "班同学女子A": "班同学女子A",
    "担任": "担任",
    "女学生A": "女学生A",
    "女学生B": "女学生B",
    "女学生C": "女学生C",
    "红河童们": "红河童们",
    "班同学女子B": "班同学女子B",
    "班同学女子C": "班同学女子C",
    "由岐奈&莳奈": "由岐奈&莳奈",
    "猫川の妖異長": "猫川妖异长",
    "猫川妖异长": "猫川妖异长",
    "猫川妖异A": "猫川妖异A",
    "猫川妖异B": "猫川妖异B",
    "「怎、怎么会……! 水虎大人、水虎大人……!」": "猫川妖异A&B",
    "鲤鱼奶奶": "鲤鱼奶奶",
    "一代": "一代",
    "ウスノロ": "傻大个",
    "妖異": "妖异"
}

# =================
import json

for path in a:
    name = path[path.rindex('\\'):]
    name = name[14]
    if name not in sc:
        sc[name] = []
        print(name)
    # =================

    with open(path, 'r', encoding='utf-8') as json_file:
        data = json.load(json_file)

        # =================
        for texts in data['scenes']:
            try:
                for texts in texts['texts']:
                    # print(texts)
                    n = texts[0]
                    if not n:
                        n = '旁白'
                    else:
                        if n in _n:
                            n = _n[n]
                        else:
                            _n[n] = clearT(n).replace('・', '&')
                            print(texts, n)

                    # =================
                    d = clearT(texts[2])
                    if d:
                        sc[name].append(n + ':' + d)

            except KeyError:
                if type(texts) is not dict:
                    print(texts)

# =================

for k, v in sc.items():
    if v:
        with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
            f.write('\n'.join(v))

# =================
import json
tmp = json.dumps(_n, ensure_ascii=False, indent=4)