-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcreate_dict.py
More file actions
28 lines (21 loc) · 923 Bytes
/
create_dict.py
File metadata and controls
28 lines (21 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import pickle
from argparse import ArgumentParser
from tqdm import tqdm
import jsonlines
from krnnt.new import preprocess_paragraph_preanalyzed, \
preprocess_paragraph_reanalyzed, serialize_sample_paragraph, create_dict
from krnnt.serial_pickle import SerialPickler, SerialUnpickler
from krnnt.structure import Paragraph
if __name__ == '__main__':
parser = ArgumentParser(description='Create dictionary of features')
parser.add_argument('input_path', type=str, help='path to preprocessed data')
parser.add_argument('output_path', type=str, help='save path')
args = parser.parse_args()
file = open(args.input_path, 'rb')
su = SerialUnpickler(file)
unique_dict = create_dict(su)
with open(args.output_path, 'wb') as file:
pickle.dump(unique_dict, file)
with open(args.output_path+'.json','w') as file:
json.dump(unique_dict, file, ensure_ascii=False)