-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw_data_condenser.py
63 lines (54 loc) · 2.21 KB
/
raw_data_condenser.py
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
"""
Take all the files in raw_data (entities downloaded from https://cod.uberguy.net/html/index.html)
and cut out all the stuff we do not need. I also removed index.json.
Why do this? 19.4 MB -> 1.16 MB
I don't have any way to know how many of these can talk, or what they might say.
But we once we get a message from them, we can find them reasonably quickly to
determine the group (like 5thColumn) and gender (GENDER_MALE) and use that as
the basis for creating the voice that should be used.
Output is a json file with a bunch of entries like:
{
...
"Colonel": {
"description": "Nemesis' officers are some of the best trained soldiers in the world, and they show amazing discipline and devotion to their master. They're armed with the Nemesis lance, a long rifle that can also operate effectively as a spear. Their skill with this weapon makes them deadly at any distance.",
"gender": "GENDER_MALE",
"group_name": "Nemesis"
},
...
}
"""
import os
import json
def main():
output = {}
for filename in os.listdir("raw_data"):
with open(os.path.join("raw_data", filename), "r") as infile:
raw = infile.read()
parsed = json.loads(raw)
gender = parsed.get("gender")
if gender is None:
print(f'Entity {filename} has no gender')
group_name = parsed["defaults"].get('group_description')
if group_name in [None, '']:
group_name = parsed['group_name']
description = parsed["defaults"].get('description', '')
for variant in parsed["levels"]:
for name in variant["display_names"]:
if name in output:
print(f'Multiple entries with display name: {name}')
else:
output[name] = {
"gender": gender,
"group_name": group_name,
"description": description
}
with open('all_npcs.json', 'w') as outfile:
outfile.write(
json.dumps(
output,
indent=2,
sort_keys=True
)
)
if __name__ == '__main__':
main()