def _get_lexicon_html(self, terms):
     lexicon_html = ''
     for i, term in enumerate(terms):
         lexicon_html += '<b>' + ClickableTerms.get_clickable_term(term, self.term_plot_interface) + '</b>'
         if self.include_category_labels:
             category = self.category_projection.category_counts.loc[term].idxmax()
             lexicon_html += (
                     ' (<i>%s</i>)' %
                     ClickableTerms.get_clickable_term(category, self.category_plot_interface,
                                                       self.term_plot_interface))
         if i != len(terms) - 1:
             lexicon_html += ',\n'
     return lexicon_html
 def _get_lexicon_html(self, terms):
     lexicon_html = ''
     for i, term in enumerate(terms):
         lexicon_html += '<b>' + ClickableTerms.get_clickable_term(term, self.term_plot_interface) + '</b>'
         if self.include_category_labels:
             category = self.category_projection.category_counts.loc[term].idxmax()
             lexicon_html += (
                     ' (<i>%s</i>)' %
                     ClickableTerms.get_clickable_term(category, self.category_plot_interface,
                                                       self.term_plot_interface))
         if i != len(terms) - 1:
             lexicon_html += ',\n'
     return lexicon_html
Esempio n. 3
0
    def get_graph(self):


        table = '<div class="timelinecontainer"><table class="timelinetable">'
        table += '<tr><th>' + '</th><th>'.join(sorted(self.corpus.get_categories())) + '</th></tr>'
        min_font_size = 7
        max_font_size = 20
        display_df = self.rank_df[lambda df: df.Rank < self.num_rows]

        bin_boundaries = np.histogram_bin_edges(
            np.log(display_df.Frequency), bins=max_font_size - min_font_size
        )
        display_df['FontSize'] = display_df.Frequency.apply(np.log).apply(
            lambda x: bisect_left(bin_boundaries, x) + min_font_size
        )

        for rank, group_df in display_df.groupby('Rank'):
            table += '<tr><td class="clickabletd">' + '</td><td class="clickabletd">'.join([
                ClickableTerms.get_clickable_term(
                    row.Term,
                    style="font-size: " + str(row.FontSize)
                )
                for _, row in group_df.sort_values(by='Category').iterrows()
            ]) + '</td></tr>'
        table += '</table></div>'
        return table