add ct_tn.py (#2795)

Co-authored-by: 启焚 <[email protected]>
This commit is contained in:
彭震东
2026-01-26 20:46:21 +08:00
committed by GitHub
co-authored by 启焚
parent 335eb1ea61
commit 7f9083daab
3 changed files with 1285 additions and 10 deletions
File diff suppressed because it is too large Load Diff
@@ -155,9 +155,7 @@ def ch_number2digit(line):
if line[i] in chsh:
number_flag = 1
if line[i] == "两":
if (i == len(line) - 1) or (
(line[i + 1] not in chsh.keys()) and (line[i + 1] not in bits.keys())
):
if (i == len(line) - 1) or ((line[i + 1] not in chsh.keys()) and (line[i + 1] not in bits.keys())):
number_flag = -1
if number_flag == 1:
digit.append(chsh[line[i]])
@@ -86,9 +86,7 @@ def main_hydra(cfg: DictConfig):
transcript_lines = f2.readlines()
if len(scp_lines) != len(transcript_lines):
print(
f"Warning: Line count mismatch - scp: {len(scp_lines)}, transcript: {len(transcript_lines)}"
)
print(f"Warning: Line count mismatch - scp: {len(scp_lines)}, transcript: {len(transcript_lines)}")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
processor = LineProcessor(tokenizer)
@@ -102,10 +100,7 @@ def main_hydra(cfg: DictConfig):
with tqdm(total=len(data_pairs), desc="Processing") as pbar:
with ThreadPoolExecutor(max_workers=max_workers) as executor:
with open(jsonl_file, "w") as f_out:
futures = {
executor.submit(processor.process_line, pair): i
for i, pair in enumerate(data_pairs)
}
futures = {executor.submit(processor.process_line, pair): i for i, pair in enumerate(data_pairs)}
for future in as_completed(futures):
result = future.result()