ink.base.graph.KnowledgeGraph¶
-
class
ink.base.graph.KnowledgeGraph(connector, prefixes=None, extract_inverse=False)¶ Bases:
objectKnowledge graph class representation
This graph builds and stores the internal knowledge graph representations. It stores and builds the neighborhoods of the nodes of interest through the initialized connector.
- Parameters
connector (
ink.base.connectors.AbstractConnector) – Connector instance.prefixes (list) – Optional dictionary of prefixes which should be mapped.
-
__init__(connector, prefixes=None, extract_inverse=False)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(connector[, prefixes, extract_inverse])Initialize self.
extract_neighborhoods(data, depth[, …])Function which extracts all the neighborhoods of a given set of nodes of interest.
neighborhood_request(noi)Function to make a neighborhood request of a certain instance.
-
extract_neighborhoods(data, depth, skip_list=None, verbose=False, jobs=1)¶ Function which extracts all the neighborhoods of a given set of nodes of interest.
- Parameters
data (list) – List of node of interests.
depth (int) – The maximum depth of the neighborhood.
skip_list (list) – List with relations which are not taken into account when traversing the neighborhoods.
verbose (bool) – Parameter to show tqdm tracker (default False).
- Returns
List of dictionaries containing the neighborhood until the defined depth for each instance of the dataset.
- Return type
list
-
neighborhood_request(noi)¶ Function to make a neighborhood request of a certain instance.
- Parameters
noi (str) – URI of Node Of Interest (noi).
- Returns
Dictionary with all values specified as in the connector string.
- Return type
dict