-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_char_new_lines.py
67 lines (56 loc) · 1.52 KB
/
add_char_new_lines.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
import os
all_characters = {
"LE DOCTEUR STOCKMANN",
"MADAME STOCKMANN",
"PETRA",
"EILIF",
"MORTEN",
"LE BOURGMESTRE",
"MORTEN KILL",
"HOVSTAD",
"MADAME BILLING",
"HORSTER",
"ASLAKSEN",
"Didascalie",
}
def add_linebreak_after_char(scene_file_name):
print(f"scene {scene_file_name}")
with open(os.path.join("transcriptions", scene_file_name)) as f:
file_content = f.read()
for character in all_characters:
for plop in [". -", " -", " .-", ".-", " . -", "-", " ."]:
file_content = file_content.replace(character + plop, character + "\n-")
with open(os.path.join("transcriptions", scene_file_name), "w") as f:
f.write(file_content)
def main():
scenes = [
# "acte_1_part_1",
# "acte_1_part_2",
# "acte_1_part_3",
# "acte_1_part_4",
# "acte_2_part_1",
# "acte_2_part_2",
# "acte_2_part_3",
# "acte_2_part_4",
# "acte_2_part_5",
# "acte_3_part_1",
# "acte_3_part_2",
# "acte_3_part_3",
# "acte_3_part_4",
# "acte_4_part_1",
# "acte_4_part_2",
# "acte_4_part_3",
# "acte_5_part_1",
# "acte_5_part_2",
# "acte_5_part_3",
# "acte_5_part_4",
"acte_5_part_5",
]
scene_file_names = [
f"{scene}.txt"
for scene in scenes
]
for scene_file_name in scene_file_names:
add_linebreak_after_char(scene_file_name)
if __name__ == '__main__':
main()