Similar to this step in the original CA notebook:
Remove any time codes
This step will search for any timecodes in formats like (~0:33) and (~10:00).
before = df["text"].copy()
df["text"] = df["text"].str.replace(r'^\([\~0-9][\~0-9:\.]*\) ', '', regex=True)
df["text"] = df["text"].str.replace(r' \([\~0-9][\~0-9:\.]*\) ', ' ', regex=True)
df["text"] = df["text"].str.replace(r' \([\~0-9][\~0-9:\.]*\)$', ' ', regex=True)
df["text"] = df["text"].str.replace(r'^\([\~0-9][\~0-9:\.]*\)', '', regex=True)
df["text"] = df["text"].str.replace(r'\([\~0-9][\~0-9:\.]*\)', ' ', regex=True)
df["text"] = df["text"].str.replace(r'\([\~0-9][\~0-9:\.]*\)$', ' ', regex=True)
with open("timecodes_log.txt", "w", encoding="utf-8") as log:
for i, (b, a) in enumerate(zip(before, df["text"])):
if b != a:
log.write("CHANGED:\n")
log.write(str(b) + "\n")
log.write("→\n")
log.write(str(a) + "\n")
log.write("-" * 40 + "\n")
Another format of time stamps to optionally remove are on a separate line, e.g.
If we want to keep the time codes, we could also add an option to put this in a separate column in the csv output.
Similar to this step in the original CA notebook:
Remove any time codes
This step will search for any timecodes in formats like (~0:33) and (~10:00).
Another format of time stamps to optionally remove are on a separate line, e.g.
If we want to keep the time codes, we could also add an option to put this in a separate column in the csv output.