public static class SynonymMap.Builder
extends java.lang.Object
Call add() until you have added all the mappings, then call build() to get an FSTSynonymMap
Modifier and Type | Class and Description |
---|---|
private static class |
SynonymMap.Builder.MapEntry |
Modifier and Type | Field and Description |
---|---|
private boolean |
dedup |
private int |
maxHorizontalContext |
private BytesRefBuilder |
utf8Scratch |
private BytesRefHash |
words |
private java.util.HashMap<CharsRef,SynonymMap.Builder.MapEntry> |
workingSet |
Constructor and Description |
---|
Builder()
Default constructor, passes
dedup=true . |
Builder(boolean dedup)
If dedup is true then identical rules (same input,
same output) will be added only once.
|
Modifier and Type | Method and Description |
---|---|
void |
add(CharsRef input,
CharsRef output,
boolean includeOrig)
Add a phrase->phrase synonym mapping.
|
private void |
add(CharsRef input,
int numInputWords,
CharsRef output,
int numOutputWords,
boolean includeOrig) |
SynonymMap |
build()
Builds an
SynonymMap 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 with
SynonymMap.WORD_SEPARATOR . |
private final java.util.HashMap<CharsRef,SynonymMap.Builder.MapEntry> workingSet
private final BytesRefHash words
private final BytesRefBuilder utf8Scratch
private int maxHorizontalContext
private final boolean dedup
public Builder()
dedup=true
.public Builder(boolean dedup)
public static CharsRef join(java.lang.String[] words, CharsRefBuilder reuse)
SynonymMap.WORD_SEPARATOR
. reuse and its chars
must not be null.private boolean hasHoles(CharsRef chars)
private void add(CharsRef input, int numInputWords, CharsRef output, int numOutputWords, boolean includeOrig)
private int countWords(CharsRef chars)
public void add(CharsRef input, CharsRef output, boolean includeOrig)
input
- input phraseoutput
- output phraseincludeOrig
- true if the original should be includedpublic SynonymMap build() throws java.io.IOException
SynonymMap
and returns it.java.io.IOException