Download packages/simplecc-wasm/OpenCC/data/scripts/merge.py from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 693 Bytes
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/simplecc-wasm/OpenCC/data/scripts/merge.py
- Command line
-
hf download hf://datasets/echodict/readest/packages/simplecc-wasm/OpenCC/data/scripts/merge.py
-
curl -L -o merge.py https://huggingface.co/datasets/echodict/readest/resolve/main/packages/simplecc-wasm/OpenCC/data/scripts/merge.py
693 Bytes
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import codecs | |
| import sys | |
| from common import sort_items | |
| if len(sys.argv) < 4: | |
| print("Merge and sort all text dictionaries") | |
| print(("Usage: ", sys.argv[0], "[input1] [input2] ... [inputN] [output]")) | |
| exit(1) | |
| all_lines = [] | |
| for i in range(1, len(sys.argv) - 1): | |
| input_file = codecs.open(sys.argv[i], "r", encoding="utf-8") | |
| for line in input_file: | |
| all_lines += line | |
| input_file.close() | |
| all_lines += '\n' | |
| output_filename = sys.argv[-1] | |
| output_file = open(output_filename, "wb") | |
| for line in all_lines: | |
| output_file.write(line.encode('utf-8')) | |
| output_file.close() | |
| sort_items(output_filename, output_filename) | |