From edc4e1bf6f7b17c3aa2f5980ca41182b4348580c Mon Sep 17 00:00:00 2001 From: ghlai9665 Date: Tue, 19 Apr 2022 22:02:26 -0500 Subject: [PATCH] make value checking for span_indices explicit Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> --- src/transformers/tokenization_utils_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/tokenization_utils_base.py b/src/transformers/tokenization_utils_base.py index 5a55c5dce61eae..d75b05c057866a 100644 --- a/src/transformers/tokenization_utils_base.py +++ b/src/transformers/tokenization_utils_base.py @@ -516,7 +516,7 @@ def token_to_chars(self, batch_or_token_index: int, token_index: Optional[int] = token_index = batch_or_token_index span_indices = self._encodings[batch_index].token_to_chars(token_index) - return CharSpan(*span_indices) if span_indices else None + return CharSpan(*span_indices) if span_indices is not None else None def char_to_token( self, batch_or_char_index: int, char_index: Optional[int] = None, sequence_index: int = 0