Last active
February 4, 2020 17:32
-
-
Save Sirsirious/6f3500aedabfeacd97db2ccf4438ae14 to your computer and use it in GitHub Desktop.
How to deal with printing and comparison with a reference-based system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[...] | |
def get(self): | |
if self.SOS: | |
return '<SOS>' | |
elif self.EOS: | |
return '<EOS>' | |
else: | |
return self._sentence_string[self.start_pos:self.end_pos] | |
# Displays the Token value in the terminal if the variable is called | |
def __repr__(self): | |
return self.get() | |
# Displays the Token value to the stdout | |
def __str__(self): | |
return self.get() | |
# Compares one token to other in a simple string-based fashion. | |
def __eq__(self, other): | |
return self.get() == other |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment