Unverified Commit d2a7c86d authored by Malte's avatar Malte Committed by GitHub
Browse files

Check if `text` is set to avoid IndexError (#4209)

Fix for https://github.com/huggingface/transformers/issues/3809
parent 90f4b245
...@@ -236,7 +236,7 @@ class RobertaTokenizer(GPT2Tokenizer): ...@@ -236,7 +236,7 @@ class RobertaTokenizer(GPT2Tokenizer):
add_prefix_space = kwargs["add_prefix_space"] add_prefix_space = kwargs["add_prefix_space"]
else: else:
add_prefix_space = add_special_tokens add_prefix_space = add_special_tokens
if add_prefix_space and not text[0].isspace(): if add_prefix_space and len(text) > 0 and not text[0].isspace():
text = " " + text text = " " + text
return text return text
......
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