lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Synonyms for AND/OR/NOT operators
Date Tue, 21 Dec 2004 09:28:20 GMT
On Dec 21, 2004, at 3:04 AM, Sanyi wrote:
> What is the simplest way to add synonyms for AND/OR/NOT operators?
> I'd like to support two sets of operator words, so people can use 
> either the original english
> operators and my custom ones for our local language.

There are two options that I know of: 1) add synonyms during indexing 
and 2) add synonyms during querying.  Generally this would be done 
using a custom analyzer.

If the synonym mappings are static and you don't mind a larger index, 
adding them during indexing avoids the complexity of rewriting the 
query.  Injecting synonyms during querying allows the synonym mappings 
to change dynamically, though does produce more complex queries.  
Here's an example you'll find with the source code distribution of 
Lucene in Action which uses WordNet to look up synonyms.

	Erik

p.s. I'm sensitive to over-marketing Lucene in Action in this forum as 
it would bother me to constantly see an advertisement.  You can be sure 
that any mentions of it from me will coincide with concrete examples 
(which are freely available) that are directly related to questions 
being asked.


% ant -emacs SynonymAnalyzerViewer
Buildfile: build.xml

check-environment:

compile:

build-test-index:

build-perf-index:

prepare:

SynonymAnalyzerViewer:

       Using a custom SynonymAnalyzer, two fixed strings are
       analyzed with the results displayed.  Synonyms, from the
       WordNet database, are injected into the same positions
       as the original words.

       See the "Analysis" chapter for more on synonym injection and
       position increments.  The "Tools and extensions" chapter covers
       the WordNet feature found in the Lucene sandbox.

Press return to continue...

Running lia.analysis.synonym.SynonymAnalyzerViewer...

1: [quick] [warm] [straightaway] [spry] [speedy] [ready] [quickly] 
[promptly] [prompt] [nimble] [immediate] [flying] [fast] [agile]
2: [brown] [brownness] [brownish]
3: [fox] [trick] [throw] [slyboots] [fuddle] [fob] [dodger] 
[discombobulate] [confuse] [confound] [befuddle] [bedevil]
4: [jumps]
5: [over] [o] [across]
6: [lazy] [faineant] [indolent] [otiose] [slothful]
7: [dogs]

1: [oh]
2: [we]
3: [get] [acquire] [aim] [amaze] [arrest] [arrive] [baffle] [beat] 
[become] [beget] [begin] [bewilder] [bring] [can] [capture] [catch] 
[cause] [come] [commence] [contract] [convey] [develop] [draw] [drive] 
[dumbfound] [engender] [experience] [father] [fetch] [find] [fix] 
[flummox] [generate] [go] [gravel] [grow] [have] [incur] [induce] [let] 
[make] [may] [mother] [mystify] [nonplus] [obtain] [perplex] [produce] 
[puzzle] [receive] [scram] [sire] [start] [stimulate] [stupefy] 
[stupify] [suffer] [sustain] [take] [trounce] [undergo]
4: [both]
5: [kinds]
6: [country] [state] [nationality] [nation] [land] [commonwealth] [area]
7: [western] [westerly]
8: [bb]

BUILD SUCCESSFUL
Total time: 10 seconds


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message