mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-08-08 09:32:20 +00:00
* mgb2 * mgb2 * adding pruned transducer stateless to mgb2 * update display_manifest_statistics.py * . * stateless transducer MGB-2 * Update README.md * Update RESULTS.md * Update prepare_lang_bpe.py * Update asr_datamodule.py * .nfs removed * Adding symlink * . * resolving conflicts * Update .gitignore * black formatting * Update compile_hlg.py * Update compute_fbank_musan.py * Update convert_transcript_words_to_tokens.py * Update download_lm.py * Update generate_unique_lexicon.py * adding simlinks * fixing symbolic links
38 lines
1.0 KiB
Python
Executable File
38 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Copyright 2022 Amir Hussein
|
|
# Apache 2.0
|
|
|
|
# This script prepares givel a column of words lexicon.
|
|
|
|
import argparse
|
|
|
|
|
|
def get_args():
|
|
parser = argparse.ArgumentParser(
|
|
description="""Creates the list of characters and words in lexicon"""
|
|
)
|
|
parser.add_argument("input", type=str, help="""Input list of words file""")
|
|
parser.add_argument("output", type=str, help="""output graphemic lexicon""")
|
|
args = parser.parse_args()
|
|
return args
|
|
|
|
|
|
def main():
|
|
lex = {}
|
|
args = get_args()
|
|
with open(args.input, "r", encoding="utf-8") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
characters = list(line)
|
|
characters = " ".join(["V" if char == "*" else char for char in characters])
|
|
lex[line] = characters
|
|
|
|
with open(args.output, "w", encoding="utf-8") as fp:
|
|
for key in sorted(lex):
|
|
fp.write(key + " " + lex[key] + "\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|