<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_dictionary(self):
 """ Return a dictionary of characterIds to their defining tags. """

        d = {}
        for t in self.all_tags_of_type(DefinitionTag, recurse_into_sprites = False):
            if t.characterId in d:
                #print 'redefinition of characterId %d:' % (t.characterId)
                #print '  was:', d[t.characterId]
                #print 'redef:', t
                raise ValueError('illegal redefinition of character')
            d[t.characterId] = t
        return d