(self, exp, label, div_name, exp_object_name,
                                text=True, opacity=True)
return ret
Adds text with highlighted words to visualization.

        Args:
             exp: list of tuples [(id, weight), (id,weight)]
             label: label id (integer)
             div_name: name of div object to be used for rendering(in js)
             exp_object_name: name of js explanation object
             text: if False, return empty
             opacity: if True, fade colors according to weight
Adds text with highlighted words to visualization.
Adds text with highlighted words to visualization .
def visualize_instance_html(self, exp, label, div_name, exp_object_name,
                                text=True, opacity=True):
        """Adds text with highlighted words to visualization.

        Args:
             exp: list of tuples [(id, weight), (id,weight)]
             label: label id (integer)
             div_name: name of div object to be used for rendering(in js)
             exp_object_name: name of js explanation object
             text: if False, return empty
             opacity: if True, fade colors according to weight
        """
        if not text:
            return u''
        text = (self.indexed_string.raw_string()
                .encode('utf-8', 'xmlcharrefreplace').decode('utf-8'))
        text = re.sub(r'[<>&]', '|', text)
        exp = [(self.indexed_string.word(x[0]),
                self.indexed_string.string_position(x[0]),
                x[1]) for x in exp]
        all_occurrences = list(itertools.chain.from_iterable(
            [itertools.product([x[0]], x[1], [x[2]]) for x in exp]))
        all_occurrences = [(x[0], int(x[1]), x[2]) for x in all_occurrences]
        ret = '''
            %s.show_raw_text(%s, %d, %s, %s, %s);
            ''' % (exp_object_name, json.dumps(all_occurrences), label,
                   json.dumps(text), div_name, json.dumps(opacity))
        return ret
def visualize_instance_html ( self , exp , label , div_name , exp_object_name , text = True , opacity = True ) : if not text : return u'' text = ( self . indexed_string . raw_string ( ) . encode ( 'utf-8' , 'xmlcharrefreplace' ) . decode ( 'utf-8' ) ) text = re . sub ( r'[<>&]' , '|' , text ) exp = [ ( self . indexed_string . word ( x [ 0 ] ) , self . indexed_string . string_position ( x [ 0 ] ) , x [ 1 ] ) for x in exp ] all_occurrences = list ( itertools . chain . from_iterable ( [ itertools . product ( [ x [ 0 ] ] , x [ 1 ] , [ x [ 2 ] ] ) for x in exp ] ) ) all_occurrences = [ ( x [ 0 ] , int ( x [ 1 ] ) , x [ 2 ] ) for x in all_occurrences ] ret = '''
            %s.show_raw_text(%s, %d, %s, %s, %s);
            ''' % ( exp_object_name , json . dumps ( all_occurrences ) , label , json . dumps ( text ) , div_name , json . dumps ( opacity ) ) return ret