gov.sandia.cognition.text.convert
Class DocumentFieldConcatenator

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.data.convert.AbstractDataConverter<InputType,OutputType>
          extended by gov.sandia.cognition.text.convert.AbstractSingleTextualConverter<Document,Textual>
              extended by gov.sandia.cognition.text.convert.DocumentFieldConcatenator
All Implemented Interfaces:
DataConverter<Document,Textual>, Evaluator<Document,Textual>, SingleTextualConverter<Document,Textual>, TextualConverter<Document,Textual>, CloneableSerializable, Serializable, Cloneable

public class DocumentFieldConcatenator
extends AbstractSingleTextualConverter<Document,Textual>

A document-text converter that concatenates multiple text fields from a document together for further processing.

Since:
3.1
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
static String DEFAULT_FIELD_SEPARATOR
          The default field separator is a newline.
protected  List<String> fieldNames
          The list of fields to concatenate together from a document.
protected  String fieldSeparator
          The field separator.
 
Constructor Summary
DocumentFieldConcatenator()
          Creates a new DocumentFieldConcatenator with an empty list of fields and a newline separator.
DocumentFieldConcatenator(List<String> fieldNames, String fieldSeparator)
          Creates a new DocumentFieldConcatenator with the given field names and field separator.
 
Method Summary
 Textual evaluate(Document document)
          Evaluates the function on the given input and returns the output.
 List<String> getFieldNames()
          Gets the list of field names whose text are to be concatenated together.
 String getFieldSeparator()
          Gets the string used as a separator between field text values.
 void setFieldNames(List<String> fieldNames)
          Sets the list of field names whose text are to be concatenated together.
 void setFieldSeparator(String fieldSeparator)
          Sets the string used as a separator between field text values.
 
Methods inherited from class gov.sandia.cognition.text.convert.AbstractSingleTextualConverter
convert, convertAll
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FIELD_SEPARATOR

public static final String DEFAULT_FIELD_SEPARATOR
The default field separator is a newline.

See Also:
Constant Field Values

fieldNames

protected List<String> fieldNames
The list of fields to concatenate together from a document.


fieldSeparator

protected String fieldSeparator
The field separator.

Constructor Detail

DocumentFieldConcatenator

public DocumentFieldConcatenator()
Creates a new DocumentFieldConcatenator with an empty list of fields and a newline separator.


DocumentFieldConcatenator

public DocumentFieldConcatenator(List<String> fieldNames,
                                 String fieldSeparator)
Creates a new DocumentFieldConcatenator with the given field names and field separator.

Parameters:
fieldNames - The names of the fields to include.
fieldSeparator - The field separator.
Method Detail

evaluate

public Textual evaluate(Document document)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Parameters:
document - The input to evaluate.
Returns:
The output produced by evaluating the input.

getFieldNames

public List<String> getFieldNames()
Gets the list of field names whose text are to be concatenated together.

Returns:
The list of field names.

setFieldNames

public void setFieldNames(List<String> fieldNames)
Sets the list of field names whose text are to be concatenated together.

Parameters:
fieldNames - The list of field names.

getFieldSeparator

public String getFieldSeparator()
Gets the string used as a separator between field text values.

Returns:
The separator between fields used in the result.

setFieldSeparator

public void setFieldSeparator(String fieldSeparator)
Sets the string used as a separator between field text values.

Parameters:
fieldSeparator - The separator between fields used in the result.