Spaces:
Sleeping
Sleeping
Eason Lu
commited on
Commit
•
3f09796
1
Parent(s):
d104403
fix regex
Browse filesFormer-commit-id: e7fbb78f006c7981e428a36557f35952a8ccad09
SRT.py
CHANGED
@@ -402,8 +402,7 @@ class SRT_script():
|
|
402 |
for word in keywords:
|
403 |
for i, seg in enumerate(self.segments):
|
404 |
if word in seg.source_text.lower():
|
405 |
-
seg.source_text = re.sub(
|
406 |
-
# seg.source_text = seg.source_text.lower().replace(word, term_enzh_dict.get(word))
|
407 |
logging.info("replace term: " + word + " --> " + term_enzh_dict.get(word) + " in time stamp {}".format(i+1))
|
408 |
logging.info("source text becomes: " + seg.source_text)
|
409 |
|
|
|
402 |
for word in keywords:
|
403 |
for i, seg in enumerate(self.segments):
|
404 |
if word in seg.source_text.lower():
|
405 |
+
seg.source_text = re.sub(fr"({word}es|{word}s?)\b", "{}".format(term_enzh_dict.get(word)), seg.source_text, flags=re.IGNORECASE)
|
|
|
406 |
logging.info("replace term: " + word + " --> " + term_enzh_dict.get(word) + " in time stamp {}".format(i+1))
|
407 |
logging.info("source text becomes: " + seg.source_text)
|
408 |
|