app/DoctrineMigrations/Version20140129151724.php
changeset 119 a1cf7fac5c2d
parent 118 c3f9a6086f52
child 121 ada5f3d8b5b4
equal deleted inserted replaced
118:c3f9a6086f52 119:a1cf7fac5c2d
    40         $listenerInst || die('Listener is not registered in the event manager');
    40         $listenerInst || die('Listener is not registered in the event manager');
    41         $evm = $em->getEventManager();
    41         $evm = $em->getEventManager();
    42         $evm->removeEventListener(array('onFlush', 'preRemove', 'postPersist', 'postUpdate',  'postRemove'), $listenerInst);
    42         $evm->removeEventListener(array('onFlush', 'preRemove', 'postPersist', 'postUpdate',  'postRemove'), $listenerInst);
    43         
    43         
    44         // First step : we populate the dbpedia uris thanks to the dbpedia-owl:wikiPageID
    44         // First step : we populate the dbpedia uris thanks to the dbpedia-owl:wikiPageID
    45 //         echo "\nFIRST STEP";
    45         echo "\nFIRST STEP";
    46 //         $query = $em->createQuery('SELECT t FROM WikiTagBundle:Tag t WHERE t.wikipediaPageId IS NOT NULL ORDER BY t.label ASC');//->setMaxResults(240)->setFirstResult(500);
    46         $query = $em->createQuery('SELECT t FROM WikiTagBundle:Tag t WHERE t.wikipediaPageId IS NOT NULL ORDER BY t.label ASC');//->setMaxResults(240)->setFirstResult(500);
    47 //         $tags = $query->getResult();
    47         $tags = $query->getResult();
    48 //         $i = 1;
    48         $i = 1;
    49 //         $nb_set = 0;
    49         $nb_set = 0;
    50 //         echo "\n".count($tags)." tags to search.";
    50         echo "\n".count($tags)." tags to search.";
    51 //         foreach($tags as $tag){
    51         foreach($tags as $tag){
    52 //         	$l = $tag->getLabel();
    52         	$l = $tag->getLabel();
    53 //         	$uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaPageId(), array(), false, "pageid");
    53         	$uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaPageId(), array(), false, "pageid");
    54 //         	$tag->setDbpediaUri($uri);
    54         	$tag->setDbpediaUri($uri);
    55 //         	$em->persist($tag);
    55         	$em->persist($tag);
    56 // 	        if($uri!=NULL && $uri!=""){
    56 	        if($uri!=NULL && $uri!=""){
    57 // 	            $nb_set++;
    57 	            $nb_set++;
    58 // 	        }
    58 	        }
    59 //         	if( $i % 50 == 0 ){
    59         	if( $i % 50 == 0 ){
    60 //         		$em->flush();
    60         		$em->flush();
    61 //         		echo "\n    FLUSH";
    61         		echo "\n    FLUSH";
    62 //         	}
    62         	}
    63 //         	$i++;
    63         	$i++;
    64 //         	echo "\n$i : $l \t\t: $uri";
    64         	echo "\n$i : $l \t\t: $uri";
    65 //         }
    65         }
    66 //         $em->flush();
    66         $em->flush();
    67 //         echo "\nFIRST STEP : $nb_set uris found";
    67         echo "\nFIRST STEP : $nb_set uris found";
    68         
    68         
    69         
    69         
    70         // Second step : we populate the dbpedia uris not found thanks to the foaf:isPrimaryTopicOf
    70         // Second step : we populate the dbpedia uris not found thanks to the foaf:isPrimaryTopicOf
    71         echo "\nSECOND STEP";
    71         echo "\nSECOND STEP";
    72         $query = $em->createQuery('SELECT t FROM WikiTagBundle:Tag t WHERE (t.wikipediaUrl!=\'\' AND t.wikipediaUrl IS NOT NULL AND (t.dbpediaUri=\'\' OR t.dbpediaUri IS NULL)) ORDER BY t.label ASC');//->setMaxResults(240);
    72         $query = $em->createQuery('SELECT t FROM WikiTagBundle:Tag t WHERE (t.wikipediaUrl!=\'\' AND t.wikipediaUrl IS NOT NULL AND (t.dbpediaUri=\'\' OR t.dbpediaUri IS NULL)) ORDER BY t.label ASC');//->setMaxResults(240);