CVS: spip/ecrire inc_index.php3, 1.49, 1.50 inc_version.php3, 1.291, 1.292 recherche.php3, 1.13, 1.14

Update of /home/spip-cvs/spip/ecrire
In directory miel:/tmp/cvs-serv4900/ecrire

Modified Files:
  inc_index.php3 inc_version.php3 recherche.php3
Log Message:
amélioration de la pertinence du moteur de recherche

Index: inc_index.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_index.php3,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- inc_index.php3 26 Jan 2004 20:56:32 -0000 1.49
+++ inc_index.php3 28 Jan 2004 00:00:46 -0000 1.50
@@ -350,6 +350,7 @@
}

// rechercher un mot dans le dico
+// retourne deux methodes : lache puis strict
function requete_dico($val) {
   $min_long = 3;

@@ -362,13 +363,14 @@
     // 3. composer la regexp pour les caracteres accentuables mais non accentues
     while (ereg("([aeiouyd])([a-z])", $val.' ', $match))
       $val = str_replace ($match[0], $match[1].'[-1-9]?[-1-9]?'.$match[2], $val);
- return "dico REGEXP '^$val'";
+ return array("dico REGEXP '^$val'", "dico REGEXP '^$val$'");
   }

   // cas normal
- if (strlen($val) > $min_long)
- return "dico LIKE '$val%'";
- else return "dico = '".$val."___'";
+ if (strlen($val) > $min_long) {
+ return array("dico LIKE '$val%'", "dico = '$val'");
+ } else
+ return array("dico = '".$val."___'", "dico = '".$val."___'");
}

@@ -383,23 +385,38 @@
   unset($h);

   // cherche les mots dans le dico
- while (list(, $val) = each($s))
- if ($rq = requete_dico ($val))
+ while (list(, $val) = each($s)) {
+ list($rq, $rq_strict) = requete_dico ($val);
+ if ($rq)
       $dico[] = $rq;
+ if ($rq_strict)
+ $dico_strict[] = $rq_strict;
+ }

   // compose la recherche dans l'index
+ if ($dico_strict) {
+ $query2 = "SELECT HEX(hash) AS hx FROM spip_index_dico WHERE ".join(" OR ", $dico_strict);
+ $result2 = spip_query($query2);
+ while ($row2 = spip_fetch_array($result2))
+ $h_strict[] = "0x".$row2["hx"];
+ }
   if ($dico) {
     $query2 = "SELECT HEX(hash) AS hx FROM spip_index_dico WHERE ".join(" OR ", $dico);
     $result2 = spip_query($query2);
     while ($row2 = spip_fetch_array($result2))
       $h[] = "0x".$row2["hx"];
   }
+ if ($h_strict)
+ $hash_recherche_strict = join(",", $h_strict);
+ else
+ $hash_recherche_strict = "0";
+
   if ($h)
     $hash_recherche = join(",", $h);
   else
     $hash_recherche = "0";

- return $hash_recherche;
+ return array($hash_recherche, $hash_recherche_strict);
}

?>

Index: inc_version.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_version.php3,v
retrieving revision 1.291
retrieving revision 1.292
diff -u -d -r1.291 -r1.292
--- inc_version.php3 4 Jan 2004 15:22:59 -0000 1.291
+++ inc_version.php3 28 Jan 2004 00:00:47 -0000 1.292
@@ -171,6 +171,7 @@
$auteur_session = '';
$connect_statut = '';
$hash_recherche = '';
+$hash_recherche_strict = '';

//

Index: recherche.php3

RCS file: /home/spip-cvs/spip/ecrire/recherche.php3,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- recherche.php3 20 Nov 2003 21:24:02 -0000 1.13
+++ recherche.php3 28 Jan 2004 00:00:47 -0000 1.14
@@ -47,7 +47,7 @@
$activer_moteur = (lire_meta('activer_moteur') == 'oui');
if ($activer_moteur) { // texte integral
   include_ecrire ('inc_index.php3');
- $hash_recherche = requete_hash ($recherche);
+ list($hash_recherche,) = requete_hash ($recherche);
   $query_articles_int = requete_txt_integral('article', $hash_recherche);
   $query_breves_int = requete_txt_integral('breve', $hash_recherche);
   $query_rubriques_int = requete_txt_integral('rubrique', $hash_recherche);