'If the key is not in the dictionary, add it to the dictionary and set
its frequency to value.'

def __setitem__(self, key, value):

    key = str(key)
    self.freq[key] = int(value)
    if (key not in self.tok2ind):
        index = len(self.tok2ind)
        self.tok2ind[key] = index
        self.ind2tok[index] = key
