infixowl
RDFLib Python binding for OWL Abstract Syntax
| OWL Constructor | DL Syntax | Manchester OWL Syntax | Example |
|---|---|---|---|
intersectionOf |
C ∩ D | C AND D | Human AND Male |
unionOf |
C ∪ D | C OR D | Man OR Woman |
complementOf |
¬C | NOT C | NOT Male |
oneOf |
{a} ∪ {b}… | {a b …} | {England Italy Spain} |
someValuesFrom |
∃ R C | R SOME C | hasColleague SOME Professor |
allValuesFrom |
∀ R C | R ONLY C | hasColleague ONLY Professor |
minCardinality |
≥ N R | R MIN 3 | hasColleague MIN 3 |
maxCardinality |
≤ N R | R MAX 3 | hasColleague MAX 3 |
cardinality |
= N R | R EXACTLY 3 | hasColleague EXACTLY 3 |
hasValue |
∃ R.{a} | R VALUE a | hasColleague VALUE Matthew |
See: - http://www.w3.org/TR/owl-semantics/syntax.html - http://owl-workshop.man.ac.uk/acceptedLong/submission_9.pdf
3.2.3 Axioms for complete classes without using owl:equivalentClass
Named class description of type 2 (with owl:oneOf) or type 4-6 (with owl:intersectionOf, owl:unionOf or owl:complementOf
Uses Manchester Syntax for __repr__
Now we have an empty graph, we can construct OWL classes in it using the Python classes defined in this module
Now we can assert rdfs:subClassOf and owl:equivalentClass relationships (in the underlying graph) with other classes using the ‘subClassOf’ and ‘equivalentClass’ descriptors which can be set to a list of objects for the corresponding predicates.
We can then access the rdfs:subClassOf relationships
This can also be used against already populated graphs:
>>> owlGraph = Graph().parse(str(OWL))
>>> list(Class(OWL.Class, graph=owlGraph).subClassOf)
[Class: rdfs:Class ]
Operators are also available. For instance we can add ex:Opera to the extension of the ex:CreativeWork class via the ‘+=’ operator
>>> a
Class: ex:Opera SubClassOf: ex:MusicalWork
>>> b = Class(exNs.CreativeWork, graph=g)
>>> b += a
>>> print(sorted(a.subClassOf, key=lambda c:c.identifier))
[Class: ex:CreativeWork , Class: ex:MusicalWork ]
And we can then remove it from the extension as well
Boolean class constructions can also be created with Python operators. For example, The | operator can be used to construct a class consisting of a owl:unionOf the operands:
Boolean class expressions can also be operated as lists (using python list operators)
The ‘&’ operator can be used to construct class intersection:
>>> woman = Class(exNs.Female, graph=g) & Class(exNs.Human, graph=g)
>>> woman.identifier = exNs.Woman
>>> woman
( ex:Female AND ex:Human )
>>> len(woman)
2
Enumerated classes can also be manipulated
>>> contList = [Class(exNs.Africa, graph=g), Class(exNs.NorthAmerica, graph=g)]
>>> EnumeratedClass(members=contList, graph=g)
{ ex:Africa ex:NorthAmerica }
owl:Restrictions can also be instantiated:
Restrictions can also be created using Manchester OWL syntax in ‘colloquial’ Python
>>> exNs.hasParent @ some @ Class(exNs.Physician, graph=g)
( ex:hasParent SOME ex:Physician )
>>> Property(exNs.hasParent, graph=g) @ max @ Literal(1)
( ex:hasParent MAX 1 )
>>> print(g.serialize(format='pretty-xml')) # doctest: +SKIP
Classes:
-
AnnotatableTerms–Terms in an OWL ontology with rdfs:label and rdfs:comment
-
BooleanClass–See: http://www.w3.org/TR/owl-ref/#Boolean
-
Callable– -
Class–‘General form’ for classes:
-
ClassNamespaceFactory– -
EnumeratedClass–Class for owl:oneOf forms:
-
Individual–A typed individual, the base class of the InfixOWL classes.
-
Infix– -
MalformedClass–Deprecated
-
MalformedClassError– -
OWLRDFListProxy– -
Ontology–The owl ontology metadata
-
Property–```
-
Restriction–```
Functions:
-
AllClasses– -
AllDifferent–TODO: implement this function
-
AllProperties– -
CastClass– -
CommonNSBindings–Takes a graph and binds the common namespaces (rdf,rdfs, & owl)
-
ComponentTerms–Takes a Class instance and returns a generator over the classes that
-
DeepClassClear–Recursively clear the given class, continuing
-
GetIdentifiedClasses– -
classOrIdentifier– -
classOrTerm– -
generateQName– -
manchesterSyntax–Core serialization
-
propertyOrIdentifier–
Attributes:
-
ACE_NS– -
CLASS_RELATIONS– -
PropertyAbstractSyntax– -
exactly– -
max– -
min– -
nsBinds– -
only– -
some– -
value–
CLASS_RELATIONS
module-attribute
CLASS_RELATIONS = difference([onProperty, allValuesFrom, hasValue, someValuesFrom, inverseOf, imports, versionInfo, backwardCompatibleWith, incompatibleWith, unionOf, intersectionOf, oneOf])
PropertyAbstractSyntax
module-attribute
PropertyAbstractSyntax = "\n%s( %s { %s }\n%s\n{ 'super(' datavaluedPropertyID ')'} ['Functional']\n{ domain( %s ) } { range( %s ) } )"
__all__
module-attribute
__all__ = ['ACE_NS', 'AllClasses', 'AllDifferent', 'AllProperties', 'AnnotatableTerms', 'BooleanClass', 'CLASS_RELATIONS', 'Callable', 'CastClass', 'Class', 'ClassNamespaceFactory', 'CommonNSBindings', 'ComponentTerms', 'DeepClassClear', 'EnumeratedClass', 'GetIdentifiedClasses', 'Individual', 'Infix', 'MalformedClass', 'MalformedClassError', 'OWLRDFListProxy', 'Ontology', 'Property', 'PropertyAbstractSyntax', 'Restriction', 'classOrIdentifier', 'classOrTerm', 'exactly', 'generateQName', 'manchesterSyntax', 'max', 'min', 'nsBinds', 'only', 'propertyOrIdentifier', 'some', 'value']
exactly
module-attribute
exactly = Infix(lambda prop, _class: Restriction(prop, graph=graph, cardinality=_class))
logger
module-attribute
From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122
Python has the wonderful “in” operator and it would be nice to have additional infix operator like this. This recipe shows how (almost) arbitrary infix operators can be defined.
max
module-attribute
max = Infix(lambda prop, _class: Restriction(prop, graph=graph, maxCardinality=_class))
min
module-attribute
min = Infix(lambda prop, _class: Restriction(prop, graph=graph, minCardinality=_class))
nsBinds
module-attribute
nsBinds = {'skos': 'http://www.w3.org/2004/02/skos/core#', 'rdf': RDF, 'rdfs': RDFS, 'owl': OWL, 'list': URIRef('http://www.w3.org/2000/10/swap/list#'), 'dc': 'http://purl.org/dc/elements/1.1/'}
only
module-attribute
only = Infix(lambda prop, _class: Restriction(prop, graph=graph, allValuesFrom=_class))
some
module-attribute
some = Infix(lambda prop, _class: Restriction(prop, graph=graph, someValuesFrom=_class))
value
module-attribute
value = Infix(lambda prop, _class: Restriction(prop, graph=graph, value=_class))
AnnotatableTerms
Bases: Individual
Terms in an OWL ontology with rdfs:label and rdfs:comment
Interface with ATTEMPTO (http://attempto.ifi.uzh.ch/site)
Verbalisation of OWL entity IRIS
How are OWL entity IRIs verbalized?
The OWL verbalizer maps OWL entity IRIs to ACE content words such that
- OWL individuals map to ACE proper names (PN)
- OWL classes map to ACE common nouns (CN)
- OWL properties map to ACE transitive verbs (TV)
There are 6 morphological categories that determine the surface form of an IRI:
- singular form of a proper name (e.g. John)
- singular form of a common noun (e.g. man)
- plural form of a common noun (e.g. men)
- singular form of a transitive verb (e.g. mans)
- plural form of a transitive verb (e.g. man)
- past participle form a transitive verb (e.g. manned)
The user has full control over the eventual surface forms of the IRIs but has to choose them in terms of the above categories. Furthermore,
- the surface forms must be legal ACE content words (e.g. they should not contain punctuation symbols);
- the mapping of IRIs to surface forms must be bidirectional within the same word class, in order to be able to (if needed) parse the verbalization back into OWL in a semantics preserving way.
Using the lexicon
It is possible to specify the mapping of IRIs to surface forms using the following annotation properties:
http://attempto.ifi.uzh.ch/ace_lexicon#PN_sg
http://attempto.ifi.uzh.ch/ace_lexicon#CN_sg
http://attempto.ifi.uzh.ch/ace_lexicon#CN_pl
http://attempto.ifi.uzh.ch/ace_lexicon#TV_sg
http://attempto.ifi.uzh.ch/ace_lexicon#TV_pl
http://attempto.ifi.uzh.ch/ace_lexicon#TV_vbg
For example, the following axioms state that if the IRI “#man” is used as a plural common noun, then the wordform men must be used by the verbalizer. If, however, it is used as a singular transitive verb, then mans must be used.
<AnnotationAssertion>
<AnnotationProperty IRI="http://attempto.ifi.uzh.ch/ace_lexicon#CN_pl"/>
<IRI>#man</IRI>
<Literal datatypeIRI="&xsd;string">men</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty IRI="http://attempto.ifi.uzh.ch/ace_lexicon#TV_sg"/>
<IRI>#man</IRI>
<Literal datatypeIRI="&xsd;string">mans</Literal>
</AnnotationAssertion>
Methods:
Attributes:
Source code in rdflib/extras/infixowl.py
comment
class-attribute
instance-attribute
seeAlso
class-attribute
instance-attribute
handleAnnotation
setupACEAnnotations
Source code in rdflib/extras/infixowl.py
BooleanClass
Bases: OWLRDFListProxy, Class
See: http://www.w3.org/TR/owl-ref/#Boolean
owl:complementOf is an attribute of Class, however
Methods:
-
__or__–Adds other to the list and returns self
-
__repr__–Returns the Manchester Syntax equivalent for this class
-
changeOperator–Converts a unionOf / intersectionOf class expression into one
-
copy–Create a copy of this class
-
isPrimitive– -
serialize–
Attributes:
Source code in rdflib/extras/infixowl.py
__or__
__repr__
Returns the Manchester Syntax equivalent for this class
Source code in rdflib/extras/infixowl.py
changeOperator
Converts a unionOf / intersectionOf class expression into one that instead uses the given operator
>>> testGraph = Graph()
>>> Individual.factoryGraph = testGraph
>>> EX = Namespace("http://example.com/")
>>> testGraph.bind("ex", EX, override=False)
>>> fire = Class(EX.Fire)
>>> water = Class(EX.Water)
>>> testClass = BooleanClass(members=[fire,water])
>>> testClass
( ex:Fire AND ex:Water )
>>> testClass.changeOperator(OWL.unionOf)
>>> testClass
( ex:Fire OR ex:Water )
>>> try:
... testClass.changeOperator(OWL.unionOf)
... except Exception as e:
... print(e) # doctest: +SKIP
The new operator is already being used!
Source code in rdflib/extras/infixowl.py
copy
isPrimitive
serialize
Source code in rdflib/extras/infixowl.py
BooleanClassExtentHelper
>>> testGraph = Graph()
>>> Individual.factoryGraph = testGraph
>>> EX = Namespace("http://example.com/")
>>> testGraph.bind("ex", EX, override=False)
>>> fire = Class(EX.Fire)
>>> water = Class(EX.Water)
>>> testClass = BooleanClass(members=[fire, water])
>>> testClass2 = BooleanClass(
... operator=OWL.unionOf, members=[fire, water])
>>> for c in BooleanClass.getIntersections():
... print(c) # doctest: +SKIP
( ex:Fire AND ex:Water )
>>> for c in BooleanClass.getUnions():
... print(c) #doctest: +SKIP
( ex:Fire OR ex:Water )
Methods:
-
__call__–
Attributes:
-
operator–
Source code in rdflib/extras/infixowl.py
Callable
Class
Class(identifier=None, subClassOf=None, equivalentClass=None, disjointWith=None, complementOf=None, graph=None, skipOWLClassMembership=False, comment=None, nounAnnotations=None, nameAnnotation=None, nameIsLabel=False)
Bases: AnnotatableTerms
‘General form’ for classes:
The Manchester Syntax (supported in Protege) is used as the basis for the form of this class
See: http://owl-workshop.man.ac.uk/acceptedLong/submission_9.pdf:
[Annotation]
‘Class:’ classID {Annotation
( (‘SubClassOf:’ ClassExpression)
| (‘EquivalentTo’ ClassExpression)
| (’DisjointWith’ ClassExpression)) }
Appropriate excerpts from OWL Reference:
”.. Subclass axioms provide us with partial definitions: they represent necessary but not sufficient conditions for establishing class membership of an individual.”
”.. A class axiom may contain (multiple) owl:equivalentClass statements”
”..A class axiom may also contain (multiple) owl:disjointWith statements..”
”..An owl:complementOf property links a class to precisely one class description.”
Methods:
-
__and__–Construct an anonymous class description consisting of the
-
__eq__– -
__hash__–b = Class(OWL.Restriction)
-
__iadd__– -
__invert__–Shorthand for Manchester syntax’s not operator
-
__isub__– -
__or__–Construct an anonymous class description consisting of the union of
-
__repr__– -
isPrimitive– -
manchesterClass–Returns the Manchester Syntax equivalent for this class
-
serialize– -
setupNounAnnotations– -
subSumpteeIds–
Attributes:
-
annotation– -
comment– -
complementOf– -
disjointWith– -
equivalentClass– -
extent– -
extentQuery– -
parents– -
subClassOf–
Source code in rdflib/extras/infixowl.py
complementOf
class-attribute
instance-attribute
disjointWith
class-attribute
instance-attribute
equivalentClass
class-attribute
instance-attribute
extentQuery
class-attribute
instance-attribute
subClassOf
class-attribute
instance-attribute
__and__
Construct an anonymous class description consisting of the intersection of this class and ‘other’ and return it
Chaining 3 intersections
>>> exNs = Namespace("http://example.com/")
>>> g = Graph()
>>> g.bind("ex", exNs, override=False)
>>> female = Class(exNs.Female, graph=g)
>>> human = Class(exNs.Human, graph=g)
>>> youngPerson = Class(exNs.YoungPerson, graph=g)
>>> youngWoman = female & human & youngPerson
>>> youngWoman # doctest: +SKIP
ex:YoungPerson THAT ( ex:Female AND ex:Human )
>>> isinstance(youngWoman, BooleanClass)
True
>>> isinstance(youngWoman.identifier, BNode)
True
Source code in rdflib/extras/infixowl.py
__eq__
__hash__
__iadd__
__invert__
__isub__
__or__
Construct an anonymous class description consisting of the union of this class and ‘other’ and return it
Source code in rdflib/extras/infixowl.py
__repr__
isPrimitive
Source code in rdflib/extras/infixowl.py
manchesterClass
Returns the Manchester Syntax equivalent for this class
Source code in rdflib/extras/infixowl.py
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 | |
serialize
setupNounAnnotations
Source code in rdflib/extras/infixowl.py
ClassNamespaceFactory
EnumeratedClass
Bases: OWLRDFListProxy, Class
Class for owl:oneOf forms:
OWL Abstract Syntax is used
axiom ::= ‘EnumeratedClass(’ classID [‘Deprecated’] { annotation } { individualID } ‘)’
>>> exNs = Namespace("http://example.com/")
>>> g = Graph()
>>> g.bind("ex", exNs, override=False)
>>> Individual.factoryGraph = g
>>> ogbujiBros = EnumeratedClass(exNs.ogbujicBros,
... members=[exNs.chime,
... exNs.uche,
... exNs.ejike])
>>> ogbujiBros # doctest: +SKIP
{ ex:chime ex:uche ex:ejike }
>>> col = Collection(g, first(
... g.objects(predicate=OWL.oneOf, subject=ogbujiBros.identifier)))
>>> sorted([g.qname(item) for item in col])
['ex:chime', 'ex:ejike', 'ex:uche']
>>> print(g.serialize(format='n3')) # doctest: +SKIP
@prefix ex: <http://example.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<BLANKLINE>
ex:ogbujicBros a owl:Class;
owl:oneOf ( ex:chime ex:uche ex:ejike ) .
<BLANKLINE>
<BLANKLINE>
Methods:
-
__repr__–Returns the Manchester Syntax equivalent for this class
-
isPrimitive– -
serialize–
Source code in rdflib/extras/infixowl.py
__repr__
isPrimitive
serialize
Source code in rdflib/extras/infixowl.py
Individual
A typed individual, the base class of the InfixOWL classes.
Methods:
-
clearInDegree–Remove references to this individual as an object in the
-
clearOutDegree–Remove all statements to this individual as a subject in the
-
delete–Delete the individual from the graph, clearing the in and
-
replace–Replace the individual in the graph with the given other,
-
serialize–
Attributes:
-
factoryGraph– -
graph– -
identifier– -
qname– -
sameAs– -
type–
Source code in rdflib/extras/infixowl.py
identifier
class-attribute
instance-attribute
sameAs
class-attribute
instance-attribute
clearInDegree
Remove references to this individual as an object in the backing store.
clearOutDegree
Remove all statements to this individual as a subject in the backing store. Note that this only removes the statements themselves, not the blank node closure so there is a chance that this will cause orphaned blank nodes to remain in the graph.
Source code in rdflib/extras/infixowl.py
delete
replace
Replace the individual in the graph with the given other, causing all triples that refer to it to be changed and then delete the individual.
>>> g = Graph()
>>> b = Individual(OWL.Restriction, g)
>>> b.type = RDFS.Resource
>>> len(list(b.type))
1
>>> del b.type
>>> len(list(b.type))
0
Source code in rdflib/extras/infixowl.py
Infix
Methods:
-
__call__– -
__matmul__– -
__rlshift__– -
__rmatmul__– -
__rshift__–
Attributes:
-
function–
Source code in rdflib/extras/infixowl.py
__call__
__matmul__
__rlshift__
__rmatmul__
MalformedClass
Bases: ValueError
Deprecated
This class will be removed in version 7.0.0.
MalformedClassError
OWLRDFListProxy
Methods:
-
__contains__– -
__delitem__– -
__eq__–Equivalence of boolean class constructors is determined by
-
__getitem__– -
__iadd__– -
__iter__– -
__len__– -
__setitem__– -
append– -
clear– -
index–
Attributes:
-
graph–
Source code in rdflib/extras/infixowl.py
__contains__
__delitem__
__eq__
Equivalence of boolean class constructors is determined by equivalence of its members
Source code in rdflib/extras/infixowl.py
__getitem__
__iadd__
__iter__
__len__
__setitem__
append
clear
Ontology
Bases: AnnotatableTerms
The owl ontology metadata
Methods:
Attributes:
Source code in rdflib/extras/infixowl.py
imports
class-attribute
instance-attribute
Property
Property(identifier=None, graph=None, baseType=ObjectProperty, subPropertyOf=None, domain=None, range=None, inverseOf=None, otherType=None, equivalentProperty=None, comment=None, verbAnnotations=None, nameAnnotation=None, nameIsLabel=False)
Bases: AnnotatableTerms
axiom ::= 'DatatypeProperty(' datavaluedPropertyID ['Deprecated']
{ annotation }
{ 'super(' datavaluedPropertyID ')'} ['Functional']
{ 'domain(' description ')' } { 'range(' dataRange ')' } ')'
| 'ObjectProperty(' individualvaluedPropertyID ['Deprecated']
{ annotation }
{ 'super(' individualvaluedPropertyID ')' }
[ 'inverseOf(' individualvaluedPropertyID ')' ] [ 'Symmetric' ]
[ 'Functional' | 'InverseFunctional' |
'Functional' 'InverseFunctional' |
'Transitive' ]
{ 'domain(' description ')' } { 'range(' description ')' } ')
Methods:
-
__repr__– -
replace– -
serialize– -
setupVerbAnnotations–OWL properties map to ACE transitive verbs (TV)
Attributes:
Source code in rdflib/extras/infixowl.py
inverseOf
class-attribute
instance-attribute
subPropertyOf
class-attribute
instance-attribute
__repr__
Source code in rdflib/extras/infixowl.py
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 | |
replace
serialize
Source code in rdflib/extras/infixowl.py
setupVerbAnnotations
OWL properties map to ACE transitive verbs (TV)
There are 6 morphological categories that determine the surface form of an IRI:
- singular form of a transitive verb (e.g. mans)
- plural form of a transitive verb (e.g. man)
- past participle form a transitive verb (e.g. manned)
- http://attempto.ifi.uzh.ch/ace_lexicon#TV_sg
- http://attempto.ifi.uzh.ch/ace_lexicon#TV_pl
- http://attempto.ifi.uzh.ch/ace_lexicon#TV_vbg
Source code in rdflib/extras/infixowl.py
Restriction
Restriction(onProperty, graph=None, allValuesFrom=None, someValuesFrom=None, value=None, cardinality=None, maxCardinality=None, minCardinality=None, identifier=None)
Bases: Class
restriction ::= 'restriction('
datavaluedPropertyID dataRestrictionComponent
{ dataRestrictionComponent } ')'
| 'restriction(' individualvaluedPropertyID
individualRestrictionComponent
{ individualRestrictionComponent } ')'
Methods:
-
__eq__–Equivalence of restrictions is determined by equivalence of the
-
__hash__– -
__repr__–Returns the Manchester Syntax equivalent for this restriction
-
isPrimitive– -
restrictionKind– -
serialize–```python
Attributes:
-
allValuesFrom– -
cardinality– -
hasValue– -
maxCardinality– -
minCardinality– -
onProperty– -
restrictionKinds– -
restrictionRange– -
restrictionType– -
someValuesFrom–
Source code in rdflib/extras/infixowl.py
1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 | |
allValuesFrom
class-attribute
instance-attribute
cardinality
class-attribute
instance-attribute
hasValue
class-attribute
instance-attribute
maxCardinality
class-attribute
instance-attribute
minCardinality
class-attribute
instance-attribute
onProperty
class-attribute
instance-attribute
restrictionKinds
class-attribute
instance-attribute
restrictionKinds = [allValuesFrom, someValuesFrom, hasValue, cardinality, maxCardinality, minCardinality]
someValuesFrom
class-attribute
instance-attribute
__eq__
Equivalence of restrictions is determined by equivalence of the property in question and the restriction ‘range’
Source code in rdflib/extras/infixowl.py
__hash__
__repr__
isPrimitive
restrictionKind
Source code in rdflib/extras/infixowl.py
serialize
>>> g1 = Graph()
>>> g2 = Graph()
>>> EX = Namespace("http://example.com/")
>>> g1.bind("ex", EX, override=False)
>>> g2.bind("ex", EX, override=False)
>>> Individual.factoryGraph = g1
>>> prop = Property(EX.someProp, baseType=OWL.DatatypeProperty)
>>> restr1 = (Property(
... EX.someProp,
... baseType=OWL.DatatypeProperty)) @ some @ (Class(EX.Foo))
>>> restr1 # doctest: +SKIP
( ex:someProp SOME ex:Foo )
>>> restr1.serialize(g2)
>>> Individual.factoryGraph = g2
>>> list(Property(
... EX.someProp,baseType=None).type
... ) #doctest: +NORMALIZE_WHITESPACE +SKIP
[rdflib.term.URIRef(
'http://www.w3.org/2002/07/owl#DatatypeProperty')]
Source code in rdflib/extras/infixowl.py
AllClasses
AllDifferent
TODO: implement this function
DisjointClasses(’ description description { description } ‘)’
AllProperties
Source code in rdflib/extras/infixowl.py
CastClass
Source code in rdflib/extras/infixowl.py
CommonNSBindings
Takes a graph and binds the common namespaces (rdf,rdfs, & owl)
Source code in rdflib/extras/infixowl.py
ComponentTerms
Takes a Class instance and returns a generator over the classes that are involved in its definition, ignoring unnamed classes
Source code in rdflib/extras/infixowl.py
DeepClassClear
Recursively clear the given class, continuing where any related class is an anonymous class
>>> EX = Namespace("http://example.com/")
>>> g = Graph()
>>> g.bind("ex", EX, override=False)
>>> Individual.factoryGraph = g
>>> classB = Class(EX.B)
>>> classC = Class(EX.C)
>>> classD = Class(EX.D)
>>> classE = Class(EX.E)
>>> classF = Class(EX.F)
>>> anonClass = EX.someProp @ some @ classD
>>> classF += anonClass
>>> list(anonClass.subClassOf)
[Class: ex:F ]
>>> classA = classE | classF | anonClass
>>> classB += classA
>>> classA.equivalentClass = [Class()]
>>> classB.subClassOf = [EX.someProp @ some @ classC]
>>> classA
( ex:E OR ex:F OR ( ex:someProp SOME ex:D ) )
>>> DeepClassClear(classA)
>>> classA
( )
>>> list(anonClass.subClassOf)
[]
>>> classB
Class: ex:B SubClassOf: ( ex:someProp SOME ex:C )
>>> otherClass = classD | anonClass
>>> otherClass
( ex:D OR ( ex:someProp SOME ex:D ) )
>>> DeepClassClear(otherClass)
>>> otherClass
( )
>>> otherClass.delete()
>>> list(g.triples((otherClass.identifier, None, None)))
[]
Source code in rdflib/extras/infixowl.py
GetIdentifiedClasses
classOrIdentifier
Source code in rdflib/extras/infixowl.py
classOrTerm
generateQName
manchesterSyntax
Core serialization thing is a Class and is processed as a subject store is an RDFLib Graph to be queried about thing
Source code in rdflib/extras/infixowl.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |