-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse.py
87 lines (76 loc) · 2.23 KB
/
analyse.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# pylint: disable=W,C,R
import json
f_old = open('./Episode_1/transcript_95.json')
f_new = open('./Episode_2200/transcript_95.json')
data_old = json.load(f_old)
data_new = json.load(f_new)
toAnalyze_EP_1 = {
"data" : []
}
toAnalyze_EP_2200 = {
"data" : []
}
def wordOfInterest(word):
# F+
if word.endswith("わ"):
return "F+"
if word.endswith("わよ"):
return "F+"
if word.endswith("わね"):
return "F+"
if word.endswith("だわ"):
return "F+"
if word.endswith("かしら"):
return "F+"
# F
if word.endswith("の"):
return "F"
if word.endswith("のよ"):
return "F"
if word.endswith("のね"):
return "F"
if word.endswith("てね"):
return "F"
if word.endswith("でしょう"):
return "F"
# NN
if word.endswith("ね"):
return "NN"
if word.endswith("よ"):
return "NN"
if word.endswith("もん"):
return "NN"
if word.endswith("さ"):
return "NN"
if word.endswith("かな"):
return "NN"
# M
if word.endswith("だろう"):
return "M"
# M+
if word.endswith("ぜ"):
return "M+"
if word.endswith("ぞ"):
return "M+"
if word.endswith("な"):
return "M+"
if word.endswith("かよ"):
return "M+"
return ""
for part in data_old["parts"]:
for word in part["words"]:
level = wordOfInterest(str(word["word"].partition('|')[0]))
if level != "":
toAnalyze_EP_1["data"].append({"sfp" : str(word["word"].partition('|')[0]), "level" : level, "start_time" : word["start_time"][:-7]})
for part in data_new["parts"]:
for word in part["words"]:
level = wordOfInterest(str(word["word"].partition('|')[0]))
if level != "":
toAnalyze_EP_2200["data"].append({"sfp" : str(word["word"].partition('|')[0]), "level" : level, "start_time" : word["start_time"][:-7]})
#print(toAnalyze_old)
#print("")
#print(toAnalyze_new)
with open("./Episode_1/toAnalyze_EP_1.json", "w") as j:
json.dump(toAnalyze_EP_1, j, ensure_ascii=False)
with open("./Episode_2200/toAnalyze_EP_2200.json", "w") as j:
json.dump(toAnalyze_EP_2200, j, ensure_ascii=False)