app/DoctrineMigrations/Version20140129151724.php
changeset 118 c3f9a6086f52
parent 113 e4f8c2479e78
child 119 a1cf7fac5c2d
equal deleted inserted replaced
117:ebcd5b67995e 118:c3f9a6086f52
    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(), [], 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);
    74         $i = 1;
    74         $i = 1;
    75         $nb_set = 0;
    75         $nb_set = 0;
    76         echo "\n".count($tags)." tags to search.";
    76         echo "\n".count($tags)." tags to search.";
    77         foreach($tags as $tag){
    77         foreach($tags as $tag){
    78         	$l = $tag->getLabel();
    78         	$l = $tag->getLabel();
    79         	$uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaUrl(), [], false, "wikiurl");
    79         	$uri = WikiTagUtils::getDbpediaUri($tag->getWikipediaUrl(), array(), false, "wikiurl");
    80         	$tag->setDbpediaUri($uri);
    80         	$tag->setDbpediaUri($uri);
    81         	$em->persist($tag);
    81         	$em->persist($tag);
    82             if($uri!=NULL && $uri!=""){
    82             if($uri!=NULL && $uri!=""){
    83                 $nb_set++;
    83                 $nb_set++;
    84             }
    84             }
   100         $i = 1;
   100         $i = 1;
   101         $nb_set = 0;
   101         $nb_set = 0;
   102         echo "\n".count($tags)." tags to search.";
   102         echo "\n".count($tags)." tags to search.";
   103         foreach($tags as $tag){
   103         foreach($tags as $tag){
   104         	$l = $tag->getLabel();
   104         	$l = $tag->getLabel();
   105         	$uri = WikiTagUtils::getDbpediaUri($tag->getLabel(), [], false);
   105         	$uri = WikiTagUtils::getDbpediaUri($tag->getLabel(), array(), false);
   106         	$tag->setDbpediaUri($uri);
   106         	$tag->setDbpediaUri($uri);
   107         	$em->persist($tag);
   107         	$em->persist($tag);
   108             if($uri!=NULL && $uri!=""){
   108             if($uri!=NULL && $uri!=""){
   109                 $nb_set++;
   109                 $nb_set++;
   110             }
   110             }