Class SolrSynonymParser
- java.lang.Object
-
- org.apache.lucene.analysis.synonym.SynonymMap.Builder
-
- org.apache.lucene.analysis.synonym.SynonymMap.Parser
-
- org.apache.lucene.analysis.synonym.SolrSynonymParser
-
public class SolrSynonymParser extends SynonymMap.Parser
Parser for the Solr synonyms format.- Blank lines and lines starting with '#' are comments.
- Explicit mappings match any token sequence on the LHS of "=>" and replace with all
alternatives on the RHS. These types of mappings ignore the expand parameter in the
constructor. Example:
i-pod, i pod => ipod
- Equivalent synonyms may be separated with commas and give no explicit mapping. In this case
the mapping behavior will be taken from the expand parameter in the constructor. This
allows the same synonym file to be used in different synonym handling strategies. Example:
ipod, i-pod, i pod
- Multiple synonym mapping entries are merged. Example:
foo => foo bar
foo => baz
is equivalent to
foo => foo bar, baz
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
expand
-
Constructor Summary
Constructors Constructor Description SolrSynonymParser(boolean dedup, boolean expand, Analyzer analyzer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addInternal(java.io.BufferedReader in)
void
parse(java.io.Reader in)
Parse the given input, adding synonyms to the inheritedSynonymMap.Builder
.private static java.lang.String[]
split(java.lang.String s, java.lang.String separator)
private java.lang.String
unescape(java.lang.String s)
-
Methods inherited from class org.apache.lucene.analysis.synonym.SynonymMap.Parser
analyze
-
Methods inherited from class org.apache.lucene.analysis.synonym.SynonymMap.Builder
add, build, join
-
-
-
-
Constructor Detail
-
SolrSynonymParser
public SolrSynonymParser(boolean dedup, boolean expand, Analyzer analyzer)
-
-
Method Detail
-
parse
public void parse(java.io.Reader in) throws java.io.IOException, java.text.ParseException
Description copied from class:SynonymMap.Parser
Parse the given input, adding synonyms to the inheritedSynonymMap.Builder
.- Specified by:
parse
in classSynonymMap.Parser
- Parameters:
in
- The input to parse- Throws:
java.io.IOException
java.text.ParseException
-
addInternal
private void addInternal(java.io.BufferedReader in) throws java.io.IOException
- Throws:
java.io.IOException
-
split
private static java.lang.String[] split(java.lang.String s, java.lang.String separator)
-
unescape
private java.lang.String unescape(java.lang.String s)
-
-