self._label_to_str+=line[:-1]# remove the line ending
self._str_to_label[line[:-1]]=self._size
self._size+=1
defstring_from_label(self,label):
returnself._label_to_str[label]
deflabel_from_string(self,string):
try:
returnself._str_to_label[string]
exceptKeyErrorase:
raiseKeyError(
'''ERROR: Your transcripts contain characters which do not occur in data/alphabet.txt! Use util/check_characters.py to see what characters are in your {train,dev,test}.csv transcripts, and then add all these to data/alphabet.txt.'''