def _check_is_max_context(doc_spans, cur_span_index, position):
<EOL>best_score = None<EOL>best_span_index = None<EOL>for (span_index, doc_span) in enumerate(doc_spans):<EOL><INDENT>end = doc_span.start + doc_span.length - <NUM_LIT:1><EOL>if position < doc_span.start:<EOL><INDENT>continue<EOL><DEDENT>if position > end:<EOL><INDENT>continue<EOL><DEDENT>num_left_context = position - doc_span.start<EOL>num_right_context = end - position<EOL>score = min(num_left_context, num_right_context) +<NUM_LIT> * doc_span.length<EOL>if best_score is None or score > best_score:<EOL><INDENT>best_score = score<EOL>best_span_index = span_index<EOL><DEDENT><DEDENT>return cur_span_index == best_span_index<EOL>
Check if this is the 'max context' doc span for the token.