topologicpy.Ontology module
Canonical ontology support for TopologicPy.
Design rules
ontology/topologicpy.ttlis the single human-edited ontology source.TopologicPy-owned datatype properties use concise attribute names such as
top:x,top:areaandtop:volume.Object properties name the relationship:
top:startsAt,top:endsAt,top:connectsTo.has...is used only when possession/association is actually the relationship (for exampletop:hasNode).Standard vocabularies are reused when they already express the semantics: rdf:type, rdfs:label, dcterms:, prov:, BOT, Brick and GeoSPARQL.
Unknown Python dictionary keys are exported under
dict:; they never silently become newtop:terms.Labels are presentation data and NEVER determine RDF identity.
RDF -> TGraph -> RDF preserves resource identity, namespaces, multiplicity, RDF types, and exact non-structural URI/BNode/literal values (including literal datatype and language). Structural graph statements are rebuilt canonically from the reconstructed TGraph.
- class topologicpy.Ontology.Ontology
Bases:
objectMethods
AnnotateSubtopologies(topology[, ...])Annotates requested subtopologies using canonical TopologicPy classes.
CanonicalClass(value[, defaultValue])Returns a canonical class QName without inventing
top:terms.ExportTTL(topology, path, **kwargs)Exports a topology/graph/dictionary as Turtle.
GraphTriples(graph[, includeVertices, ...])IsQName(value)Returns True when
valueis a QName with a registered prefix.NormalizeDictionary(topology[, inferClass, ...])Normalizes a TopologicPy/IFC dictionary without legacy RDF aliases.
PropertyQName(key[, defaultPrefix])Returns a canonical predicate QName without inventing
top:terms.SetURI(obj, uri[, silent])Sets the explicit RDF resource identity under the canonical
urikey.SetValue(obj, key, value[, silent])Sets one dictionary value and preserves the object returned by the adapter.
TurtleFromTriples(triples[, ...])Serializes triples to Turtle, with or without RDFLib.
Validate(topology[, silent, requiredKeys])Validates ontology annotations against the canonical TTL vocabulary.
ValidateGraph(graph[, silent])Validates a TGraph's ontology annotations and structural endpoints.
ValidateTTLString(ttlString[, silent])Validates Turtle syntax and canonical TopologicPy vocabulary use.
Value(obj, key[, defaultValue])Returns a dictionary value from a topology, TGraph item, or plain dict.
Annotate
AnnotateIFC
BOTClassByClass
Category
CategoryByClass
Class
ClassByIFCClass
ClassByTopology
ClassQName
ExpandQName
ExportOntologyTTL
ExportRDF
GraphByRDFFile
GraphByRDFGraph
GraphByTTL
GraphByTTLString
IsA
IsClass
IsProperty
IsResourceString
Label
Namespace
Namespaces
OntologyRDFGraph
OntologyTTLString
OntologyTriples
QName
RDFGraph
RDFString
SetCategory
SetClass
SetLabel
TTLString
Triples
ValidateRDFGraph
ValidateTTL
- ANNOTATION_PROPERTIES: Dict[str, Any] = {}
- static Annotate(topology: Any, ontologyClass: str = None, category: Any = None, label: Any = None, uri: str = None, source: Any = None, derivedFrom: Any = None, generatedBy: Any = None, inferClass: bool = False, silent: bool = False)
- static AnnotateIFC(topology: Any, ifcClass: str = None, ifcGUID: str = None, ifcName: str = None, source: Any = None, silent: bool = False)
- static AnnotateSubtopologies(topology: Any, topologyTypes: Iterable[str] = None, inferClass: bool = True, silent: bool = False, **kwargs)
Annotates requested subtopologies using canonical TopologicPy classes.
topologyTypesmay contain names such as"Vertex"or"Face". For convenience, boolean keyword flags such asvertices=Trueandfaces=Trueare also accepted. The input topology is returned.
- static BOTClassByClass(ontologyClass: Any, defaultValue: Any = None)
- CATEGORY_KEY = 'category'
- CLASS_ALIASES: Dict[str, str] = {}
- static CanonicalClass(value: Any, defaultValue: Any = None)
Returns a canonical class QName without inventing
top:terms.Undeclared terms in the TopologicPy namespace are rejected. External classes retain their native QName/URI because TopologicPy does not own their naming conventions.
- static Category(obj: Any, defaultValue: Any = None)
- static CategoryByClass(ontologyClass: Any, defaultValue: Any = None)
- static Class(obj: Any, defaultValue: Any = None)
- static ClassByIFCClass(ifcClass: Any, defaultValue: Any = None)
- static ClassByTopology(topology: Any, defaultValue: Any = None)
- static ClassQName(value: Any, defaultValue: Any = None)
- DATA_PROPERTIES: Dict[str, Any] = {}
- DEPRECATED_PROPERTIES = {}
- DERIVED_FROM_KEY = 'derived_from'
- static ExpandQName(value: Any, defaultValue: Any = None)
- static ExportOntologyTTL(path: str, includeBOT: bool = True, silent: bool = False)
- static ExportRDF(topology: Any, path: str, format: str = None, silent: bool = False, **kwargs)
- static ExportTTL(topology: Any, path: str, **kwargs)
Exports a topology/graph/dictionary as Turtle.
Unlike
ExportRDF(), this method does not require RDFLib. It usesTTLString(), whose deterministic fallback serializer preserves the same canonical predicates when RDFLib is unavailable.
- GENERATED_BY_KEY = 'generated_by'
- static GraphByRDFFile(path: str, format: str = None, graphSubject: str = None, namespacePrefix: str = 'inst', tolerance: float = 0.0001, silent: bool = False)
- static GraphByRDFGraph(rdfGraph, graphSubject: str = None, namespacePrefix: str = 'inst', tolerance: float = 0.0001, silent: bool = False)
- static GraphByTTL(path: str, **kwargs)
- static GraphByTTLString(ttlString: str, graphSubject: str = None, namespacePrefix: str = 'inst', tolerance: float = 0.0001, silent: bool = False)
- static GraphTriples(graph: Any, includeVertices: bool = True, includeEdges: bool = True, includeDictionaries: bool = True, includeBOT: bool = True, namespacePrefix: str = 'inst', silent: bool = False)
- IFC_CLASS_KEY = 'ifc_class'
- IFC_GUID_KEY = 'ifc_guid'
- IFC_TO_TOP = {'IfcApproval': 'top:Approval', 'IfcBeam': 'top:Beam', 'IfcBuilding': 'top:Building', 'IfcBuildingElementProxy': 'top:Element', 'IfcBuildingStorey': 'top:Storey', 'IfcClassificationReference': 'top:ClassificationReference', 'IfcColumn': 'top:Column', 'IfcConstraint': 'top:Constraint', 'IfcCurtainWall': 'top:CurtainWall', 'IfcDistributionElement': 'top:Equipment', 'IfcDistributionFlowElement': 'top:Equipment', 'IfcDocumentReference': 'top:DocumentReference', 'IfcDoor': 'top:Door', 'IfcElementQuantity': 'top:Quantity', 'IfcEnergyConversionDevice': 'top:Equipment', 'IfcFlowController': 'top:Equipment', 'IfcFlowFitting': 'top:Equipment', 'IfcFlowMovingDevice': 'top:Equipment', 'IfcFlowSegment': 'top:Equipment', 'IfcFlowStorageDevice': 'top:Equipment', 'IfcFlowTerminal': 'top:Equipment', 'IfcFlowTreatmentDevice': 'top:Equipment', 'IfcFurnishingElement': 'top:Furniture', 'IfcFurniture': 'top:Furniture', 'IfcMaterial': 'top:Material', 'IfcMaterialLayerSet': 'top:MaterialSet', 'IfcMaterialProfileSet': 'top:MaterialSet', 'IfcMember': 'top:Member', 'IfcOpeningElement': 'top:Opening', 'IfcProject': 'top:Project', 'IfcPropertySet': 'top:PropertySet', 'IfcRailing': 'top:Railing', 'IfcRelSpaceBoundary': 'top:Interface', 'IfcRoof': 'top:Roof', 'IfcSensor': 'top:Sensor', 'IfcSite': 'top:Site', 'IfcSlab': 'top:Slab', 'IfcSpace': 'top:Space', 'IfcStair': 'top:Stair', 'IfcStairFlight': 'top:Stair', 'IfcVirtualElement': 'top:Element', 'IfcWall': 'top:Wall', 'IfcWallStandardCase': 'top:Wall', 'IfcWindow': 'top:Window', 'IfcZone': 'top:Zone'}
- static IsA(topology: Any, ontologyClass: str, transitive: bool = True) bool
- static IsClass(value: Any) bool
- static IsProperty(value: Any) bool
- static IsQName(value: Any) bool
Returns True when
valueis a QName with a registered prefix.
- static IsResourceString(value: Any) bool
- LABEL_KEY = 'label'
- static Label(obj: Any, defaultValue: Any = None)
- NAMESPACES = {'bot': 'https://w3id.org/bot#', 'brick': 'https://brickschema.org/schema/Brick#', 'dcterms': 'http://purl.org/dc/terms/', 'dict': 'http://w3id.org/topologicpy/dictionary#', 'geo': 'http://www.opengis.net/ont/geosparql#', 'ifc': 'https://standards.buildingsmart.org/IFC/DEV/IFC4/ADD2_TC1/OWL#', 'inst': 'http://w3id.org/topologicpy/instance#', 'owl': 'http://www.w3.org/2002/07/owl#', 'prov': 'http://www.w3.org/ns/prov#', 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#', 'skos': 'http://www.w3.org/2004/02/skos/core#', 'top': 'http://w3id.org/topologicpy#', 'vann': 'http://purl.org/vocab/vann/', 'xsd': 'http://www.w3.org/2001/XMLSchema#'}
- static Namespace(prefix: str, defaultValue: Any = None)
- static Namespaces() Dict[str, str]
- static NormalizeDictionary(topology: Any, inferClass: bool = True, silent: bool = False, **kwargs)
Normalizes a TopologicPy/IFC dictionary without legacy RDF aliases.
IFC implementation keys are adapted to the canonical internal keys; no deprecated ontology predicate or class aliases are created.
- OBJECT_PROPERTIES: Dict[str, Any] = {}
- ONTOLOGY_CLASS_KEY = 'ontology_class'
- ONTOLOGY_URI_KEY = 'ontology_uri'
- static OntologyRDFGraph(silent: bool = False)
- static OntologyTTLString(includeBOT: bool = True, silent: bool = False) Optional[str]
- static OntologyTriples(includeBOT: bool = True)
- PROPERTY_ALIASES: Dict[str, str] = {}
- static PropertyQName(key: Any, defaultPrefix: str = 'dict')
Returns a canonical predicate QName without inventing
top:terms.An undeclared explicit
top:predicate is invalid and returns None. Unknown unqualified Python dictionary keys are intentionally placed in thedict:namespace. External vocabulary predicates are preserved.
- static QName(value: Any, defaultValue: Any = None)
- static RDFGraph(topology: Any, includeGraph: bool = True, includeDictionaries: bool = True, includeBOT: bool = True, namespacePrefix: str = 'inst', instanceNamespace: str = 'http://w3id.org/topologicpy/instance#', silent: bool = False)
- static RDFString(topology: Any, format: str = 'turtle', **kwargs)
- RDF_PROPERTIES_KEY = '_rdf_properties'
- RDF_TYPES_KEY = '_rdf_types'
- RDF_URI_KEY = '_rdf_uri'
- SOURCE_KEY = 'source'
- static SetCategory(obj: Any, category: Any, silent: bool = False)
- static SetClass(obj: Any, ontologyClass: str, silent: bool = False)
- static SetLabel(obj: Any, label: Any, silent: bool = False)
- static SetURI(obj: Any, uri: str, silent: bool = False)
Sets the explicit RDF resource identity under the canonical
urikey.
- static SetValue(obj: Any, key: str, value: Any, silent: bool = False)
Sets one dictionary value and preserves the object returned by the adapter.
- TOP_SUPERCLASSES: Dict[str, List[str]] = {}
- TOP_TO_BOT = {'top:Aperture': 'bot:Element', 'top:Beam': 'bot:Element', 'top:Building': 'bot:Building', 'top:CirculationZone': 'bot:Zone', 'top:Column': 'bot:Element', 'top:CurtainWall': 'bot:Element', 'top:Door': 'bot:Element', 'top:Element': 'bot:Element', 'top:Equipment': 'brick:Equipment', 'top:FunctionalZone': 'bot:Zone', 'top:Furniture': 'bot:Element', 'top:Interface': 'bot:Interface', 'top:Member': 'bot:Element', 'top:Opening': 'bot:Element', 'top:Project': 'prov:Entity', 'top:Railing': 'bot:Element', 'top:Roof': 'bot:Element', 'top:Room': 'bot:Space', 'top:Sensor': 'brick:Point', 'top:Site': 'bot:Site', 'top:Slab': 'bot:Element', 'top:Space': 'bot:Space', 'top:Stair': 'bot:Element', 'top:Storey': 'bot:Storey', 'top:ThermalZone': 'bot:Zone', 'top:Wall': 'bot:Element', 'top:Window': 'bot:Element', 'top:Zone': 'bot:Zone'}
- static TTLString(topology: Any, **kwargs)
- static Triples(topology: Any, subject: str = None, includeDictionaries: bool = True, includeBOT: bool = True, namespacePrefix: str = 'inst', silent: bool = False)
- static TurtleFromTriples(triples: Iterable[Tuple[Any, Any, Any]], namespacePrefix: str = 'inst', instanceNamespace: str = 'http://w3id.org/topologicpy/instance#', namespaces: Dict[str, str] = None, includeHeader: bool = True, **kwargs)
Serializes triples to Turtle, with or without RDFLib.
- URI_KEY = 'uri'
- static Validate(topology: Any, silent: bool = False, requiredKeys: Iterable[str] = None, **kwargs) Dict[str, Any]
Validates ontology annotations against the canonical TTL vocabulary.
- static ValidateGraph(graph: Any, silent: bool = False, **kwargs) Dict[str, Any]
Validates a TGraph’s ontology annotations and structural endpoints.
- static ValidateRDFGraph(rdfGraph: Any, silent: bool = False) Dict[str, Any]
- static ValidateTTL(path: str, silent: bool = False) Dict[str, Any]
- static ValidateTTLString(ttlString: str, silent: bool = False) Dict[str, Any]
Validates Turtle syntax and canonical TopologicPy vocabulary use.
Every URI in the
top:namespace must be declared by the canonical ontology as a class or property. Thus ingested Turtle is held to the same no-invented-terms rule as exported RDF.
- static Value(obj: Any, key: str, defaultValue: Any = None)
Returns a dictionary value from a topology, TGraph item, or plain dict.