Class SynonymMap.Builder
- java.lang.Object
-
- org.apache.lucene.analysis.synonym.SynonymMap.Builder
-
- Direct Known Subclasses:
SynonymMap.Parser
- Enclosing class:
- SynonymMap
public static class SynonymMap.Builder extends java.lang.Object
Builds an FSTSynonymMap.Call add() until you have added all the mappings, then call build() to get an FSTSynonymMap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SynonymMap.Builder.MapEntry
-
Field Summary
Fields Modifier and Type Field Description private boolean
dedup
private int
maxHorizontalContext
private BytesRefBuilder
utf8Scratch
private BytesRefHash
words
private java.util.HashMap<CharsRef,SynonymMap.Builder.MapEntry>
workingSet
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
add(CharsRef input, int numInputWords, CharsRef output, int numOutputWords, boolean includeOrig)
void
add(CharsRef input, CharsRef output, boolean includeOrig)
Add a phrase->phrase synonym mapping.SynonymMap
build()
Builds anSynonymMap
and returns it.private int
countWords(CharsRef chars)
private boolean
hasHoles(CharsRef chars)
only used for asserting!static CharsRef
join(java.lang.String[] words, CharsRefBuilder reuse)
Sugar: just joins the provided terms withSynonymMap.WORD_SEPARATOR
.
-
-
-
Field Detail
-
workingSet
private final java.util.HashMap<CharsRef,SynonymMap.Builder.MapEntry> workingSet
-
words
private final BytesRefHash words
-
utf8Scratch
private final BytesRefBuilder utf8Scratch
-
maxHorizontalContext
private int maxHorizontalContext
-
dedup
private final boolean dedup
-
-
Method Detail
-
join
public static CharsRef join(java.lang.String[] words, CharsRefBuilder reuse)
Sugar: just joins the provided terms withSynonymMap.WORD_SEPARATOR
. reuse and its chars must not be null.
-
hasHoles
private boolean hasHoles(CharsRef chars)
only used for asserting!
-
add
private void add(CharsRef input, int numInputWords, CharsRef output, int numOutputWords, boolean includeOrig)
-
countWords
private int countWords(CharsRef chars)
-
add
public void add(CharsRef input, CharsRef output, boolean includeOrig)
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
public SynonymMap build() throws java.io.IOException
Builds anSynonymMap
and returns it.- Throws:
java.io.IOException
-
-