Example #1
0
    def get_word_network_graph(self,
                               centrality_dict,
                               mode="markers",
                               centrality_th=0.5,
                               weight_th=0.5,
                               ego_node_list=[],
                               node_size_rate=10,
                               edge_width_rate=10,
                               text_size_rate=10):
        tv = TextVisualizer()
        tv.set_plotly()

        if len(ego_node_list) > 0:
            edge_list = [(a, b, w) for (a, b), w in self.get_edge_list()
                         if w >= weight_th and (
                             a in ego_node_list or b in ego_node_list) and (
                                 centrality_dict[a] >= centrality_th
                                 and centrality_dict[b] >= centrality_th)]
        else:
            edge_list = [
                (a, b, w) for (a, b), w in self.get_edge_list()
                if w >= weight_th and (centrality_dict[a] >= centrality_th
                                       and centrality_dict[b] >= centrality_th)
            ]
        node_list = []
        for a, b, c in edge_list:
            #if c >= weight_th:
            if a not in node_list:
                node_list.append(a)
            if b not in node_list:
                node_list.append(b)

        data_meta = {
            "node_list": node_list,
            "edge_list": edge_list,
            "weight_dict": centrality_dict
        }

        graph_meta = {
            "title": "Word Network Graph",
            "height": 1000,
            "width": 1000,
            "weight_name": "Word Centrality",
        }

        return tv.draw_network(data_meta,
                               graph_meta,
                               mode=mode,
                               node_size_rate=node_size_rate,
                               edge_width_rate=edge_width_rate)
Example #2
0
    def get_word_network_graph(self, centrality_dict):
        tv = TextVisualizer()
        tv.set_plotly()
        data_meta = {
            "node_list": self.get_node_list(),
            "edge_list": [(a, b, w) for (a, b), w in self.get_edge_list()],
            "weight_dict": centrality_dict
        }

        graph_meta = {
            "title": "Word Network Graph",
            "height": 1000,
            "width": 1000,
            "weight_name": "Word Centrality",
        }

        return tv.draw_network(data_meta, graph_meta)
Example #3
0
 def get_wordcloud(self, weight_dict):
     tv = TextVisualizer()
     tv.set_plotly()
     data_meta = {
         "weight_dict": weight_dict,
     }
     graph_meta = {
         "height": 1000,
         "width": 1000,
         "min_font_size": 10,
         "max_font_size": 500,
         "margin": 10,
         "background_color": "white"
     }
     tv.draw_wordcloud(data_meta, graph_meta)
Example #4
0
 def draw_sentiment_parse(self, token_list, weight_list):
     tv = TextVisualizer()
     tv.set_plotly()
     return tv.draw_sentence_attention(token_list, weight_list)
Example #5
0
 def draw_sentence_weight(self, sentence):
     token_list, weight_list = self.get_weight(sentence)
     weight_list = [w**3 for w in weight_list]
     tv = TextVisualizer()
     tv.set_plotly()
     return tv.draw_sentence_attention(token_list, weight_list)