Package org.apache.lucene.search.suggest
Class FileDictionary
- java.lang.Object
-
- org.apache.lucene.search.suggest.FileDictionary
-
- All Implemented Interfaces:
Dictionary
public class FileDictionary extends java.lang.Object implements Dictionary
Dictionary represented by a text file. Format allowed: 1 entry per line:
An entry can be:
- suggestion
- suggestion
fieldDelimiter
weight - suggestion
fieldDelimiter
weightfieldDelimiter
payload
fieldDelimiter
is "\t"
NOTE:- In order to have payload enabled, the first entry has to have a payload
- If the weight for an entry is not specified then a value of 1 is used
- A payload cannot be specified without having the weight specified for an entry
- If the payload for an entry is not specified (assuming payload is enabled) then an empty payload is returned
- An entry cannot have more than two
fieldDelimiter
word1 word2 TAB 100 TAB payload1
word3 TAB 101
word4 word3 TAB 102
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FIELD_DELIMITER
Tab-delimited fields are most common thus the default, but one can override this via the constructor
-
Constructor Summary
Constructors Constructor Description FileDictionary(java.io.InputStream dictFile)
Creates a dictionary based on an inputstream.FileDictionary(java.io.InputStream dictFile, java.lang.String fieldDelimiter)
Creates a dictionary based on an inputstream.FileDictionary(java.io.Reader reader)
Creates a dictionary based on a reader.FileDictionary(java.io.Reader reader, java.lang.String fieldDelimiter)
Creates a dictionary based on a reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputIterator
getEntryIterator()
Returns an iterator over all the entries
-
-
-
Field Detail
-
DEFAULT_FIELD_DELIMITER
public static final java.lang.String DEFAULT_FIELD_DELIMITER
Tab-delimited fields are most common thus the default, but one can override this via the constructor- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileDictionary
public FileDictionary(java.io.InputStream dictFile)
Creates a dictionary based on an inputstream. UsingDEFAULT_FIELD_DELIMITER
as the field seperator in a line.NOTE: content is treated as UTF-8
-
FileDictionary
public FileDictionary(java.io.Reader reader)
Creates a dictionary based on a reader. UsingDEFAULT_FIELD_DELIMITER
as the field seperator in a line.
-
FileDictionary
public FileDictionary(java.io.Reader reader, java.lang.String fieldDelimiter)
Creates a dictionary based on a reader. UsingfieldDelimiter
to seperate out the fields in a line.
-
FileDictionary
public FileDictionary(java.io.InputStream dictFile, java.lang.String fieldDelimiter)
Creates a dictionary based on an inputstream. UsingfieldDelimiter
to seperate out the fields in a line.NOTE: content is treated as UTF-8
-
-
Method Detail
-
getEntryIterator
public InputIterator getEntryIterator()
Description copied from interface:Dictionary
Returns an iterator over all the entries- Specified by:
getEntryIterator
in interfaceDictionary
- Returns:
- Iterator
-
-