コード例 #1
0
ファイル: OWLRLExtras.py プロジェクト: pombredanne/OWL-RL
	def one_time_rules(self) :
		"""
		This method is invoked only once at the beginning, and prior of, the forward chaing process.

		At present, only the L{subsumption of restricted datatypes<_subsume_restricted_datatypes>} is performed.
		"""
		RDFS_OWLRL_Semantics.one_time_rules(self)
		# it is important to flush the triples at this point, because
		# the handling of the restriction datatypes rely on the datatype
		# subsumption triples added by the superclass
		self.flush_stored_triples()
		self._subsume_restricted_datatypes()
コード例 #2
0
ファイル: OWLRLExtras.py プロジェクト: pombredanne/OWL-RL
	def rules(self, t, cycle_num) :
		"""
		Go through the additional rules implemented by this module.
		@param t: a triple (in the form of a tuple)
		@param cycle_num: which cycle are we in, starting with 1. This value is forwarded to all local rules; it is also used
		locally to collect the bnodes in the graph.
		"""
		RDFS_OWLRL_Semantics.rules(self, t, cycle_num)
		z, q, x = t
		if q == hasSelf :
			for p in self.graph.objects(z, onProperty) :
				for y in self.graph.subjects( rdfType, z ) :
					self.store_triple((y, p, y))
				for y1, y2 in self.graph.subject_objects(p) :
					if y1 == y2 :
						self.store_triple((y1, rdfType, z))
コード例 #3
0
ファイル: OWLRLExtras.py プロジェクト: pombredanne/OWL-RL
	def __init__(self, graph, axioms, daxioms, rdfs = False) :
		"""
		@param graph: the RDF graph to be extended
		@type graph: rdflib.Graph
		@param axioms: whether (non-datatype) axiomatic triples should be added or not
		@type axioms: Boolean
		@param daxioms: whether datatype axiomatic triples should be added or not
		@type daxioms: Boolean
		@param rdfs: whether RDFS extension is done 
		@type rdfs: boolean
		"""
		RDFS_OWLRL_Semantics.__init__(self, graph, axioms, daxioms, rdfs )
		self.rdfs = rdfs
		self.add_new_datatype(ns_owl["rational"], _strToRational, OWL_RL_Datatypes, 
						      subsumption_dict = OWL_Datatype_Subsumptions, 
						      subsumption_key  = ns_xsd["decimal"], 
						      subsumption_list = [ns_owl["rational"]])
		
		self.restricted_datatypes = extract_faceted_datatypes(self, graph)
		for dt in self.restricted_datatypes :
			self.add_new_datatype(dt.datatype, dt.toPython, OWL_RL_Datatypes,
								  subsumption_dict = OWL_Datatype_Subsumptions,
								  subsumption_key  = dt.datatype,
								  subsumption_list = [ dt.base_type ])
コード例 #4
0
ファイル: OWLRLExtras.py プロジェクト: pombredanne/OWL-RL
	def add_axioms(self) :
		"""
		Add the L{extra axioms<OWLRL_Extension.extra_axioms>}, related to the self restrictions.
		"""
		RDFS_OWLRL_Semantics.add_axioms(self)
		for t in self.extra_axioms : self.graph.add(t)