drepr/old_code/prototype/drepr/query/selection_interface.py
def align_with_semantic_model(self, sm: SemanticModel):
        """align the selection graph with semantic models"""
        self.optimize()

        mappings = align2graphs(sm.graph, self.graph)
        assert len(mappings) == 1, "Haven't handle when there are more than 1 mapping"
        mapping = mappings[0]
        assert get_mapping_score(sm.graph, self.graph, mapping) == 1

        self.graph = nx.relabel_nodes(self.graph, mapping)
        for n in self.graph.nodes:
            if not self.graph.nodes[n]['is_class_node']:
                self.graph.nodes[n]['label'] = n

        self.main_node = self.graph.nodes[mapping[str(self.main_node)]]['original']
align the selection graph with semantic models
align the selection graph with semantic models
align the selection graph with semantic models
def align_with_semantic_model(self, sm: SemanticModel):
        self.optimize()
        mappings = align2graphs(sm.graph, self.graph)
        assert len(mappings) == 1, "Haven't handle when there are more than 1 mapping"
        mapping = mappings[0]
        assert get_mapping_score(sm.graph, self.graph, mapping) == 1
        self.graph = nx.relabel_nodes(self.graph, mapping)
        for n in self.graph.nodes:
            if not self.graph.nodes[n]['is_class_node']:
                self.graph.nodes[n]['label'] = n
        self.main_node = self.graph.nodes[mapping[str(self.main_node)]]['original']
def align_with_semantic_model ( self , sm : SemanticModel ) : self . optimize ( ) mappings = align2graphs ( sm . graph , self . graph ) assert len ( mappings ) == 1 , "Haven't handle when there are more than 1 mapping" mapping = mappings [ 0 ] assert get_mapping_score ( sm . graph , self . graph , mapping ) == 1 self . graph = nx . relabel_nodes ( self . graph , mapping ) for n in self . graph . nodes : if not self . graph . nodes [ n ] [ 'is_class_node' ] : self . graph . nodes [ n ] [ 'label' ] = n self . main_node = self . graph . nodes [ mapping [ str ( self . main_node ) ] ] [ 'original' ]
align the selection graph with semantic models
align the selection graph with semantic models
"""align the selection graph with semantic models"""
self
sm
SemanticModel