com.raritantechnologies.searchApp.formatters
Class ExcerptFormatter

java.lang.Object
  extended bycom.raritantechnologies.searchApp.formatters.ExcerptFormatter
All Implemented Interfaces:
IConfigurable, IFieldFormatter

public class ExcerptFormatter
extends java.lang.Object
implements IFieldFormatter

Takes a keyword or phrase from some source and extracts a section of text from another field that surrounds the keyword - to create a dynamic summary or "keyword in context" set.

Operational Modes:
XML Configuration Template:
   <Formatter 
       formatterClass="com.raritantechnologies.searchApp.formatters.ExcerptFormatter"
       inputField="[ field that contains data to create excerpt from ]"
       excerptField="[ name of field that contains the extracted excerpt ]"
       keywordField="[ field to get the keyword value ]"
       documentMatcherField="[ alternative: documentMatcher name ]"
       documentClassifier="[ name of DocumentClassifier to use (default='DocClassifier') ]"
       excerptWidth="[ number of characters to include in excerpt ]"
       includeStart="[true|false(default): include start of data section ]"
       caseSensitive="[true|false(default)]"
       useIndexedDocument="[true|false( default ) ]"
       detectSentences="[ true(default)|false ]"
       cachedIndexDocKey="[ optional session key to get indexed document ]"
       useCachedIndexDoc="[true|false(default) - if true get IndexedDocument from cache ]"
       highlightPrefix="[ prefix tag for marking hit terms in the excerpt ]"
       highlightPostfix="[ postfix tag for marking hit terms in the excerpt ]"
       maxNumberOfExcerpts="[ maximum number of excerpts sections to display ]" >

      <!-- Optional list of Stop Words -->
      <StopWords>[ comma separated list of words that should not be included in excerpts ]</StopWords>

      <!-- Can use a SearchSource to expand the terms that will be used for excerpting -->
      <KeywordLookupSource
        searchSource="[ alternative: Lookup source to find related keywords ]"
        searchField="[ field in lookup source to get search keyword ]"
        resultField="[ field in lookup results to get related keywords ]" />

  </Formatter>
 

Developed by Raritan Technologies .

Author:
Ted Sullivan

Field Summary
 
Fields inherited from interface com.raritantechnologies.searchApp.IFieldFormatter
TEMPLATE
 
Constructor Summary
ExcerptFormatter()
           
 
Method Summary
 java.lang.String formatField(java.lang.String fieldVal)
          Reformats a field value.
 java.lang.String formatField(java.lang.String sessionID, java.lang.String fieldVal)
          Reformats a field value.
 void formatResultField(IResult result)
          Formats a result field "in place", incorporating session context.
 void formatResultField(java.lang.String sessionID, IResult result)
          Formats a result field "in place".
 java.lang.String getConfigurationXML()
           
 java.lang.String getConfigurationXML(java.lang.String configurationTemplate)
           
 java.lang.String getDataField()
           
static java.lang.String getExcerpt(java.lang.String keyValue, java.lang.String dataValue, int charWidth)
           
static java.lang.String getExcerpt(java.lang.String keyValue, java.lang.String dataValue, int charWidth, boolean includeStart)
           
static java.lang.String getExcerpt(java.lang.String keyValue, java.lang.String dataValue, int charWidth, boolean includeStart, boolean caseSensitive)
           
 java.lang.String getExcerptField()
           
static java.lang.String[] getExcerpts(java.lang.String keyValue, java.lang.String dataValue, int charWidth, boolean includeStart, boolean caseSensitive)
           
static java.lang.String[] getExcerpts(java.lang.String keyValue, java.lang.String dataValue, int charWidth, boolean includeStart, boolean caseSensitive, boolean useStemming)
           
 java.lang.String getFieldName()
          Returns the name of the result field that this formatter can reformat.
 java.lang.String getKeywordField()
           
 void initialize(org.w3c.dom.Element elem)
          Initializes the formatter from configuration XML element.
 void setDataField(java.lang.String dataField)
           
 void setExcerptField(java.lang.String excerptField)
           
 void setKeywordField(java.lang.String keywordField)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExcerptFormatter

public ExcerptFormatter()
Method Detail

formatResultField

public void formatResultField(IResult result)
Formats a result field "in place", incorporating session context.

Specified by:
formatResultField in interface IFieldFormatter
Parameters:
result - The result object that is to be formatted.

formatResultField

public void formatResultField(java.lang.String sessionID,
                              IResult result)
Formats a result field "in place".

Specified by:
formatResultField in interface IFieldFormatter
Parameters:
result - The result object that is to be formatted.
sessionID - The session key needed to lookup any session content stored in the session data cache.

getFieldName

public java.lang.String getFieldName()
Returns the name of the result field that this formatter can reformat.

Specified by:
getFieldName in interface IFieldFormatter

formatField

public java.lang.String formatField(java.lang.String sessionID,
                                    java.lang.String fieldVal)
Reformats a field value.

Specified by:
formatField in interface IFieldFormatter
Parameters:
sessionID - The session key needed to lookup any session content stored in the session data cache.
fieldVal - The field value to be reformatted.
Returns:
The reformatted field value.

formatField

public java.lang.String formatField(java.lang.String fieldVal)
Reformats a field value.

Specified by:
formatField in interface IFieldFormatter
Parameters:
fieldVal - The field value to be reformatted.
Returns:
The reformatted field value.

initialize

public void initialize(org.w3c.dom.Element elem)
Initializes the formatter from configuration XML element.

Specified by:
initialize in interface IFieldFormatter

getExcerpt

public static java.lang.String getExcerpt(java.lang.String keyValue,
                                          java.lang.String dataValue,
                                          int charWidth)

getExcerpt

public static java.lang.String getExcerpt(java.lang.String keyValue,
                                          java.lang.String dataValue,
                                          int charWidth,
                                          boolean includeStart)

getExcerpt

public static java.lang.String getExcerpt(java.lang.String keyValue,
                                          java.lang.String dataValue,
                                          int charWidth,
                                          boolean includeStart,
                                          boolean caseSensitive)

getExcerpts

public static java.lang.String[] getExcerpts(java.lang.String keyValue,
                                             java.lang.String dataValue,
                                             int charWidth,
                                             boolean includeStart,
                                             boolean caseSensitive)

getExcerpts

public static java.lang.String[] getExcerpts(java.lang.String keyValue,
                                             java.lang.String dataValue,
                                             int charWidth,
                                             boolean includeStart,
                                             boolean caseSensitive,
                                             boolean useStemming)

setKeywordField

public void setKeywordField(java.lang.String keywordField)

getKeywordField

public java.lang.String getKeywordField()

setDataField

public void setDataField(java.lang.String dataField)

getDataField

public java.lang.String getDataField()

setExcerptField

public void setExcerptField(java.lang.String excerptField)

getExcerptField

public java.lang.String getExcerptField()

getConfigurationXML

public java.lang.String getConfigurationXML()
Specified by:
getConfigurationXML in interface IFieldFormatter

getConfigurationXML

public java.lang.String getConfigurationXML(java.lang.String configurationTemplate)
Specified by:
getConfigurationXML in interface IFieldFormatter