Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

Commit

Permalink
Fixed pickle encoding arguments for Python2 and Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sim Dy committed Aug 16, 2018
1 parent 90b3875 commit 4fc765d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion code/machine_learning/crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def predict(clf, X):
# Dump the model into a temp file
os_handle,tmp_file = tempfile.mkstemp(dir=tmp_dir, suffix="crf_temp")
with open(tmp_file, 'wb') as f:
clf_byte = bytearray(clf, 'latin1')
clf_byte = bytearray(clf)
f.write(clf_byte)

# Create the Tagger object
Expand Down
2 changes: 1 addition & 1 deletion code/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def generic_train(p_or_n, train_sents, train_labels, use_lstm, val_sents=None, v
print ("START TRAINING")

eval_dir = os.path.join(tmo_dir, 'cliner_eval_%d' % random.randint(0,256)+os.sep)
parameters['conll_like_result_folder']=eval_dir)
parameters['conll_like_result_folder']=eval_dir


test_temp = os.path.join(parameters['conll_like_result_folder'], 'test/')
Expand Down
2 changes: 1 addition & 1 deletion code/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def predict(files, model_path, output_dir, format, use_lstm=True):
# Load model
#if use_lstm==False:
with open(model_path, 'rb') as f:
model = pickle.load(f,encoding = 'latin1')
model = pickle.load(f)


if model._use_lstm:
Expand Down

1 comment on commit 4fc765d

@paulxshen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The silver.crf default model mentioned in the readme only works with encoding = 'latin1'

Please sign in to comment.