Unverified Commit 8efaf8f1 authored by wlhgtc's avatar wlhgtc Committed by GitHub
Browse files

fix 'best_non_null_entry' is None error

parent 0e774e57
...@@ -573,6 +573,13 @@ def write_predictions(all_examples, all_features, all_results, n_best_size, ...@@ -573,6 +573,13 @@ def write_predictions(all_examples, all_features, all_results, n_best_size,
text="", text="",
start_logit=null_start_logit, start_logit=null_start_logit,
end_logit=null_end_logit)) end_logit=null_end_logit))
# In very rare edge cases we could only have single null prediction.
# So we just create a nonce prediction in this case to avoid failure.
if len(nbest)==1:
nbest.insert(0,
_NbestPrediction(text="empty", start_logit=0.0, end_logit=0.0))
# In very rare edge cases we could have no valid predictions. So we # In very rare edge cases we could have no valid predictions. So we
# just create a nonce prediction in this case to avoid failure. # just create a nonce prediction in this case to avoid failure.
if not nbest: if not nbest:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment