Utils/WikiTagUtils.php
changeset 43 54f204bceb28
parent 42 0e57c730bb18
child 50 e967654e90cb
--- a/Utils/WikiTagUtils.php	Fri Nov 25 18:55:42 2011 +0100
+++ b/Utils/WikiTagUtils.php	Sun Nov 27 22:36:21 2011 +0100
@@ -22,19 +22,30 @@
         }
         $tag_label = trim($tag_label);//tag.strip()
         $tag_label = str_replace("_", " ", $tag_label);//tag.replace("_", " ")
-        $tag_label = str_replace("Œ", "oe", $tag_label);
-        $tag_label = str_replace("œ", "oe", $tag_label);
-        $tag_label = preg_replace('/\s+/', ' ', $tag_label);//" ".join(tag.split())
+        $tag_label = preg_replace('/\s+/u', ' ', $tag_label);//" ".join(tag.split())
         $tag_label = ucfirst($tag_label);//tag[0].upper() + tag[1:]
         return $tag_label;
     }
     
     /**
+     * Query wikipedia with a normalized label or a pageid
+     * return an array with the form
+     * array(
+     *      'new_label'=>$new_label,
+     *   	'alternative_label'=>$alternative_label,
+     *   	'status'=>$status,
+     *   	'wikipedia_url'=>$url,
+     *      'wikipedia_alternative_url'=>$alternative_url,
+     *   	'pageid'=>$pageid,
+     *   	'alternative_pageid'=>$alternative_pageid,
+     *   	'dbpedia_uri'=>$dbpedia_uri,
+     *   	'revision_id'=> ,
+     *   	'response'=> the original wikipedia json response
+     *   	)
      *
-     * TODO: Enter description here ...
-     * @param unknown_type $tag_label_normalized
-     * @param unknown_type $page_id
-     * @return multitype:NULL unknown |multitype:Ambigous <NULL, unknown> multitype:number  mixed Ambigous <NULL, string> Ambigous <unknown, mixed>
+     * @param string $tag_label_normalized
+     * @param bigint $page_id
+     * @return array
      */
     public static function getWikipediaInfo($tag_label_normalized, $page_id=null)
     {
@@ -86,7 +97,6 @@
         $alternative_pageid = null;
         if($status==Tag::$TAG_URL_STATUS_DICT["redirection"])
         {
-            //TODO: add alternative label
             $params['redirects'] = "true";
             $ar = WikiTagUtils::requestWikipedia($params);
             $res = $ar[0];
@@ -139,10 +149,10 @@
     
 
     /**
+     * build and do the request to Wikipedia.
      *
-     * TODO : Enter description here ...
-     * @param unknown_type $params
-     * @return multitype:unknown mixed
+     * @param array $params
+     * @return array
      */
     private static function requestWikipedia($params)
     {