Ejemplo n.º 1
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     # _:x rdf:type owl:Class .
     # _:x owl:unionOf T(SEQ CE1 ... CEn) .
     x = BNode()
     g.add((x, RDF.type, OWL.Class))
     g.add((x, OWL.unionOf, SEQ(g, self.classExpressions)))
     return x
Ejemplo n.º 2
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     # _:x rdf:type rdfs:Datatype .
     # _:x owl:oneOf T(SEQ lt1 ... ltn) .
     x = BNode()
     g.add((x, RDF.type, RDFS.Datatype))
     g.add((x, OWL.oneOf, SEQ(g, self.literal)))
     return x
Ejemplo n.º 3
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     # _:x rdf:type owl:Class .
     # _:x owl:oneOf T(SEQ a1 ... an) .
     x = BNode()
     g.add((x, RDF.type, OWL.Class))
     g.add((x, OWL.oneOf, SEQ(g, self.individuals)))
     return x
Ejemplo n.º 4
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     # _:x rdf:type owl:Class .
     # _:x owl:intersectionOf T(SEQ CE1 ... CEn) .
     subj = BNode()
     g.add((subj, RDF.type, OWL.Class))
     g.add((subj, OWL.intersectionOf, SEQ(g, self.classExpressions)))
     return subj
Ejemplo n.º 5
0
 def to_rdf(self, g: Graph) -> BNode:
     """
     _:x rdf:type owl:Class .
     _:x owl:unionOf T(SEQ CE1 ... CEn) .
     """
     rval = BNode()
     g.add((rval, RDF.type, OWL.Class))
     g.add((rval, OWL.unionOf, SEQ(g, self.classExpressions)))
     return rval
Ejemplo n.º 6
0
 def to_rdf(self, g: Graph) -> None:
     if len(self.individuals) == 2:
         self.add_triple(g, self.individuals[0].to_rdf(g),
                         OWL.differentFrom, self.individuals[1].to_rdf(g))
     elif len(self.individuals) > 2:
         subj = BNode()
         g.add((subj, RDF.type, OWL.AllDifferent))
         g.add((subj, OWL.memebers, SEQ(g, self.individuals)))
         self.TANN(g, subj)
     return None
Ejemplo n.º 7
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> None:
     if len(self.classExpressions) == 2:
         self.add_triple(g, self.classExpressions[0].to_rdf(g),
                         OWL.disjointWith,
                         self.classExpressions[1].to_rdf(g))
     else:
         subj = BNode()
         g.add((subj, RDF.type, OWL.AllDisjointClasses))
         g.add((subj, OWL.members, SEQ(g, self.classExpressions)))
         self.TANN(g, subj)
Ejemplo n.º 8
0
 def to_rdf(self, g: Graph) -> BNode:
     """
     _:x rdf:type owl:Class .
     _:x owl:oneOf T(SEQ a1 ... an) .
     :param g:
     :return:
     """
     rval = BNode()
     g.add((rval, RDF.type, OWL.Class))
     g.add((rval, OWL.oneOf, SEQ(g, self.individuals)))
     return rval
Ejemplo n.º 9
0
 def to_rdf(self, g: Graph) -> BNode:
     subj = BNode()
     if self.dataPropertyExpression >= 2:
         g.add((subj, RDF.type, OWL.Restriction))
         g.add((subj, OWL.onProperties, SEQ(g,
                                            self.dataPropertyExpression)))
         g.add((subj, OWL.allValuesFrom, self.dataRange.to_rdf(g)))
     else:
         g.add((subj, RDF.type, OWL.Restriction))
         g.add((subj, OWL.onProperties, self.dataPropertyExpression))
         g.add((subj, OWL.allValuesFrom, self.dataRange.to_rdf(g)))
