-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo_cut.py
37 lines (31 loc) · 1.26 KB
/
demo_cut.py
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
29
30
31
32
33
34
35
36
37
from Text_Annotation import Data_process
from Text_Annotation.train import train_annotation
from Text_Annotation.demo import annotate_cut
import pickle
import os
DIR = os.path.dirname(os.path.abspath(__file__))
params = {
'model': 'crf',
'num_units': 128,
'num_layers': 2,
'num_tags': 5,
}
data_process = Data_process()
texts_seq, target = data_process.data_transform(len_min=0,
len_max=20,
num_words=5000,
num=300000,
file='chat')
with open(DIR + '/model/%s/model_cut/data_process.pkl' % (params['model']), mode='wb') as f:
pickle.dump(data_process, f)
train_annotation(x=texts_seq,
y=target,
num_words=data_process.num_words,
batchsize=64,
epoch=1,
max_seq_len=data_process.max_seq_len,
model_path=DIR + '/model/%s/model_cut/' % (params['model']),
**params)
annotate_cut(data_process_path=DIR + '/model/%s/model_cut/data_process.pkl' % (params['model']),
model_path=DIR + '/model/%s/model_cut/' % (params['model']),
**params)