コード例 #1
0
 public function __construct(URI $subject, $language)
 {
     $this->subject = $subject;
     $this->language = $language;
     $this->use = Options::getOption('Sparql.use');
     if ($this->use == 'odbc') {
         $this->odbc = ODBC::getDefaultConnection();
     } else {
         $this->sparqlEndpoint = SPARQLEndpoint::getDefaultEndpoint();
     }
 }
コード例 #2
0
ファイル: Hash.php プロジェクト: ljarray/dbpedia
 public function __construct($oaiId, $subject)
 {
     $this->subject = $subject;
     //$this->subjectOAIidentifier = $subjectOAIidentifier;
     //	$this->language = $language;
     $this->oaiId = $oaiId;
     $this->log(INFO, "_construct: " . $this->oaiId . " " . $this->subject);
     if (Options::getOption('LiveUpdateDestination.useHashForOptimization')) {
         $this->odbc = ODBC::getDefaultConnection();
         $this->hasHash = $this->_retrieveHashValues();
         $this->active = true;
     }
 }
 public function finish()
 {
     $generateOWLAxiomAnnotations = Options::getOption('generateOWLAxiomAnnotations');
     if ($generateOWLAxiomAnnotations) {
         Timer::start('LiveUpdateDestination::diffItOWLAxioms');
         //$result = $this->diffItOWLAxioms();
         $result = $this->smarterDiffItOWLAxioms();
         Timer::stop('LiveUpdateDestination::diffItOWLAxioms');
     } else {
         Timer::start('LiveUpdateDestination::diffItSimple');
         $result = $this->diffItSimple();
         Timer::stop('LiveUpdateDestination::diffItSimple');
     }
     $graphURI = Options::getOption('graphURI');
     $deleteSPARUL = $result['del'];
     $insertSPARUL = $result['ins'];
     if (Options::getOption('writeSPARULtoFiles')) {
         $this->writeSPARULtoFiles($deleteSPARUL, $insertSPARUL);
     }
     $odbc = ODBC::getDefaultConnection();
     /*
             $iconfirm = Options::getOption('iconfirmthaticheckedthestringsbelow');
             $dryRun = false;
             if(($generateOWLAxiomAnnotations==true) && ($iconfirm==false )){
     
                 $dryRun = true;
                 $this->log(WARN, 'This will be a dry run, see dbpedia.ini iconfirmthaticheckedthestringsbelow');
                 sleep (4);
                 }
     
             $dryRun = ($dryRun || Options::getOption('dryRun'));
     */
     // LOADING into STORE
     Timer::start('LiveUpdateDestination::loadIntoVirtuoso');
     if ($generateOWLAxiomAnnotations) {
         $this->loadIntoVirtuoso($odbc, $deleteSPARUL, $insertSPARUL, $graphURI);
     } else {
         $this->loadIntoVirtuosoSimple($odbc, $deleteSPARUL, $insertSPARUL, $graphURI);
     }
     Timer::stop('LiveUpdateDestination::loadIntoVirtuoso');
     //Logger::debug($this->tripleDiff->createSPARQLQuery());
     //odbc_close_all();
 }
コード例 #4
0
 private function _primaryStrategy()
 {
     /*
      * PREPARATION
      *
      * */
     if (!TheContainer::wasSet(LUD_SPARQLFILTER)) {
         $store = null;
         $tripleDiff = new TripleDiff($this->uri, $this->language, $this->producesFilterList, $store);
         TheContainer::set(LUD_SPARQLFILTER, $tripleDiff->createFilter($this->producesFilterList));
     }
     $this->odbc = ODBC::getDefaultConnection();
     $graphURI = $this->graphURI;
     $annotationGraphURI = $this->annotationGraphURI;
     $generateOWLAxiomAnnotations = $this->generateOWLAxiomAnnotations;
     /*
      * STRATEGIES FOR DELETION
      * */
     Timer::start('LiveUpdateDestination::_odbc_sparul_delete_total');
     $this->_odbc_clean_sparul_delete_subresources();
     $this->_odbc_sparul_delete_subject_not_static($graphURI, $this->subjectSPARULpattern, TheContainer::get(LUD_SPARQLFILTER));
     //$this->_odbc_sparul_delete_language($graphURI, $languageProperties );
     //$this->_odbc_sparul_delete_language_oneQuery($graphURI, $languageProperties );
     Timer::stop('LiveUpdateDestination::_odbc_sparul_delete_total');
     /*
      * STRATEGIES FOR INSERTION
      * will do nothing if Options::getOption('debug_turn_off_insert') is true
      * */
     $this->_odbc_ttlp_insert_triples($this->tripleFromExtractor);
     $this->log(INFO, 'no of queries, insert: ' . $this->counterInserts . ' delete: ' . $this->counterDelete . ' odbc_total: ' . $this->counterTotalODBCOperations);
     /*
             if(Options::getOption('writeSPARULtoFiles')){
                 $this->writeSPARULtoFiles($deleteSPARUL, $insertSPARUL);
             }
     */
 }
