Natan Cox
Natan Cox

Reputation: 1545

OWL rdfs:langString and restricting its allowed languages

Is it possible in OWL to restrict a Property with a range like

demo:property rdfs:range rdf:langString

so that we only allow "en" and "de" as languages?

So

demo:object demo:property "hello"@en

would be allowed, but

demo:object demo:property "bonjour"@fr

would not.

Upvotes: 2

Views: 677

Answers (1)

Stanislav Kralin
Stanislav Kralin

Reputation: 11479

From 4.3 Strings:

The OWL 2 datatype map provides the rdf:PlainLiteral datatype for the representation of strings in a particular language. The definitions of the value space, the lexical space, the facet space, and the necessary mappings are given in [RDF:PLAINLITERAL]. The normative constraining facets for rdf:PlainLiteral are xsd:length, xsd:minLength, xsd:maxLength, xsd:pattern, and rdf:langRange; furthermore, only basic language ranges [BCP 47] are supported in the rdf:langRange constraining facet.

Thus, in the Manchester syntax:

DataProperty: demo:property
    Range: 
        (rdf:PlainLiteral[langRange "de"] or rdf:PlainLiteral[langRange "en"]

In Turtle:

demo:property a owl:DatatypeProperty ;
    rdfs:range [ rdf:type rdfs:Datatype ;
        owl:unionOf ( [ rdf:type rdfs:Datatype ;
                        owl:onDatatype rdf:PlainLiteral ;
                        owl:withRestrictions ( [ rdf:langRange "de" ] )
                      ]
                      [ rdf:type rdfs:Datatype ;
                        owl:onDatatype rdf:PlainLiteral ;
                        owl:withRestrictions ( [ rdf:langRange "en" ] )
                      ]
                    )
                ] .

Now create 3 individuals (in Turtle):

demo:object_en a owl:NamedIndividual ;
               demo:property "demo"@en .

demo:object_de a owl:NamedIndividual ;
               demo:property "demo"@de .

demo:object_fr a owl:NamedIndividual ;
               demo:property "demo"@fr .

Then start a reasoner and look into inconsistency explanation.

Upvotes: 3

Related Questions