Example #1
0
 /**
  * Loads the mappings
  */
 private function loadMappings()
 {
     $this->extractor = new ExtractionManager();
     //Parse mapping pages
     if ($this->allowCaching && file_exists(self::MAPPINGS_FILE)) {
         $this->logger->info('Loading mappings from file.');
         $mappingExtractor = unserialize(file_get_contents(self::MAPPINGS_FILE));
         if ($mappingExtractor && $mappingExtractor->getContext() != $this->context) {
             $this->logger->info('Discarding cached mappings as context differs');
             unset($mappingExtractor);
         } else {
             /* Hack: Re-open the quad destination file and assume the context from the extractor */
             $mappingExtractor->getContext()->getDestinations()->getDestination('destination id')->open();
             $this->context = $mappingExtractor->getContext();
         }
     }
     if (!isset($mappingExtractor)) {
         $this->logger->info('Reading mapping definitions...');
         $mappingPages = $this->loadAllPages($this->mappingsSource);
         $this->logger->info('Building mapping definitions...');
         $mappingExtractor = MappingExtractor::load($mappingPages, $this->ontology, $this->context);
         $this->destroyAllPages($mappingPages);
         file_put_contents(self::MAPPINGS_FILE, serialize($mappingExtractor));
     }
     $this->extractor->addExtractor($mappingExtractor);
     //echo $this->extractor;
 }
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;
 }