'Modify data according to the expected output.'

def add_refs(self, data):

    if self.getRefs:
        titl_re = (u'(%s)' % '|'.join([re.escape(x) for x in self._titlesRefs.keys()]))
        if (titl_re != u'()'):
            re_titles = re.compile(titl_re, re.U)
        else:
            re_titles = None
        nam_re = (u'(%s)' % '|'.join([re.escape(x) for x in self._namesRefs.keys()]))
        if (nam_re != u'()'):
            re_names = re.compile(nam_re, re.U)
        else:
            re_names = None
        chr_re = (u'(%s)' % '|'.join([re.escape(x) for x in self._charactersRefs.keys()]))
        if (chr_re != u'()'):
            re_characters = re.compile(chr_re, re.U)
        else:
            re_characters = None
        _putRefs(data, re_titles, re_names, re_characters)
    return {'data': data, 'titlesRefs': self._titlesRefs, 'namesRefs': self._namesRefs, 'charactersRefs': self._charactersRefs}
