def parse_ontology(self): for subj, pred, obj in self._schema_nodes(): leaves = [(subj, pred, obj)] if type(obj) == rt.BNode: leaves = deepest_node((subj, pred, obj), self.graph) for s,p,o in leaves: if s not in self.attributes_by_class[self.source] and not isinstance(s, rt.BNode): self.attributes_by_class[self.source].append(s)
def parse_ontology(self): self.attributes_by_class = defaultdict(list, self.attributes_by_class) for subj, pred, obj in self._schema_nodes(): leaves = [(subj, pred, obj)] if type(obj) == rt.BNode: leaves = deepest_node((subj, pred, obj), self.graph) for s,p,o in leaves: if s not in self.attributes_by_class[self.source] and not isinstance(s, rt.BNode): self.attributes_by_class[self.source].append(s)
def parse_ontology(self): """place the ontology graph into a set of custom data structures for use by the validator""" for subj, pred, obj in self._schema_nodes(): leaves = [(subj, pred, obj)] if type(obj) == rt.BNode: leaves = deepest_node((subj, pred, obj), self.graph) for s, p, o in leaves: if pred == rt.URIRef(self.lexicon["domain"]): self.attributes_by_class[o].append(subj)
def parse_ontology(self): """place the ontology graph into a set of custom data structures for use by the validator""" start = time.clock() log.info("Parsing ontology file for {}".format(self.__class__.__name__)) for subj, pred, obj in self._schema_nodes(): if subj not in self.attributes_by_class.keys(): if obj == rt.URIRef(self.lexicon["class"]) and pred == rt.URIRef(self.lexicon["type"]): self.attributes_by_class[subj] = [] leaves = [(subj, pred, obj)] if type(obj) == rt.BNode: leaves = deepest_node((subj, pred, obj), self.graph) for s, p, o in leaves: if o not in self.attributes_by_class.keys(): self.attributes_by_class[o] = [] if pred == rt.URIRef(self.lexicon["domain"]): self.attributes_by_class[o].append(subj) log.info("Ontology parsing complete in {}".format((time.clock() - start) * 1000))
def parse_ontology(self): """place the ontology graph into a set of custom data structures for use by the validator""" start = time.clock() log.info("Parsing ontology file for {}".format( self.__class__.__name__)) for subj, pred, obj in self._schema_nodes(): if subj not in self.attributes_by_class.keys(): if obj == rt.URIRef( self.lexicon['class']) and pred == rt.URIRef( self.lexicon['type']): self.attributes_by_class[subj] = [] leaves = [(subj, pred, obj)] if type(obj) == rt.BNode: leaves = deepest_node((subj, pred, obj), self.graph) for s, p, o in leaves: if o not in self.attributes_by_class.keys(): self.attributes_by_class[o] = [] if pred == rt.URIRef(self.lexicon['domain']): self.attributes_by_class[o].append(subj) log.info("Ontology parsing complete in {}".format( (time.clock() - start) * 1000))