org.apache.lucene.wordnet.package.html Maven / Gradle / Ivy
WordNet Lucene Synonyms Integration
This package uses synonyms defined by WordNet.
There are two methods: query expansion and analysis.
Both methods first require you to download the WordNet prolog database
Inside this archive is a file named wn_s.pl, which contains the WordNet synonyms.
Query Expansion Method
This method creates Lucene index storing the synonyms, which in turn can be used for query expansion.
You normally run {@link org.apache.lucene.wordnet.Syns2Index} once to build the query index/"database", and then call
{@link org.apache.lucene.wordnet.SynExpand#expand SynExpand.expand(...)} to expand a query.
Instructions
- Invoke Syn2Index as appropriate to build a synonym index.
It'll take 2 arguments, the path to wn_s.pl from the WordNet download, and the index name.
- Update your UI so that as appropriate you call SynExpand.expand(...) to expand user queries with synonyms.
Analysis Method
This method injects additional synonym tokens for tokens from a child {@link org.apache.lucene.analysis.TokenStream}.
Instructions
- Create a {@link org.apache.lucene.wordnet.SynonymMap}, passing in the path to wn_s.pl
- Add a {@link org.apache.lucene.wordnet.SynonymTokenFilter} to your analyzer. Note: SynonymTokenFilter should be after LowerCaseFilter,
because it expects terms to already be in lowercase.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy