query_brickschema.py§
clean_result(data)
§
Extract the relevant part of a URI from a list of data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
List[str]
|
A list of URIs to clean. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of extracted parts from the URIs. |
Source code in brickllm/utils/query_brickschema.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
general_query(element)
§
Retrieve properties and relationships for a given element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
str
|
The element to retrieve properties and relationships for. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Dict[str, Union[str, List[str]]]]
|
Dict[str, Dict[str, Union[str, List[str]]]]: A dictionary containing properties and their constraints. |
Source code in brickllm/utils/query_brickschema.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
get_brick_definition(element_name)
§
Get the definition of an element from the Brick schema Turtle file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_name
|
str
|
The name of the element to get the definition for. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The definition of the element, or "No definition available" if not found. |
Source code in brickllm/utils/query_brickschema.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
get_query_result(query)
§
Execute a SPARQL query on the Brick schema graph and return the results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The SPARQL query to execute. |
required |
Returns:
Type | Description |
---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: A list of dictionaries representing the query results. |
Source code in brickllm/utils/query_brickschema.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
iterative_subclasses(element)
§
Iteratively find all subclasses of a given element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
str
|
The element to find subclasses for. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of subclasses. |
Source code in brickllm/utils/query_brickschema.py
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 |
|
query_properties(element)
§
Create a SPARQL query to find properties of a given element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
str
|
The element to find properties for. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The SPARQL query string. |
Source code in brickllm/utils/query_brickschema.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
query_subclass(element)
§
Create a SPARQL query to find subclasses of a given element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
str
|
The element to find subclasses for. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The SPARQL query string. |
Source code in brickllm/utils/query_brickschema.py
97 98 99 100 101 102 103 104 105 106 107 |
|
validate_ttl(ttl_file, method='pyshacl')
§
Validate a TTL file using the specified method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ttl_file
|
str
|
The TTL file to validate. |
required |
method
|
str
|
The method to use for validation. Default is 'pyshacl'. |
'pyshacl'
|
Returns:
Type | Description |
---|---|
Tuple[bool, str]
|
Tuple[bool, str]: A tuple containing a boolean indicating if the validation was successful and a validation report or error message. |
Source code in brickllm/utils/query_brickschema.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|