org.apache.lucene.analysis.synonym
Class SynonymMap.Builder

java.lang.Object
  extended by 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
SynonymMap.Builder(boolean dedup)
          If dedup is true then identical rules (same input, same output) will be added only once.
 
Method Summary
 void add(CharsRef input, CharsRef output, boolean includeOrig)
          Add a phrase->phrase synonym mapping.
static CharsRef analyze(Analyzer analyzer, String text, CharsRef reuse)
          Sugar: analyzes the text with the analyzer and separates by SynonymMap.WORD_SEPARATOR.
 SynonymMap build()
          Builds an SynonymMap and returns it.
static CharsRef join(String[] words, CharsRef reuse)
          Sugar: just joins the provided terms with SynonymMap.WORD_SEPARATOR.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynonymMap.Builder

public SynonymMap.Builder(boolean dedup)
If dedup is true then identical rules (same input, same output) will be added only once.

Method Detail

join

public static CharsRef join(String[] words,
                            CharsRef reuse)
Sugar: just joins the provided terms with SynonymMap.WORD_SEPARATOR. reuse and its chars must not be null.


analyze

public static CharsRef analyze(Analyzer analyzer,
                               String text,
                               CharsRef reuse)
                        throws IOException
Sugar: analyzes the text with the analyzer and separates by SynonymMap.WORD_SEPARATOR. reuse and its chars must not be null.

Throws:
IOException

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 (). Empty words (two s in a row) are not allowed in the input nor the output!

Parameters:
input - input phrase
output - output phrase
includeOrig - true if the original should be included

build

public SynonymMap build()
                 throws IOException
Builds an SynonymMap and returns it.

Throws:
IOException


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.