Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  *
  * @param $abstracts should AbstractExtractor be added? 
  * TODO: Create an interface ExtractorBuilder with methods addProperties() and createExtractor().
  * Give this method an array of ExtractorBuilders.
  */
 public function loadMappings($ontology, $context, $abstracts = true)
 {
     $mappingPages = $this->loadAllPages($this->mappingDir);
     $extractor = new ExtractionManager();
     $extractor->addExtractor(MappingExtractor::load($mappingPages, $ontology, $context));
     $extractor->addExtractor(\dbpedia\mapping\LabelExtractor::load($ontology, $context));
     if ($abstracts) {
         $extractor->addExtractor(\dbpedia\mapping\AbstractExtractor::load($ontology, $context));
     }
     $this->destroyAllPages($mappingPages);
     return $extractor;
 }