API reference¶
This page is generated automatically from maplib's docstrings using mkdocstrings. It rebuilds whenever the docs are built, so it always matches the installed version of the library.
Build requirement
mkdocstrings imports the package at build time, so maplib must be installed in the
environment that runs mkdocs build (pip install maplib).
Model¶
The single entry point. One Model is one in-memory knowledge graph (optionally with
multiple named graphs).
maplib.Model ¶
A model session allowing:
- Iterative model using OTTR templates
- Interactive SPARQL querying and enrichment
- SHACL validation
Usage:
>>> from maplib import Model
... doc = '''
... @prefix ex:<http://example.net/ns#>.
... ex:ExampleTemplate [?MyValue] :: {
... ottr:Triple(ex:myObject, ex:hasValue, ?MyValue)
... } .'''
... m = Model()
... m.add_template(doc)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
documents
|
a stOTTR document or a list of these |
required | |
indexing_options
|
IndexingOptions
|
options for indexing |
None
|
add_template ¶
Add a template to the model. Overwrites any existing template with the same IRI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
Union[Template, str]
|
The template to add, as a stOTTR string or as a programmatically constructed Template. |
required |
get_templates ¶
Return the OTTR templates currently held by the model (whether added as stOTTR or
programmatically). The built-in ottr:Triple primitive is not included.
Usage:
Returns:
| Type | Description |
|---|---|
List[Template]
|
A list of Template objects. |
templates_to_graph ¶
Materialize the model's OTTR templates into a named graph as RDF, using the flattened
maplib template vocabulary (prefix maplib, base
https://datatreehouse.github.io/maplib/vocab#). This lets template structure and
the interconnectedness of IRIs across templates be inspected with ordinary SPARQL, and
used to derive SHACL shapes. The triples are added alongside any existing content of
the target graph (the graph is not replaced).
Usage:
>>> m.templates_to_graph("https://example.org/templates")
>>> m.query('''
... PREFIX maplib: <https://datatreehouse.github.io/maplib/vocab#>
... SELECT ?template ?iri WHERE {
... GRAPH <https://example.org/templates> { ?template maplib:referencesIri ?iri }
... }''')
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
str
|
The IRI of the graph to add the template triples to. Defaults to the default graph. |
None
|
add_prefixes ¶
map ¶
map(
template: Union[str, Template, IRI],
data: Union[DataFrame, SolutionMappings] = None,
graph: str = None,
validate_iris: bool = True,
) -> None
Map a template using a DataFrame Usage:
If the template has no arguments, the df argument is not necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
Union[str, Template, IRI]
|
Template, IRI, IRI string or prefixed template name. |
required |
data
|
Union[DataFrame, SolutionMappings]
|
DataFrame where the columns have the same names as the template arguments (when piping the output of queries back in, use SolutionMappings) |
None
|
graph
|
str
|
The IRI of the graph to add triples to. |
None
|
validate_iris
|
bool
|
Validate any IRI-columns. |
True
|
map_json ¶
Map a JSON file or string to triples. Usage:
or:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_string
|
Path | str
|
Path to a JSON document or a JSON string. |
required |
graph
|
str
|
The IRI of the graph to add triples to. None is the default graph. |
None
|
transient
|
bool
|
Should the triples be included when serializing the graph? |
True
|
map_xml ¶
Map an XML file or string to triples. Usage:
or:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_string
|
Path | str
|
Path to an XML document or an XML string. |
required |
graph
|
str
|
The IRI of the graph to add triples to. None is the default graph. |
None
|
transient
|
bool
|
Should the triples be included when serializing the graph? |
True
|
map_triples ¶
map_triples(
data: Union[DataFrame, SolutionMappings] = None,
predicate: str = None,
graph: str = None,
validate_iris: bool = True,
) -> None
Map a template using a DataFrame with columns subject, object and predicate The predicate column can also be supplied as a string if it is the same for all rows. Usage:
If the template has no arguments, the df argument is not necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[DataFrame, SolutionMappings]
|
DataFrame where the columns are named subject and object. May also contain a predicate-column. When piping the output of queries back in, use SolutionMappings. |
None
|
verb
|
The uri of the verb. |
required | |
graph
|
str
|
The IRI of the graph to add triples to. |
None
|
validate_iris
|
bool
|
Validate any IRI-columns. |
True
|
map_default ¶
map_default(
data: Union[DataFrame, SolutionMappings],
primary_key_column: str,
dry_run: bool = False,
graph: str = None,
validate_iris: bool = True,
) -> str
Create a default template and map it based on a dataframe. Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[DataFrame, SolutionMappings]
|
DataFrame where the columns have the same names as the template arguments (when piping the output of queries back in, use SolutionMappings) |
required |
primary_key_column
|
str
|
This column will be the subject of all triples in the generated template. |
required |
dry_run
|
bool
|
Do not map the template, only return the string. |
False
|
graph
|
str
|
The IRI of the graph to add triples to. |
None
|
validate_iris
|
bool
|
Validate any IRI-columns. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The generated template |
explore ¶
explore(
host: str = "localhost",
port: int = 8000,
bind: str = "localhost",
popup=False,
fts=True,
fts_path: str = "fts",
graph: str = None,
page: str = None,
) -> ExploreServer
Starts a graph explorer session. To run from Jupyter Notebook use:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
The hostname that we will point the browser to. |
'localhost'
|
port
|
int
|
The port where the graph explorer webserver listens on. |
8000
|
bind
|
str
|
Bind to the following host / ip. |
'localhost'
|
fts
|
Enable full text search indexing |
True
|
|
fts_path
|
str
|
Path to the fts index |
'fts'
|
graph
|
str
|
The named graph to explore, defaults to the default graph |
None
|
page
|
str
|
We use this feature flag to test new frontends (try "new" or "yasgui") |
None
|
query ¶
query(
query: str,
parameters: ParametersType = None,
solution_mappings: bool = False,
graph: str = None,
streaming: bool = False,
return_json: bool = False,
include_transient: bool = True,
max_rows: int = None,
debug: bool = False,
) -> Union[
DataFrame,
SolutionMappings,
List[Union[DataFrame, SolutionMappings, str]],
None,
]
Query the contained knowledge graph using SPARQL Currently, SELECT, CONSTRUCT and INSERT are supported. Usage:
>>> df = model.query('''
... PREFIX ex:<http://example.net/ns#>
... SELECT ?obj1 ?obj2 WHERE {
... ?obj1 ex:hasObj ?obj2
... }''')
... print(df)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The SPARQL query string |
required |
parameters
|
ParametersType
|
PVALUES Parameters, for each parameter, the SolutionMappings containing corresponding mappings and types. |
None
|
solution_mappings
|
bool
|
Returns SolutionMappings with maplib-native formatting and with RDF typing. Useful for round-trips. |
False
|
graph
|
str
|
The IRI of the graph to query. |
None
|
streaming
|
bool
|
Use Polars streaming |
False
|
return_json
|
bool
|
Return JSON string. |
False
|
include_transient
|
bool
|
Include transient triples when querying. |
True
|
max_rows
|
int
|
Maximum estimated rows in result, helps avoid out-of-memory errors. |
None
|
debug
|
bool
|
Why does my query have no results? |
False
|
Returns:
| Type | Description |
|---|---|
Union[DataFrame, SolutionMappings, List[Union[DataFrame, SolutionMappings, str]], None]
|
DataFrame (Select), list of DataFrames (Construct) containing results, None for Insert-queries, or SolutionMappings when solution_mappings is set. |
update ¶
update(
update: str,
parameters: ParametersType = None,
graph: str = None,
streaming: bool = False,
include_transient: bool = True,
max_rows: int = None,
debug: bool = False,
)
Insert the results of a Construct query in the graph. Useful for being able to use the same query for inspecting what will be inserted and actually inserting. Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
str
|
The SPARQL Update string |
required |
parameters
|
ParametersType
|
PVALUES Parameters, for each parameter, the SolutionMappings containing corresponding mappings and types. |
None
|
streaming
|
bool
|
Use Polars streaming |
False
|
include_transient
|
bool
|
Include transient triples when querying (but see "transient" above). |
True
|
max_rows
|
int
|
Maximum estimated rows in result, helps avoid out-of-memory errors. |
None
|
debug
|
bool
|
Why does my query have no results? |
False
|
Returns:
| Type | Description |
|---|---|
|
None |
insert ¶
insert(
query: str,
parameters: ParametersType = None,
solution_mappings: bool = False,
transient: bool = False,
streaming: bool = False,
source_graph: str = None,
target_graph: str = None,
include_transient: bool = True,
max_rows: int = None,
debug: bool = False,
)
Insert the results of a Construct query in the graph. Useful for being able to use the same query for inspecting what will be inserted and actually inserting. Usage:
>>> m = Model(doc)
... # Omitted
... hpizzas = '''
... PREFIX pizza:<https://github.com/magbak/maplib/pizza#>
... PREFIX ing:<https://github.com/magbak/maplib/pizza/ingredients#>
... CONSTRUCT { ?p a pizza:HeterodoxPizza }
... WHERE {
... ?p a pizza:Pizza .
... ?p pizza:hasIngredient ing:Pineapple .
... }'''
... m.insert(hpizzas)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The SPARQL Insert query string |
required |
parameters
|
ParametersType
|
PVALUES Parameters, for each parameter, the SolutionMappings containing corresponding mappings and types. |
None
|
solution_mappings
|
bool
|
Returns SolutionMappings with maplib-native formatting and with RDF typing. Useful for round-trips. |
False
|
transient
|
bool
|
Should the inserted triples be transient? |
False
|
source_graph
|
str
|
The IRI of the source graph to execute the construct query. |
None
|
target_graph
|
str
|
The IRI of the target graph to insert into. |
None
|
streaming
|
bool
|
Use Polars streaming |
False
|
include_transient
|
bool
|
Include transient triples when querying (but see "transient" above). |
True
|
max_rows
|
int
|
Maximum estimated rows in result, helps avoid out-of-memory errors. |
None
|
debug
|
bool
|
Why does my query have no results? |
False
|
Returns:
| Type | Description |
|---|---|
|
None |
validate ¶
validate(
shape_graph: str = None,
data_graph: str = None,
report_graph: str = None,
inferences_graph: str = None,
include_details: bool = False,
include_conforms: bool = False,
include_shape_graph: bool = True,
streaming: bool = False,
max_shape_constraint_results: int = None,
only_shapes: List[str] = None,
deactivate_shapes: List[str] = None,
dry_run: bool = False,
max_rows: int = None,
serial: bool = False,
max_iterations: Optional[int] = 100000,
debug_rules: bool = False,
) -> ValidationReport
Validate the contained knowledge graph using SHACL Assumes that the contained knowledge graph also contains SHACL Shapes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape_graph
|
str
|
The IRI of the Shape Graph (defaults to the default graph). |
None
|
data_graph
|
str
|
The IRI of the Data Graph (defaults to the default graph). |
None
|
report_graph
|
str
|
If this IRI is supplied, the validation report (if any) is found in this named graph. |
None
|
inferences_graph
|
str
|
If this IRI is supplied, any inference results from sh:rule can be found in this named graph. |
None
|
include_details
|
bool
|
Include details of SHACL evaluation alongside the report. Currently uses a lot of memory. |
False
|
include_conforms
|
bool
|
Include those results that conformed. Also applies to details. |
False
|
solution_mappings
|
Returns SolutionMappings instead of DataFrame (includes types for columns). |
required | |
streaming
|
bool
|
Use Polars streaming |
False
|
max_shape_constraint_results
|
int
|
Maximum number of results per shape and constraint. Reduces the size of the result set. |
None
|
only_shapes
|
List[str]
|
Validate only these shapes, None means all shapes are validated (must be IRI, cannot be used with deactivate_shapes). |
None
|
deactivate_shapes
|
List[str]
|
Disable validation of these shapes (must be IRI, cannot be used with deactivate_shapes). |
None
|
dry_run
|
bool
|
Only find targets of shapes, but do not validate them. |
False
|
max_rows
|
int
|
Maximum estimated rows in underlying SPARQL results, helps avoid out-of-memory errors. |
None
|
serial
|
bool
|
Turns off most parallell validation of shapes. |
False
|
max_iterations
|
Optional[int]
|
Maximum number of iterations for SHACL rules. |
100000
|
debug_rules
|
bool
|
Debug why rules returning no results do so. Included in rule log. |
False
|
Returns:
| Type | Description |
|---|---|
ValidationReport
|
Validation report containing shape performance details and target counts and whether the graph conforms (report.conforms) |
read ¶
read(
file_path: Union[str, Path],
format: Literal[
"ntriples",
"turtle",
"rdf/xml",
"cim/xml",
"json-ld",
"hdt",
] = None,
base_iri: str = None,
transient: bool = False,
parallel: bool = None,
checked: bool = True,
graph: str = None,
replace_graph: bool = False,
triples_batch_size: int = 10000000,
known_contexts: Dict[str, str] = None,
) -> None
Reads triples from a file path. You can specify the format, or it will be derived using file extension, e.g. filename.ttl or filename.nt. Specify transient if you only want the triples to be available for further querying and validation, but not persisted using write-methods.
Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Union[str, Path]
|
The path of the file containing triples |
required |
format
|
Literal['ntriples', 'turtle', 'rdf/xml', 'cim/xml', 'json-ld', 'hdt']
|
One of "ntriples", "turtle", "rdf/xml", "json-ld", "cim/xml" or "hdt", otherwise it is inferred from the file extension. |
None
|
base_iri
|
str
|
Base iri |
None
|
transient
|
bool
|
Should these triples be included when writing the graph to the file system? |
False
|
parallel
|
bool
|
Parse triples in parallel, currently only NTRiples and Turtle. Assumes all prefixes are in the beginning of the document. Defaults to true only for NTriples. |
None
|
checked
|
bool
|
Check IRIs etc. |
True
|
graph
|
str
|
The IRI of the graph to read the triples into, if None, it will be the default graph. |
None
|
replace_graph
|
bool
|
Replace the graph with these triples? Will replace the default graph if no graph is specified. |
False
|
triples_batch_size
|
int
|
Read this many triples in each batch. |
10000000
|
known_contexts
|
Dict[str, str]
|
Contexts in JSON-LD documents are resolved towards this dict. |
None
|
read_template ¶
reads ¶
reads(
s: str,
format: Literal[
"ntriples",
"turtle",
"rdf/xml",
"cim/xml",
"json-ld",
],
base_iri: str = None,
transient: bool = False,
parallel: bool = None,
checked: bool = True,
graph: str = None,
replace_graph: bool = False,
triples_batch_size: int = 10000000,
known_contexts: Dict[str, str] = None,
) -> None
Reads triples from a string. Specify transient if you only want the triples to be available for further querying and validation, but not persisted using write-methods.
Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
String containing serialized triples. |
required |
format
|
Literal['ntriples', 'turtle', 'rdf/xml', 'cim/xml', 'json-ld']
|
One of "ntriples", "turtle", "rdf/xml", "json-ld" or "cim/xml". |
required |
base_iri
|
str
|
Base iri |
None
|
transient
|
bool
|
Should these triples be included when writing the graph to the file system? |
False
|
parallel
|
bool
|
Parse triples in parallel, currently only NTRiples and Turtle. Assumes all prefixes are in the beginning of the document. Defaults to true for NTriples. |
None
|
checked
|
bool
|
Check IRIs etc. |
True
|
graph
|
str
|
The IRI of the graph to read the triples into. |
None
|
replace_graph
|
bool
|
Replace the graph with these triples? Will replace the default graph if no graph is specified. |
False
|
triples_batch_size
|
int
|
Number of triples to read in each batch. |
10000000
|
known_contexts
|
Dict[str, str]
|
Contexts in JSON-LD documents are resolved towards this dict. |
None
|
write_cim_xml ¶
write_cim_xml(
file_path: Union[str, Path],
profile_graph: str,
model_iri: str = None,
version: str = None,
description: str = None,
created: str = None,
scenario_time: str = None,
modeling_authority_set: str = None,
prefixes: Dict[str, str] = None,
graph: str = None,
) -> None
Write the legacy CIM XML format.
>>> PROFILE_GRAPH = "urn:graph:profiles"
>>> m = Model()
>>> m.read(model_path, base_iri=publicID, format="rdf/xml")
>>> m.read("61970-600-2_Equipment-AP-Voc-RDFS2020_v3-0-0.rdf", graph=PROFILE_GRAPH, format="rdf/xml")
>>> m.read("61970-600-2_Operation-AP-Voc-RDFS2020_v3-0-0.rdf", graph=PROFILE_GRAPH, format="rdf/xml")
>>> m.write_cim_xml(
>>> "model.xml",
>>> profile_graph=PROFILE_GRAPH,
>>> description = "MyModel",
>>> created = "2023-09-14T20:27:41",
>>> scenario_time = "2023-09-14T02:44:43",
>>> modeling_authority_set="www.westernpower.co.uk",
>>> version="22",
>>> )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Union[str, Path]
|
The path of the file containing triples |
required |
profile_graph
|
str
|
The IRI of the graph containing the ontology of the CIM profile to write. |
required |
model_iri
|
str
|
model_iri a md:FullModel. Is generated if not provided. |
None
|
version
|
str
|
model_iri md:Model.version version . |
None
|
description
|
str
|
model_iri md:Model.description description . |
None
|
created
|
str
|
model_iri md:Model.created created . |
None
|
scenario_time
|
str
|
model_iri md:Model.scenarioTime scenario_time . |
None
|
modeling_authority_set
|
str
|
model_iri md:Model.modelingAuthoritySet modeling_authority_set . |
None
|
prefixes
|
Dict[str, str]
|
Prefixes to be used in XML export. |
None
|
graph
|
str
|
The graph to write, defaults to the default graph. |
None
|
write ¶
write(
file_path: Union[str, Path],
format=LiteralType[
"ntriples", "turtle", "rdf/xml", "hdt"
],
graph: str = None,
prefixes: Dict[str, str] = None,
) -> None
Write the non-transient triples to the file path specified in the NTriples format.
Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Union[str, Path]
|
The path of the file containing triples |
required |
format
|
One of "ntriples", "turtle", "rdf/xml", "hdt". HDT is built in memory; literals with special characters are stored N-Triples-escaped, following the Rust hdt crate. |
Literal['ntriples', 'turtle', 'rdf/xml', 'hdt']
|
|
graph
|
str
|
The IRI of the graph to write. |
None
|
prefixes
|
Dict[str, str]
|
The prefixes that will be used in turtle serialization. |
None
|
writes ¶
writes(
format=LiteralType["ntriples", "turtle", "rdf/xml"],
graph: str = None,
prefixes: Dict[str, str] = None,
) -> str
Write the non-transient triples to a string in memory.
Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
One of "ntriples", "turtle", "rdf/xml". |
Literal['ntriples', 'turtle', 'rdf/xml']
|
|
graph
|
str
|
The IRI of the graph to write. |
None
|
prefixes
|
Dict[str, str]
|
The prefixes used for turtle serialization. |
None
|
write_native_parquet ¶
Write non-transient triples using the internal native Parquet format.
Usage:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_path
|
Union[str, Path]
|
The path of the folder to write triples in the native format. |
required |
graph
|
str
|
The IRI of the graph to write. |
None
|
truncate_graph ¶
Removes all triples associated with the given graph from the triplestore, includes transient triples and full-text search entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
str
|
The IRI of the graph to truncate. |
None
|
detach_graph ¶
Detaches and returns a named graph as their own Model object. The named graph is removed from the original Model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
str
|
The name of the graph to detach. Defaults to the default graph. |
None
|
preserve_name
|
bool
|
Preserve the name of the graph in the new Model, defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Model
|
A model. |
get_predicate_iris ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
str
|
The graph to get the predicate iris from. |
None
|
include_transient
|
bool
|
Should we include predicates only between transient triples? |
False
|
Returns:
| Type | Description |
|---|---|
List[IRI]
|
The IRIs of the predicates currently in the given graph. |
get_predicate ¶
get_predicate(
iri: IRI,
graph: str = None,
include_transient: bool = False,
) -> List[SolutionMappings]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
IRI
|
The predicate IRI |
required |
graph
|
str
|
The graph to get the predicate from. |
None
|
include_transient
|
bool
|
Should we include transient triples? |
False
|
Returns:
| Type | Description |
|---|---|
List[SolutionMappings]
|
A list of the underlying tables that store a given predicate. |
create_index ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
IndexingOptions
|
Indexing options |
None
|
all
|
bool
|
Apply to all existing and new graphs |
True
|
graph
|
str
|
The graph where indexes should be added |
None
|
infer ¶
infer(
ruleset: Union[str, List[str]],
graph: str = None,
max_iterations: Optional[int] = 100000,
max_results: Optional[int] = 10000000,
include_transient: bool = True,
max_rows: Optional[int] = 100000000,
debug: bool = False,
) -> Optional[Dict[str, DataFrame]]
Run the inference rules that are provided
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ruleset
|
Union[str, List[str]]
|
The Datalog ruleset (a string). |
required |
graph
|
str
|
Apply the ruleset to this graph, defaults to the default graph, or the graph specified in the rules. |
None
|
max_iterations
|
Optional[int]
|
Maximum number of iterations. |
100000
|
max_results
|
Optional[int]
|
Maximum number of results. |
10000000
|
include_transient
|
bool
|
Include transient triples when reasoning. |
True
|
max_rows
|
Optional[int]
|
Maximum estimated rows in result, helps avoid out-of-memory errors. |
100000000
|
debug
|
bool
|
Debugs rule bodies for executions that give no triples. |
False
|
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, DataFrame]]
|
The inferred N-Tuples. |
size ¶
Get the number of triples in a graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
str
|
The named graph we are returning the size for |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The inferred N-Tuples. |
Supporting types¶
maplib.Template ¶
Create a new OTTR Template
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
IRI
|
The IRI of the template |
required |
parameters
|
List[Union[Parameter, Variable]]
|
|
required |
instances
|
List[Instance]
|
|
required |
instances
instance-attribute
¶
An OTTR Template. Note that accessing parameters- or instances-fields returns copies. To change these fields, you must assign new lists of parameters or instances.
instance ¶
instance(
arguments: List[
Union[Argument, Variable, IRI, Literal, None]
],
list_expander: Literal[
"cross", "zipMin", "zipMax"
] = None,
) -> Instance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arguments
|
List[Union[Argument, Variable, IRI, Literal, None]]
|
The arguments to the template. |
required |
list_expander
|
Literal['cross', 'zipMin', 'zipMax']
|
(How) should we list-expand? |
None
|
maplib.Parameter ¶
Parameter(
variable: Variable,
optional: Optional[bool] = False,
allow_blank: Optional[bool] = True,
rdf_type: Optional[RDFType] = None,
default_value: Optional[
Union[Literal, IRI, BlankNode]
] = None,
)
Create a new parameter for a Template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
Variable
|
The variable. |
required |
optional
|
Optional[bool]
|
Can the variable be unbound? |
False
|
allow_blank
|
Optional[bool]
|
Can the variable be bound to a blank node? |
True
|
rdf_type
|
Optional[RDFType]
|
The type of the variable. Can be nested. |
None
|
default_value
|
Optional[Union[Literal, IRI, BlankNode]]
|
Default value when no value provided. |
None
|
default_value
instance-attribute
¶
Parameters for template signatures.
maplib.Argument ¶
An argument for a template instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
Union[Variable, IRI, Literal]
|
The term. |
required |
list_expand
|
Optional[bool]
|
Should the argument be expanded? Used with the list_expander argument of instance. |
False
|
maplib.IndexingOptions ¶
IndexingOptions(
object_sort_all: bool = None,
object_sort_some: List[IRI] = None,
fts: str = None,
fts_path: str = None,
subject_object_index: bool = None,
)
Options for indexing
Defaults to indexing on subjects and objects for select types (e.g. rdf:type and rdfs:label)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_sort_all
|
bool
|
Enable object-indexing for all suitable predicates (doubles memory requirement). |
None
|
object_sort_some
|
List[IRI]
|
Enable object-indexing for a selected list of predicates. |
None
|
fts
|
str
|
Enable full text search, in memory if a path is not given. |
None
|
fts_path
|
str
|
Enable full text search, stored at the path |
None
|
subject_object_index
|
bool
|
An index used to deduplicate before insertion, speeds up mapping at a moderate memory cost. On by default. |
None
|