Ejemplo n.º 10
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     # _:x rdf:type rdfs:Datatype .
     # _:x owl:onDatatype T(DT) .
     # _:x owl:withRestrictions T(SEQ _:y1 ... _:yn) .
     # _:y1 F1 lt1 .
     # ...
     # _:yn Fn ltn .
     x = BNode()
     g.add((x, RDF.type, RDFS.Datatype))
     g.add((x, OWL.onDatatype, self.datatype.to_rdf(g)))
     g.add((x, OWL.withRestrictions, SEQ(g, self.restrictions)))
     return x
Ejemplo n.º 11
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> None:
     # T(OPE1) owl:propertyDisjointWith T(OPE2) .
     # N > 2:
     #    _:x rdf:type owl:AllDisjointProperties .
     #    _:x owl:members T(SEQ OPE1 ... OPEn) .
     if len(self.objectPropertyExpressions) > 2:
         x = BNode()
         g.add((x, RDF.type, OWL.AllDisjointProperties))
         self.add_triple(g, x, OWL.members,
                         SEQ(g, self.objectPropertyExpressions))
     else:
         self.add_triple(g, self.objectPropertyExpressions[0].to_rdf(g),
                         OWL.propertyDisjointWith,
                         self.objectPropertyExpressions[1].to_rdf(g))
Ejemplo n.º 12
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> None:
     # N == 2
     #    T(a1) owl:differentFrom T(a2) .
     # N > 2
     #    _:x rdf:type owl:AllDifferent .
     #    _:x owl:members T(SEQ a1 ... an) .
     # TODO: Spec says members, tooling says "distinctMembers" -- error in spec?
     if len(self.individuals) == 2:
         self.add_triple(g, self.individuals[0].to_rdf(g),
                         OWL.differentFrom, self.individuals[1].to_rdf(g))
     elif len(self.individuals) > 2:
         subj = BNode()
         g.add((subj, RDF.type, OWL.AllDifferent))
         g.add((subj, OWL.distinctMembers, SEQ(g, self.individuals)))
         self.TANN(g, subj)
     return None
Ejemplo n.º 13
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     # N == 1
     #    _:x rdf:type owl:Restriction .
     #   _:x owl:onProperty T(DPE) .
     #    _:x owl:allValuesFrom T(DR) .
     # N >= 2
     #    _:x rdf:type owl:Restriction .
     #    _:x owl:onProperties T(SEQ DPE1 ... DPEn) .
     #    _:x owl:allValuesFrom T(DR) .
     subj = BNode()
     g.add((subj, RDF.type, OWL.Restriction))
     if len(self.dataPropertyExpressions) >= 2:
         g.add((subj, OWL.onProperties, SEQ(g,
                                            self.dataPropertyExpressions)))
     else:
         g.add((subj, OWL.onProperty,
                self.dataPropertyExpressions[0].to_rdf(g)))
     g.add((subj, OWL.allValuesFrom, self.dataRange.to_rdf(g)))
     return subj
Ejemplo n.º 14
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> None:
     # T(CE) owl:hasKey T(SEQ OPE1 ... OPEm DPE1 ... DPEn ) .
     self.add_triple(
         g, self.classExpression.to_rdf(g), OWL.hasKey,
         SEQ(g,
             self.objectPropertyExpressions + self.dataPropertyExpressions))
Ejemplo n.º 15
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> None:
     # 	T(C) owl:disjointUnionOf T(SEQ CE1 ... CEn) .
     self.add_triple(g, self.cls.to_rdf(g), OWL.disjointUnionOf,
                     SEQ(g, self.disjointClassExpressions))
Ejemplo n.º 16
0
 def to_rdf(self, g: Graph, emit_type_arc: bool = False) -> BNode:
     return SEQ(g, self.objectPropertyExpressions)
Ejemplo n.º 17
0
 def to_rdf(self, g: Graph) -> BNode:
     return SEQ(g, self.objectPropertyExpressions)
Ejemplo n.º 18
0
 def to_rdf(self, g: Graph) -> BNode:
     subj = BNode()
     g.add((subj, RDF.type, OWL.Class))
     g.add((subj, OWL.intersectionOf, SEQ(g, self.classExpressions)))
     return subj