    def ensure_text(self) -> str:
        """
        Return the `text` field, raising an exception if it's `None`.
        """
        if self.text is None:
            raise ValueError("Unexpected null text for token")
        else:
            return self.text
Return the `text` field, raising an exception if it's `None`.
allennlp/data/tokenizers/token_class.py