コード例 #5
0
 public function start($language)
 {
     $this->language = $language;
     $this->parseHintToTripleGenerator = self::createParseHintToTripleGeneratorMap($language);
     //$this->defaultTripleGenerator = new DefaultTripleGenerator($language);
     // Initialize database connection
     if (false == Options::getOption('LiveMappingBased.useTemplateDb')) {
         $this->templateDb = new DummyTemplateDb();
     } else {
         $odbc = ODBC::getDefaultConnection();
         //$odbc = new ODBC("VOS", "dbpedia", "dbpedia");
         $this->templateDb = new TemplateDb($odbc);
     }
     // Initialize the template name filter
     $this->templateNameFilter = new AndCompoundFilter(array(new LegacyTemplateFilter(), new TemplateFilter()));
     $mediaWikiUtil = MediaWikiUtil::getInstance("http://en.wikipedia.org/wiki/");
     $this->rootTripleGenerator = new RootTripleGenerator($this->language, $this->templateNameFilter, $this->templateDb, $this->parseHintToTripleGenerator, $mediaWikiUtil);
 }
コード例 #6
0
 private function _alternativeStrategy()
 {
     /*
      * PREPARATION
      *
      * */
     $languageProperties = $this->languageProperties;
     //$this->_prepare($languageProperties);
     $this->odbc = ODBC::getDefaultConnection();
     $graphURI = $this->graphURI;
     $annotationGraphURI = $this->annotationGraphURI;
     $generateOWLAxiomAnnotations = $this->generateOWLAxiomAnnotations;
     //echo TheContainer::get(LUD_SPARQLFILTERWITHLANGUAGES ) ;
     /*GET TRIPLES*/
     $store = new SPARQLToRDFTriple($this->uri, $this->language);
     $tripleDiff = new TripleDiff($this->uri, $this->language, $this->producesFilterList, $store);
     $diff = $tripleDiff->simplerDiff($this->tripleFromExtractor);
     $this->odbc = ODBC::getDefaultConnection();
     $fromStore = $diff['triplesFromStore'];
     $subResourceAsObjectStore = $diff['subResourceAsObjectStore'];
     $this->_alt_delete_all_triples_RDFTripleArray($fromStore);
     $this->_alt_delete_subresources($subResourceAsObjectStore);
     if ($generateOWLAxiomAnnotations) {
         $this->_odbc_sparul_delete_annotations();
         $this->_odbc_sparul_delete_Annotations_of_subResources('alternative');
     }
     /*
      * STRATEGIES FOR INSERTION
      * */
     Timer::start('LiveUpdateDestination::_odbc_insert_total');
     //$this->_odbc_sparul_insert_triples_and_annotations($graphURI,$annotationGraphURI,$generateOWLAxiomAnnotations);
     $this->_odbc_ttlp_insert_triples($this->tripleFromExtractor);
     $this->_odbc_ttlp_insert_annotations($this->tripleFromExtractor);
     //$this->_odbc_ttlp_insert_triples_and_annotations($this->tripleFromExtractor);
     Timer::stop('LiveUpdateDestination::_odbc_insert_total');
     $this->log(INFO, 'no of queries, insert: ' . $this->counterInserts . ' delete: ' . $this->counterDelete . ' odbc_total: ' . $this->counterTotalODBCOperations);
 }
コード例 #7
0
ファイル: maintenance.php プロジェクト: ljarray/dbpedia
<?php

include 'dbpedia.php';
$storespecific = VIRTUOSO;
$graphURI = 'http://dbpedia.org';
$annotationGraphURI = 'http://dbpedia.org/meta';
$odbc = ODBC::getDefaultConnection();
$odbc->connect();
$total = 0;
while (count($triples = getAnnotations($graphURI)) > 0) {
    $total += deleteSubjects($odbc, $graphURI, $triples, $storespecific);
    echo 'executed ' . $total . ' delete queries' . "\n";
}
//deleteTriples($odbc,$graphURI, $triples, $storespecific);
function getAnnotations($graphURI)
{
    $lang = 'en';
    $store = new SPARQLToRDFTriple(null, $lang);
    $query = 'SELECT * FROM <' . $graphURI . '> WHERE {
			?s <' . RDF_TYPE . '> <' . OWL_AXIOM . '> .
			FILTER (isURI(?s))
		} Limit 100';
    //$subject =array('action'=>'classattribute','value'=>null);
    $subject = array('action' => 'variable', 'value' => 's');
    $predicate = array('action' => 'fix', 'value' => OWL_SUBJECT);
    $object = array('action' => 'fix', 'value' => OWL_AXIOM);
    Logger::debug($query);
    $triples = $store->getRDFTriples($query, $subject, $predicate, $object, false);
    Logger::debug('retrieved: ' . count($triples) . ' triples');
    return $triples;
}