On Fri, Jul 06, 2007 at 11:18:09PM -0400, Mitchell Curtis Hatter wrote: > Hi, > > I've implemented synonym searching in my rails application but have > an idea I'd like to implement but can't figure out how to do. The > idea is that I'd like to give the end user the choice on whether to > search for the synonym of a word or not. Preferably by extending the > query language to parse a construct similar to '%word1' and then have > the word turned into a or list (i.e., word1|word2|word3|...). > > Currently, the query parser constantly calls SynonymTokenFilter to > get synonyms for each token. Is there a way I can go about achieving > this functionality?
You have to extend Ferret's Query Parser to achieve this. If you don't want to mess around with the grammar stuff the parser code is generated from, you could also preprocess user queries to modify them accordingly before giving them to the QueryParser. Can get complicated, too ;-) Atm you're doing the synonym stuff twice, once at indexing time and once when Queries are parsed. Because of the insertion of synonyms in the index at indexing time, adding synonyms to Queries is not really needed any more. So you don't really want to specify your SynonymAnalyzer for aaf as the analyzer to use for indexing and searching (aaf doesn't support different analyzers for indexing/searching bec. in general it's a good idea to use the same analyzer in both cases). If you used plain Ferret and wanted Synonyms everywhere or in a specific field, but for ALL queries, you could use your Analyzer at indexing time, but not for Query parsing. In your case, using your WordnetEngine in a customized QueryParser or a custom query preprocessor would be the better way. > Here's an overview of what I've done so far: [..] That's really cool stuff, would you mind posting this to Ferret's Wiki so other people can more easily find it? If you included the WordnetSynonymEngine that would be even better :-) Cheers, Jens -- Jens Krämer webit! Gesellschaft für neue Medien mbH Schnorrstraße 76 | 01069 Dresden Telefon +49 351 46766-0 | Telefax +49 351 46766-66 [EMAIL PROTECTED] | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

