ifcopenshell.mvd.sparql

Module Contents

class ifcopenshell.mvd.sparql.builder

Bases: object

A helper class for dealing with SPARQL query statements

append(*stmt)
bind(di)
x()
prefixes
statements = []
class ifcopenshell.mvd.sparql.convertor

Bases: object

static build_filter(self)
static concept_or_applicability(concept)

Convert the Template (SELECT … WHERE {}) structure and TemplateRule (FILTER)

Parameters:

qtype – 0 or 1, 0 for a general query matching the applicableRootEntity

Returns:

static convert(item, *args, **kwargs)
static root(rootEntity)
static template(template, bld=None, rootEntity=None)
class ifcopenshell.mvd.sparql.executor

Bases: object

static run(CR, fn, ttlfn)

Generates SPARQL queries for the parsed MVD and executes on the building model

Parameters:
  • CR – A parsed concept root

  • fn – A filename used as the prefix to store generate SPARQL queries to disk

  • ttlfn – A filename for the LD representation of an IFC model

Returns:

class ifcopenshell.mvd.sparql.ifcOwl

Bases: object

Helper class with static function for dealing with ifcOwl attribute names

static get_names(e, c)

Returns inverse or forward attribute names for latebound entity definition

Parameters:
  • e – latebound entity definition

  • c – either ‘all_attributes’ or ‘all_inverse_attributes’

Returns:

set of attribute names

static is_boxed(S, entity, attribute, predCount=0)

Returns whether the entity attribute should be boxed in ifcOwl. Which means that there is an additional indirection.

inst:IfcRelDefinesByType_21937

ifcowl:globalId_IfcRoot inst:IfcGloballyUniqueId_117684 ;

inst:IfcGloballyUniqueId_117684

rdf:type ifcowl:IfcGloballyUniqueId ; express:hasString “2P9FPkykn0r8rCpmBxZH0w” .

Parameters:
  • S – schema definition (from decorator)

  • entity – entity name string

  • attribute – attribute name string

  • predCount – numeric identifier to postfix predicate identifier in case of SELECT types

Returns:

either a predicate from the express namespace or a variable postfixed with predCount

static is_inverse(S, entity, attribute)

When entity attribute is an INVERSE attribute, returns the opposite forward entity and attribute name. Otherwise returns (False, False)

Parameters:
  • S

  • entity

  • attribute

Returns:

static is_select(S, decl_name)

Returns True when the declaration is a select type

Parameters:
  • S

  • decl_name

Returns:

static name(S, entity, attribute)

Names the entity attribute according to ifcOwl

Parameters:
  • S

  • entity

  • attribute

Returns:

static supertypes(S, entity)

Yields ifcOwl subtypes for the supplied entity name

Parameters:
  • S – schema definition (from decorator)

  • entity – entity name string

Returns:

class ifcopenshell.mvd.sparql.rule_binding

Bases: object

Object for mapping rules to generated SPARQL variables

ifcopenshell.mvd.sparql.camel(s)

Camel case conversion function :param s: str :return: camel case formatted string

ifcopenshell.mvd.sparql.derive_prefix(ttlfn)
ifcopenshell.mvd.sparql.infer_subtypes(ttlfn)
ifcopenshell.mvd.sparql.withschema(fn)

Decorator that takes a function and adds an IFC latebound schema definition in the first parameter. The schema identifier is looked up based on the global ifcOwl prefix.

Parameters:

fn – input function

Returns:

decorated function

ifcopenshell.mvd.sparql.JENA_SPARQL
ifcopenshell.mvd.sparql.STANDARD_PREFIXES
ifcopenshell.mvd.sparql.noop