[Xapian-discuss] Xapian, PHP bindings and spellings correction

Bruno at Badiliz xapian at badiliz.fr
Tue Mar 3 11:23:31 GMT 2009


Olly Betts <olly <at> survex.com> writes:

> 
> On Mon, Mar 02, 2009 at 05:44:09PM +0000, James Aylett wrote:
> > On Mon, Mar 02, 2009 at 06:36:01PM +0100, Bruno at Badiliz wrote:
> > 
> > >                 $query = $qp->parse_query( $query_string ); //,
> > > XapianQueryParser::FLAG_SPELLING_CORRECTION);
> > 
> > Uncomment this, and then check $query->get_corrected_query_string().
> 
> But note that you'll also need to OR in the default flags (with the |
> operator) if you want them.
> 
> Cheers,
>     Olly
> 

Hello James
Hello Olly,

Thank you for your answer. I had tryed what you propose me... without succes.
Here was the first code I had tryed (the exception try part):


try {
  $database = new XapianDatabase( $_PATH.'/_inc/cache/xapian/pa' );
  $enquire = new XapianEnquire($database);
  $query_string = xapianEncode( $_GET['q'] );
  $rset = new XapianRSet();
  $qp = new XapianQueryParser();
  $stemmer = new XapianStem( 'french' );
  $qp->set_stemmer($stemmer);
  $qp->set_database($database);
  $qp->set_stemming_strategy( XapianQueryParser::STEM_SOME );
  $query = $qp->parse_query( $query_string , 
    XapianQueryParser::FLAG_PHRASE 
    | XapianQueryParser::FLAG_BOOLEAN 
    | XapianQueryParser::FLAG_LOVEHATE
    | XapianQueryParser::FLAG_SPELLING_CORRECTION 
  );
  print 'Corrected: '. $qp->get_corrected_query_string() .'<br />'."\n";
  print 'Parsed query is: '. $query->get_description() .'<br />'."\n";
  // Find the top 10 results for the query.
  ...
  // Display the results.
  ...
}

Even with this code, get_corrected_query_string()does not return any words even
with a misspell word "chaussuire"  in a database of 40000 doc and 436 doc which
contain "chaussure" without the "i" !!!

Can you see something wrong in this code ?
Thank you for your help

Best regards
Bruno 





More information about the Xapian-discuss mailing list