Class SynonymMap.Builder
java.lang.Object
org.apache.lucene.analysis.synonym.SynonymMap.Builder
- Direct Known Subclasses:
SynonymMap.Parser
- Enclosing class:
- SynonymMap
Builds an FSTSynonymMap.
Call add() until you have added all the mappings, then call build() to get an FSTSynonymMap
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private int
private final BytesRefBuilder
private final BytesRefHash
private final HashMap<CharsRef,
SynonymMap.Builder.MapEntry> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
Add a phrase->phrase synonym mapping.build()
Builds anSynonymMap
and returns it.private int
countWords
(CharsRef chars) private boolean
only used for asserting!static CharsRef
join
(String[] words, CharsRefBuilder reuse) Sugar: just joins the provided terms withSynonymMap.WORD_SEPARATOR
.
-
Field Details
-
workingSet
-
words
-
utf8Scratch
-
maxHorizontalContext
private int maxHorizontalContext -
dedup
private final boolean dedup
-
-
Constructor Details
-
Builder
public Builder()Default constructor, passesdedup=true
. -
Builder
public Builder(boolean dedup) If dedup is true then identical rules (same input, same output) will be added only once.
-
-
Method Details
-
join
Sugar: just joins the provided terms withSynonymMap.WORD_SEPARATOR
. reuse and its chars must not be null. -
hasHoles
only used for asserting! -
add
-
countWords
-
add
Add a phrase->phrase synonym mapping. Phrases are character sequences where words are separated with character zero (U+0000). Empty words (two U+0000s 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
Builds anSynonymMap
and returns it.- Throws:
IOException
-