def parse_node()

in src/graph_notebook/network/sparql/SPARQLNetwork.py [0:0]


    def parse_node(self, node_id: str, node_binding: dict = None, data: dict = None):
        """
        overriding parent add_node class to automatically parse the uri for a node
        and add data to the node for prefix and shortened name
        :param node_id: the full uri
        :param node_binding: the subject or object binding, in dict form
        :param data: dict to set node initial node properties
        """
        if data is None:
            data = {}
        if self.display_property:
            label = self.get_node_property_value(node_binding, self.display_property, data=data)
            if label:
                title, label = self.strip_and_truncate_label_and_title(label, self.label_max_length)
                data['label'] = label
                data['title'] = title
        if self.tooltip_property and self.tooltip_property != self.display_property:
            tooltip_raw = self.get_node_property_value(node_binding, self.tooltip_property, data=data)
            if tooltip_raw:
                title, label_plc = self.strip_and_truncate_label_and_title(tooltip_raw)
                data['title'] = title
        if 'label' not in data:
            data = self.generate_node_label_title(node_id=node_id, data=data)
        if self.ignore_groups or not node_binding:
            node_group = DEFAULT_GRP
        elif str(self.group_by_property) == DEFAULT_RAW_GRP_KEY:
            node_group = str(node_binding)
        else:
            node_group = None
            node_type = self.get_node_class(data)
            if isinstance(self.group_by_property, dict):
                # if rdf:type or similar node class identifier does not exist on the node, set group to the default.
                if node_type:
                    try:
                        if node_type in self.group_by_property:
                            group_by_for_type = self.group_by_property[node_type]
                            if group_by_for_type == DEFAULT_RAW_GRP_KEY:
                                node_group = str(node_binding)
                            elif group_by_for_type[:2] == "P." and 'properties' in data:
                                node_group = self.retrieve_object_property_value(group_by_for_type[2:],
                                                                                 data['properties'])
                            else:
                                node_group = node_binding[group_by_for_type]
                        else:
                            node_group = node_type
                    except KeyError:
                        node_group = node_type
                else:
                    node_group = DEFAULT_GRP
            elif self.group_by_property[:2] == "P." and 'properties' in data:
                node_group = self.retrieve_object_property_value(self.group_by_property[2:],
                                                                 data['properties'])
            elif self.group_by_property in node_binding:
                node_group = node_binding[self.group_by_property]

            if not node_group:
                if node_type:
                    node_group = node_type
                else:
                    node_group = DEFAULT_GRP
        data['group'] = str(node_group)

        self.add_node(node_id=node_id, data=data)