public function smarterDiffItOWLAxioms()
    {
        Timer::start('LiveUpdateDestination::diffItOWLAxioms::total');
        Timer::start('LiveUpdateDestination::diffItOWLAxioms::preparation');
        //a store is needed for language here
        $store = null;
        //$store = new SPARQLToRDFTriple($this->uri, $this->language);
        $propLangFilter = Options::getOption('stringPredicateWithForeignlanguages');
        $graphURI = Options::getOption('graphURI');
        $annotationGraphURI = Options::getOption('annotationGraphURI');
        //generate the regex filter according to namespaces
        //includes language properties
        foreach ($propLangFilter as $one) {
            $this->predicateFilterList[] = $one;
        }
        $tripleDiff = new TripleDiff($this->uri, $this->language, $this->predicateFilterList, $this->objectFilterList, $this->predicateObjectFilterList, $store);
        $filterForNotAnnotatedTriples = $tripleDiff->createFilter($this->predicateFilterList, $this->objectFilterList, $this->predicateObjectFilterList);
        //$langTriples = $store->getRDFTripleForLangProperties($propLangFilter);
        //create a filter for extractors
        $subjectpattern = $this->uri->toSPARULPattern($this->storespecific);
        /*
                    $extractedByPattern = RDFtriple::URI(DBM_ORIGIN)->toSPARULPattern($this->storespecific);
        
                    $extractorFilter = "";
                    $extTerms = array();
                    foreach ($this->activeExtractors as $one){
                         $u = new URI($one);
                         $extPattern = $u->toSPARULPattern($this->storespecific);
                         $extTerms[] = ' ?extractor = '.$extPattern.' ';
                    }
                    foreach ($this->purgeExtractors as $one){
                         $u = new URI($one);
                         $extPattern = $u->toSPARULPattern($this->storespecific);
                         $extTerms[] = ' ?extractor = '.$extPattern.' ';
                    }
                    $extractorFilter = 'FILTER ( '.TripleDiff::assembleTerms($extTerms,'||').') . ';
        */
        $preparation = Timer::stop('LiveUpdateDestination::diffItOWLAxioms::preparation');
        $this->log(TRACE, 'prep needed: ' . $preparation);
        //***********************
        //DELETE ALL NON STATIC TRIPLES
        //**********************
        //delete all triples with the current subject
        //according to the filters
        //do not delete special properties see below
        //Timer::start('LiveUpdateDestination::diffItOWLAxioms::notAnnotated');
        $deleteSPARUL['delete_with_subject_not_static'] = 'DELETE  FROM <' . $graphURI . '>
    { ' . $subjectpattern . ' ?p ?o }
WHERE {
    ' . $subjectpattern . ' ?p ?o .
    FILTER (' . $filterForNotAnnotatedTriples . ').
}';
        //***********************
        //LANGUAGE
        //***********************
        //delete all triples with the current subject
        //where the lang properties with string object
        //from other language version are given, which should stay
        $x = 0;
        //var_dump($langTriples);
        foreach ($propLangFilter as $one) {
            $u = new URI($one, false);
            $deleteSPARUL['delete_english' . $x++] = 'DELETE FROM GRAPH <' . $graphURI . '>
{ ' . $subjectpattern . ' ' . $u->toSPARULPattern($this->storespecific) . ' ?o }
WHERE {
    ' . $subjectpattern . ' ' . $u->toSPARULPattern($this->storespecific) . ' ?o .
    FILTER ( lang(?o) = \'en\').
}';
        }
        //****************************
        //DELETE ANNOTATIONS
        //****************************
        //delete the corresponding annotations
        $deleteSPARUL['delete_corresponding_annotations'] = 'DELETE  FROM <' . $annotationGraphURI . '>
    { ?axiom ?axp  ?axo .  }
WHERE {
    ?axiom <' . OWL_SUBJECT . '> ' . $subjectpattern . ' .
    ?axiom ?axp  ?axo .
}';
        //echo $deleteSPARUL['delete_corresponding_annotations'] ;die;
        //***********************
        //MISSING: DELETE ANOMALIES I.E. source Page
        //***********************
        //TODO go to infobox extractor and
        //add an annotation to all subject/rating objects to which subject they belong
        //and then delete them also
        /*
        $deleteSPARUL['delete_anomalies'] =
        'DELETE  FROM <' . $annotationGraphURI . '>
            { ?axiom ?axp  ?axo .  }
        WHERE {
            ?axiom <'.DBM_ONDELETECASCADE.'> '.$subjectpattern.' .
            ?axiom ?axp  ?axo .
        }';
        */
        //**********************
        //GENERATE NEW TRIPLES
        //**********************
        Timer::start('LiveUpdateDestination::diffItOWLAxioms::insertSPARULCreation');
        $insertSPARUL = array();
        $insertSPARUL['insert_triples'] = array();
        $insertSPARUL['insert_annotations'] = array();
        $globalannotationpattern = "";
        $globaltriplepattern = "";
        $this->log(DEBUG, 'number of triples: ' . count($this->tripleFromExtractor));
        foreach ($this->tripleFromExtractor as $triple) {
            $pattern = $triple->toSPARULPattern($this->storespecific);
            $insertSPARUL['insert_triples'][] = 'INSERT INTO GRAPH <' . $graphURI . '> { ' . $pattern . ' }';
            $globaltriplepattern .= $pattern . "\n";
            $annotations = $triple->getOWLAxiomAnnotations();
            Statistics::increaseCount('Total', 'createdAnnotations', count($annotations));
            if (count($annotations) > 0) {
                $pattern = "";
                foreach ($annotations as $ann) {
                    $current = $ann->toSPARULPattern($this->storespecific);
                    $pattern .= $current;
                    $globalannotationpattern .= $current . "\n";
                }
                //annotations for one triple are aggregated to one query
                $insertSPARUL['insert_annotations'][] = 'INSERT INTO GRAPH <' . $annotationGraphURI . '> { ' . $pattern . ' }';
            }
        }
        $this->log(DEBUG, 'number of annotation inserts: ' . count($insertSPARUL['insert_annotations']));
        $insertSPARUL['globalAnnotationPattern'] = 'INSERT INTO GRAPH <' . $annotationGraphURI . '> { ' . $globalannotationpattern . ' }';
        $insertSPARUL['globalTriplePattern'] = 'INSERT INTO GRAPH <' . $graphURI . '> { ' . $globaltriplepattern . ' }';
        $this->log(DEBUG, 'length globalTriplePattern: ' . strlen($insertSPARUL['globalTriplePattern']));
        $this->log(DEBUG, 'length globalAnnotationPattern: ' . strlen($insertSPARUL['globalAnnotationPattern']));
        Timer::stop('LiveUpdateDestination::diffItOWLAxioms::insertSPARULCreation');
        $result = array();
        $result['del'] = $deleteSPARUL;
        $result['ins'] = $insertSPARUL;
        Timer::stop('LiveUpdateDestination::diffItOWLAxioms::total');
        return $result;
    }
コード例 #2
0
    private function _odbc_sparul_delete_language_oneQuery($graphURI, $languageProperties)
    {
        //***********************
        //LANGUAGE
        //***********************
        //delete all triples with the current subject
        //where the lang properties with string object
        //from other language version are given, which should stay
        Timer::start('LiveUpdateDestination::_odbc_sparul_delete_english_total');
        $union = array();
        foreach ($languageProperties as $one) {
            $u = new URI($one, false);
            $union[] = '?p = ' . $u->toSPARULPattern();
        }
        $filter = TripleDiff::assembleTerms($union, '||');
        //$filter ='';
        $sparul = 'DELETE FROM  <' . $graphURI . '>
{ ' . $this->subjectSPARULpattern . ' ?p  ?o }
FROM  <' . $graphURI . '>
WHERE {
    ' . $this->subjectSPARULpattern . '  ?p  ?o .
    FILTER ( ' . $filter . ' && (lang(?o) = \'en\')).
}';
        if ($this->_odbc_sparul_execute($sparul)) {
            $this->counterDelete += 1;
        }
        Timer::stop('LiveUpdateDestination::_odbc_sparul_delete_english_total');
        $this->log(DEBUG, 'deleted language');
        //TESTS>>>>>>>>>>>>
        if (Options::getOption('debug_run_tests')) {
            $this->log(INFO, 'no test for language currently');
        }
        //TESTS<<<<<<<<<<<
    }