kg_creation_utils
add_and_attach_data_entity(kg, data, top_level_kg, top_level_schema_namespace, data_entity, relation, task_entity)
¶
Adds data entity instance to kg with the necessary relations, and attaches it to the given task
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kg | Graph | Graph object to add to | required |
data | Entity | object representing top-level DataEntity class in KG | required |
top_level_kg | Graph | KG corresponding to the top-level KG schema | required |
top_level_schema_namespace | Namespace | namespace of the top-level KG schema | required |
data_entity | DataEntity | data entity to add | required |
relation | URIRef | IRI of relation to add | required |
task_entity | Task | task to attach the data entity to | required |
Source code in exe_kg_lib/utils/kg_creation_utils.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
add_data_entity_instance(kg, data, top_level_kg, top_level_schema_namespace, data_entity)
¶
Adds data entity instance to kg with the necessary relations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kg | Graph | Graph object to add to | required |
data | Entity | object representing top-level DataEntity class in KG | required |
top_level_kg | Graph | KG corresponding to the top-level KG schema | required |
top_level_schema_namespace | Namespace | namespace of the top-level KG schema | required |
data_entity | DataEntity | data entity to add | required |
Source code in exe_kg_lib/utils/kg_creation_utils.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
add_instance(kg, entity_instance)
¶
Adds entity instance to KG only if its parent entity exists and there is no instance with the same IRI
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kg | Graph | Graph object to add to | required |
entity_instance | Entity | the entity instance to create | required |
Source code in exe_kg_lib/utils/kg_creation_utils.py
15 16 17 18 19 20 21 22 23 |
|
add_instance_from_parent_with_relation(namespace, kg, parent_entity, relation_iri, related_entity, instance_name)
¶
Creates an entity object based on the arguments and calls add_instance() and add_relation() to create a new entity instance and relation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace | Namespace | namespace for the new instance | required |
kg | Graph | Graph object to add to | required |
parent_entity | Entity | parent entity for the new instance | required |
relation_iri | str | IRI that connects the given related_entity with the new instance | required |
related_entity | Entity | relation source | required |
instance_name | str | name for the new instance | required |
Returns:
Name | Type | Description |
---|---|---|
Entity | Entity | object containing the new entity instance's basic info |
Source code in exe_kg_lib/utils/kg_creation_utils.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
add_literal(kg, from_entity, relation_iri, literal)
¶
Adds relation between a given entity and a given literal to KG
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kg | Graph | Graph object to add to | required |
from_entity | Entity | relation source | required |
relation_iri | str | IRI that connects the given entity with the given literal | required |
literal | Literal | literal to add to Graph object | required |
Source code in exe_kg_lib/utils/kg_creation_utils.py
44 45 46 47 48 49 50 51 52 53 |
|
add_relation(kg, from_entity, relation_iri, to_entity)
¶
Adds relation between 2 given entities to KG
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kg | Graph | Graph object to add to | required |
from_entity | Entity | relation source | required |
relation_iri | str | IRI that connects the 2 given entities | required |
to_entity | Entity | relation destination | required |
Source code in exe_kg_lib/utils/kg_creation_utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
create_pipeline_task(top_level_schema_namespace, parent_entity, kg, pipeline_name, input_data_path)
¶
Adds instance of pipeline task to kg
Parameters:
Name | Type | Description | Default |
---|---|---|---|
top_level_schema_namespace | Namespace | namespace of the top-level KG schema | required |
parent_entity | Entity | parent entity of pipeline instance | required |
kg | Graph | Graph object to add to | required |
pipeline_name | str | name for the pipeline | required |
input_data_path | str | path for the input data to be used by the pipeline's tasks | required |
Returns:
Name | Type | Description |
---|---|---|
Task | Task | created pipeline task |
Source code in exe_kg_lib/utils/kg_creation_utils.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
name_instance(task_type_dict, method_type_dict, parent_entity)
¶
Creates a unique name for a new instance by concatenating the parent entity's name (which is the instance type) with a number Also increments the relevant number of the corresponding dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_type_dict | Dict[str, int] | contains pairs of task types and numbers | required |
method_type_dict | Dict[str, int] | contains pairs of method types and numbers | required |
parent_entity | Entity | instance's parent entity | required |
Returns:
Name | Type | Description |
---|---|---|
str | Union[None, str] | name to be given to the new instance |
None | Union[None, str] | if the type of the given parent entity is not equal with "AtomicTask" or "AtomicMethod" |
Source code in exe_kg_lib/utils/kg_creation_utils.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|