-
-
Save jingning42/6050e0e3cabe4731c848 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
import sys | |
prog = re.compile(r"\\N(?:{[^{}]*})?") | |
prog2 = re.compile(r"(Dialogue: \w*,\w*:\w*:\w*.\w*,\w*:\w*:\w*.\w*,\w*,\w*,\w*,\w*,\w*,\w*,)(.*)") | |
for line in sys.stdin: | |
if line.startswith("Dialogue"): | |
mt = prog2.match(line) | |
if mt and len(mt.groups()) == 2: | |
a, b = mt.groups() | |
sp = prog.split(b) | |
if len(sp) == 2: | |
print((a+sp[0]).strip(), file=sys.stderr) | |
print((a+sp[1]).strip(), file=sys.stdout) | |
continue | |
print(line.strip(), file=sys.stderr) | |
if not re.findall(r'[\u4e00-\u9fff]+', line): | |
print(line.strip(), file=sys.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment