Class SynonymMap.Builder
- java.lang.Object
-
- org.apache.lucene.analysis.synonym.SynonymMap.Builder
-
- Direct Known Subclasses:
SolrSynonymParser,WordnetSynonymParser
- Enclosing class:
- SynonymMap
public static class SynonymMap.Builder extends Object
Builds an FSTSynonymMap.Call add() until you have added all the mappings, then call build() to get an FSTSynonymMap
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description Builder(boolean dedup)If dedup is true then identical rules (same input, same output) will be added only once.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(org.apache.lucene.util.CharsRef input, org.apache.lucene.util.CharsRef output, boolean includeOrig)Add a phrase->phrase synonym mapping.static org.apache.lucene.util.CharsRefanalyze(org.apache.lucene.analysis.Analyzer analyzer, String text, org.apache.lucene.util.CharsRef reuse)Sugar: analyzes the text with the analyzer and separates bySynonymMap.WORD_SEPARATOR.SynonymMapbuild()Builds anSynonymMapand returns it.static org.apache.lucene.util.CharsRefjoin(String[] words, org.apache.lucene.util.CharsRef reuse)Sugar: just joins the provided terms withSynonymMap.WORD_SEPARATOR.
-
-
-
Method Detail
-
join
public static org.apache.lucene.util.CharsRef join(String[] words, org.apache.lucene.util.CharsRef reuse)
Sugar: just joins the provided terms withSynonymMap.WORD_SEPARATOR. reuse and its chars must not be null.
-
analyze
public static org.apache.lucene.util.CharsRef analyze(org.apache.lucene.analysis.Analyzer analyzer, String text, org.apache.lucene.util.CharsRef reuse) throws IOExceptionSugar: analyzes the text with the analyzer and separates bySynonymMap.WORD_SEPARATOR. reuse and its chars must not be null.- Throws:
IOException
-
add
public void add(org.apache.lucene.util.CharsRef input, org.apache.lucene.util.CharsRef output, boolean includeOrig)Add a phrase->phrase synonym mapping. Phrases are character sequences where words are separated with character zero ( ). Empty words (two s in a row) are not allowed in the input nor the output!- Parameters:
input- input phraseoutput- output phraseincludeOrig- true if the original should be included
-
build
public SynonymMap build() throws IOException
Builds anSynonymMapand returns it.- Throws:
IOException
-
-