To make OWL concrete, it helps to look at it in Turtle (.ttl) format, which is the most human-readable syntax for the W3C semantic stack.
Here is a simple example of an OWL ontology defining a domain for Vehicles and Motorcycles, including classes, properties, and logical constraints that a reasoner can use to infer new knowledge.
OWL Ontology Example (Turtle Syntax)
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.org/vehicles#> .
# 1. Define the Ontology Header
ex:VehicleOntology a owl:Ontology ;
rdfs:comment "A sample OWL ontology for vehicle classification." .
# 2. Define Classes (Taxonomy)
ex:Vehicle a owl:Class ;
rdfs:label "Vehicle" .
ex:Motorcycle a owl:Class ;
rdfs:subClassOf ex:Vehicle ;
rdfs:label "Motorcycle" .
ex:Manufacturer a owl:Class ;
rdfs:label "Manufacturer" .
# 3. Define Properties (Relationships & Attributes)
ex:manufacturedBy a owl:ObjectProperty ;
rdfs:domain ex:Vehicle ;
rdfs:range ex:Manufacturer ;
rdfs:label "manufactured by" .
ex:engineDisplacementCC a owl:DatatypeProperty, owl:FunctionalProperty ;
rdfs:domain ex:Motorcycle ;
rdfs:range xsd:integer ;
rdfs:label "engine displacement in CC" .
# 4. Define Instances (Individuals) & Automated Reasoning
ex:HeroMotoCorp a ex:Manufacturer ;
rdfs:label "Hero MotoCorp" .
# Notice we only state that 'Xpulse210' has an engine displacement.
# Because of the OWL restrictions above, a reasoner automatically knows it is a Motorcycle (and therefore a Vehicle).
ex:Xpulse210 a ex:Motorcycle ;
ex:manufacturedBy ex:HeroMotoCorp ;
ex:engineDisplacementCC "210"^^xsd:integer .
How OWL Powers This Example
- Taxonomy & Inheritance (
rdfs:subClassOf): By definingex:Motorcycle rdfs:subClassOf ex:Vehicle, any rule or query that applies to aVehicleautomatically cascades down toMotorcycle. - Object vs. Datatype Properties:
ex:manufacturedByis an Object Property because it links a resource (Vehicle) to another resource (Manufacturer).ex:engineDisplacementCCis a Datatype Property because it links a resource to a literal value (210as an integer).
- Logical Inference:
Because
rdfs:domainspecifies thatengineDisplacementCCcan only belong to aMotorcycle, an OWL reasoner can look at raw data, spot an unclassified object with an engine displacement, and automatically infer that the object must be aMotorcycleand aVehicle.
No comments:
Post a Comment