| 1 |
|
| 2 |
|
| 3 |
l |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
import sys |
| 19 |
import mmap |
| 20 |
import argparse |
| 21 |
import shutil |
| 22 |
import os |
| 23 |
from os import O_RDONLY, O_RDWR, O_WRONLY, O_TRUNC, O_CREAT, SEEK_END, SEEK_CUR, SEEK_SET |
| 24 |
|
| 25 |
def main(argc, argv): |
| 26 |
if argc < 2: |
| 27 |
print('Summary: add file to the corpus ', file=sys.stderr) |
| 28 |
print(f'Usage: {argv[0]} -c <corpus_dir>', file=sys.stderr) |
| 29 |
exit(1) |
| 30 |
|
| 31 |
ap = argparse.ArgumentParser() |
| 32 |
|
| 33 |
|
| 34 |
ap.add_argument("-c", "--corpus_dir", required=True, |
| 35 |
help="corpus directory where to add the file") |
| 36 |
args = vars(ap.parse_args()) |
| 37 |
|
| 38 |
|
| 39 |
lang_list=os.getenv("FUZZ_VOICE") |
| 40 |
if(lang_list): |
| 41 |
list=lang_list+"_list" |
| 42 |
else: |
| 43 |
list="en_list" |
| 44 |
output_name = list+"_dict_corpus.txt" |
| 45 |
output_path=args['corpus_dir']+output_name |
| 46 |
output= open(output_path, "w") |
| 47 |
|
| 48 |
path="../../dictsource/"+list |
| 49 |
|
| 50 |
|
| 51 |
file = open( path, "r") |
| 52 |
lines=file.readlines() |
| 53 |
index=1 |
| 54 |
for line in lines: |
| 55 |
if line[0]=='/' and line[1]=='/': |
| 56 |
continue |
| 57 |
res = line.split() |
| 58 |
if len(res): |
| 59 |
output.write("kw") |
| 60 |
output.write(str(index)) |
| 61 |
index=index+1 |
| 62 |
output.write("=") |
| 63 |
output.write(res[0]) |
| 64 |
output.write('\n') |
| 65 |
file.close() |
| 66 |
output.close() |
| 67 |
if __name__ == "__main__": |
| 68 |
main(len(sys.argv), sys.argv) |