/** * Loads the ontology */ private function loadOntology() { if ($this->allowCaching && file_exists(self::ONTOLOGY_FILE)) { $this->logger->info('Loading ontology from file.'); $this->ontology = unserialize(file_get_contents(self::ONTOLOGY_FILE)); } else { //Parse ontology schema pages $this->logger->info('Reading ontology...'); $ontologyPages = $this->loadAllPages($this->ontologySource); //Load ontology $ontologyReader = new OntologyReader(); $this->ontology = $ontologyReader->read($ontologyPages); LabelExtractor::addProperties($this->ontology); AbstractExtractor::addProperties($this->ontology); $this->destroyAllPages($ontologyPages); file_put_contents(self::ONTOLOGY_FILE, serialize($this->ontology)); //Show the extracted ontology $writer = new ontology\OWLOntologyWriter(); echo $writer->toOWL($this->ontology); } }
/** * @param $abstracts should properties for AbstractExtractor be added to ontology? * TODO: Create an interface ExtractorBuilder with methods addProperties() and createExtractor(). * Give this method an array of ExtractorBuilders. */ public function loadOntology($abstracts = true) { $ontologyPages = $this->loadAllPages($this->ontologyDir); $ontologyReader = new OntologyReader(); $ontology = $ontologyReader->read($ontologyPages); \dbpedia\mapping\LabelExtractor::addProperties($ontology); if ($abstracts) { \dbpedia\mapping\AbstractExtractor::addProperties($ontology); } $this->destroyAllPages($ontologyPages); return $ontology; }