drepr/old_code/prototype/drepr/services/ra_executor/planner_misc.py
def select_start_data_node(repr: Representation, sg: SelectionGraph, u: str) -> Variable:
    """Return a data node, which number of values are equal to number of instances of class `u`"""
    best_node = None
    best_non_optional_node = None

    for v in sg.graph.successors(u):
        if not sg.graph.nodes[v]['is_class_node']:
            if best_node is None:
                best_node = repr.get_variable(v)
            elif best_node.cmp_size(repr.get_variable(v)) > 0:
                best_node = repr.get_variable(v)

            if not sg.graph.edges[u, v]['is_optional']:
                if best_non_optional_node is None:
                    best_non_optional_node = repr.get_variable(v)
                elif best_non_optional_node.cmp_size(repr.get_variable(v)) > 0:
                    best_non_optional_node = repr.get_variable(v)

    assert best_non_optional_node.cmp_size(best_node) == 0, "we cannot have optional on uri properties"
    return best_non_optional_node
Return a data node, which number of values are equal to number of instances of class `u`
Return a data node, which number of values are equal to number of instances of class `u`
Return a data node which number of values are equal to number of instances of class ` u `
def select_start_data_node(repr: Representation, sg: SelectionGraph, u: str) -> Variable:
    best_node = None
    best_non_optional_node = None
    for v in sg.graph.successors(u):
        if not sg.graph.nodes[v]['is_class_node']:
            if best_node is None:
                best_node = repr.get_variable(v)
            elif best_node.cmp_size(repr.get_variable(v)) > 0:
                best_node = repr.get_variable(v)
            if not sg.graph.edges[u, v]['is_optional']:
                if best_non_optional_node is None:
                    best_non_optional_node = repr.get_variable(v)
                elif best_non_optional_node.cmp_size(repr.get_variable(v)) > 0:
                    best_non_optional_node = repr.get_variable(v)
    assert best_non_optional_node.cmp_size(best_node) == 0, "we cannot have optional on uri properties"
    return best_non_optional_node
def select_start_data_node ( repr : Representation , sg : SelectionGraph , u : str ) -> Variable : best_node = None best_non_optional_node = None for v in sg . graph . successors ( u ) : if not sg . graph . nodes [ v ] [ 'is_class_node' ] : if best_node is None : best_node = repr . get_variable ( v ) elif best_node . cmp_size ( repr . get_variable ( v ) ) > 0 : best_node = repr . get_variable ( v ) if not sg . graph . edges [ u , v ] [ 'is_optional' ] : if best_non_optional_node is None : best_non_optional_node = repr . get_variable ( v ) elif best_non_optional_node . cmp_size ( repr . get_variable ( v ) ) > 0 : best_non_optional_node = repr . get_variable ( v ) assert best_non_optional_node . cmp_size ( best_node ) == 0 , "we cannot have optional on uri properties" return best_non_optional_node
Return a data node, which number of values are equal to number of instances of class `u`
Return a data node which number of values are equal to number of instances of class ` u `
"""Return a data node, which number of values are equal to number of instances of class `u`"""
repr
Representation
sg
SelectionGraph
u
str