com.sun.labs.minion
Interface PassageBuilder

All Known Subinterfaces:
HLPipeline
All Known Implementing Classes:
HLPipelineImpl

public interface PassageBuilder

An interface that will allow applications to build a set of passages to display from a search result.

See Also:
Result.getPassageBuilder()

Method Summary
 void addPassageField(java.lang.String fieldName)
          Registers a field for which we would like to get passages.
 void addPassageField(java.lang.String fieldName, Passage.Type type, int context, int maxSize, boolean doSort)
          Registers the parameters for a field for which we would like to get passages.
 java.util.Map<java.lang.String,java.util.List<Passage>> getPassages(java.util.Map document)
          Gets the highlighted passages that were specified using addPassageField.
 java.util.List<Passage> getPassages(java.util.Map document, int context, int maxSize)
          Gets all of the passages in the document as a list.
 java.util.Map<java.lang.String,java.util.List<Passage>> getPassages(java.util.Map document, int context, int maxSize, boolean doSort)
          Gets the highlighted passages that were specified using addPassageField.
 

Method Detail

addPassageField

void addPassageField(java.lang.String fieldName)
Registers a field for which we would like to get passages. Any passages from this field will be joined together into a single spanning passage, the entire field will be retained as context, and there will be no maximum size imposed on the passages.

This is mostly a convenience for highlighting all of the passages in a field that is expected to be small (say, like the subject of an email message.)

Parameters:
fieldName - The name of the field that we want to collect passages for. If this name is null, the other parameters specify the data for anything that is not in one of the fields added using addPassageField. If the name is NonField, then the other parameters specify the data for passages that do not occur in any field.

addPassageField

void addPassageField(java.lang.String fieldName,
                     Passage.Type type,
                     int context,
                     int maxSize,
                     boolean doSort)
Registers the parameters for a field for which we would like to get passages.

Parameters:
fieldName - The name of the field that we want to collect passages for. If this name is null, the other parameters specify the data for anything that is not in one of the fields added using addPassageField. If the name is NonField, then the other parameters specify the data for passages that do not occur in any field.
type - The type of passage to build. If this is JOIN, then all hits within the named field will be joined into a single passage. If this is UNIQUE, then each hit will be a separate passage.
context - The size of the surrounding context to put in the passage, in words. -1 means take the entire containing field.
maxSize - The maximum size of passage to return, in characters. -1 means any size is OK.
doSort - If true, then the passages for this field will be sorted by score before being returned.

getPassages

java.util.Map<java.lang.String,java.util.List<Passage>> getPassages(java.util.Map document)
Gets the highlighted passages that were specified using addPassageField.

Parameters:
document - A map representing a list of field names and values.
Returns:
A Map that maps from field names to a List of instances of Passage that are associated with the field. The key null maps to passages that did not occur in any field.
See Also:
SearchEngine.index(java.lang.String, java.util.Map), addPassageField(java.lang.String)

getPassages

java.util.Map<java.lang.String,java.util.List<Passage>> getPassages(java.util.Map document,
                                                                    int context,
                                                                    int maxSize,
                                                                    boolean doSort)
Gets the highlighted passages that were specified using addPassageField.

Parameters:
document - A map representing a list of field names and values.
context - the amount of context that will be used around passages in fields that were not explicitly added.
maxSize - the maximum size of passage to return, in characters, for fields that were not explicitly added. -1 means any size is OK.
doSort - If true, passages from any fields not explictly added will be sorted by score before being returned.
Returns:
A Map that maps from field names to a List of instances of Passage that are associated with the field. The key null maps to passages that did not occur in any field and to passages from fields that were not explicitly added.
See Also:
SearchEngine.index(java.lang.String, java.util.Map), addPassageField(java.lang.String)

getPassages

java.util.List<Passage> getPassages(java.util.Map document,
                                    int context,
                                    int maxSize)
Gets all of the passages in the document as a list.

Parameters:
document - A map representing a list of field names and values.
context - The size of the surrounding context to put in the passage, in words. -1 means take an entire field value as context.
maxSize - The maximum size of passage to return, in characters. -1 means any size is OK.
Returns:
a list of Passages.