Package com.tietoenator.trip.jxp.data

# Class TdbNlpInfo

java.lang.Object
com.tietoenator.trip.jxp.data.TdbNlpInfo

public class TdbNlpInfo extends Object
Container for natural language processing information. Access to instances of this class is provided via properties in the TdbRecord class. Use this class to enable TRIPcof/TRIPnlp keyword and metadata extraction from fields in the record.

You will need TRIPsystem 7.0 or later and TRIPcof on the server in order to make use of this class. You also need TRIPnlp or a custom NLP adapter for TRIPcof installed together with TRIPcof.

Since:
  TRIPjxp 3.0-1
See Also:
  - `TdbRecord.getNlpInfo()`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `TdbNlpInfo.FieldMappingType`
  Field name mapping mode for extracted meta-data.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addInputField(String name)`
  Add the name of a field on which to base meta-data processing.
  `boolean`
  `getExtractKeywords()`
  Returns true if keywords are to be extracted and false otherwise.
  `boolean`
  `getExtractMetadata()`
  Returns true if meta-data is to be extracted and false otherwise.
  `boolean`
  `getFallback()`
  Get state of fallback behavior.
  `TdbNlpInfo.FieldMappingType`
  `getFieldMapping()`
  Get the field name mapping mode to control how extracted meta-data is stored into the record.
  `String`
  `getKeywordField()`
  Get the name of the field to receive extracted keywords.
  `String`
  `getMetadataNameField()`
  Get the name of the tupled field to receive extracted meta-data names.
  `String`
  `getMetadataValueField()`
  Get the name of the tupled field to receive extracted meta-data values.
  `String`
  `getPreferredAdapter()`
  Get the ID of the adapter that must be used to perform the analysis.
  `boolean`
  `isEnabled()`
  Returns true if TRIPcof/TRIPnlp interaction is enabled and false otherwise.
  `void`
  `mapMetadataField(String categoryName, String fieldName)`
  Define a field to hold the values for a particular meta-data category.
  `void`
  `setExtractKeywords(boolean enable)`
  Enable or disable the extraction of keywords.
  `void`
  `setExtractMetadata(boolean enable)`
  Enable or disable the extraction of meta-data.
  `void`
  `setFallback(boolean enable)`
  Enable or disable fallback behavior.
  `void`
  `setFieldMapping(TdbNlpInfo.FieldMappingType type)`
  Set the field name mapping mode to control how extracted meta-data is stored into the record.
  `void`
  `setInputLanguage(int lang)`
  Sets the input language of the text in the record to be analyzed.
  `void`
  `setInputLanguage(TdbLanguage lang)`
  Sets the input language of the text in the record to be analyzed.
  `void`
  `setInputLanguage(String lang)`
  Sets the input language of the text in the record to be analyzed.
  `void`
  `setKeywordField(String fieldname)`
  Set the name of the field to receive extracted keywords.
  `void`
  `setMetadataTupleFields(String namefield, String valuefield)`
  Set the names of the field to receive extracted meta-data.
  `void`
  `setPreferredAdapter(String adapterid)`
  Assign the ID of the adapter that must be used to perform the analysis.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### isEnabled

    public boolean isEnabled()
    Returns true if TRIPcof/TRIPnlp interaction is enabled and false otherwise. TRIPcof/TRIPnlp interaction is enabled if either keywords or meta-data extraction has been enabled.
    See Also:
      - `setExtractKeywords(boolean)`
      - `setExtractMetadata(boolean)`

  - ### setExtractKeywords

    public void setExtractKeywords(boolean enable)
    Enable or disable the extraction of keywords.
    Parameters:
      `enable` - True to enable and false to disable

  - ### getExtractKeywords

    public boolean getExtractKeywords()
    Returns true if keywords are to be extracted and false otherwise.

  - ### setExtractMetadata

    public void setExtractMetadata(boolean enable)
    Enable or disable the extraction of meta-data.
    Parameters:
      `enable` - True to enable and false to disable

  - ### getExtractMetadata

    public boolean getExtractMetadata()
    Returns true if meta-data is to be extracted and false otherwise.

  - ### setInputLanguage

    public void setInputLanguage(int lang)
    Sets the input language of the text in the record to be analyzed. Input language should be declared if the database design does not include a natural language specification.
    Parameters:
      `lang` - TRIP numerical code of language.

  - ### setInputLanguage

    public void setInputLanguage(String lang)
    Sets the input language of the text in the record to be analyzed. Input language should be declared if the database design does not include a natural language specification.
    Parameters:
      `lang` - Natural language type string (ENG, GER, SWE, NOR, FIN, or CHI)

  - ### setInputLanguage

    public void setInputLanguage(TdbLanguage lang)
    Sets the input language of the text in the record to be analyzed. Input language should be declared if the database design does not include a natural language specification.
    Parameters:
      `lang` - Enumerated value representing the language of the text

  - ### setFieldMapping

    public void setFieldMapping(TdbNlpInfo.FieldMappingType type)
    Set the field name mapping mode to control how extracted meta-data is stored into the record.
    Parameters:
      `type` - Mapping type to assign

  - ### getFieldMapping

    public TdbNlpInfo.FieldMappingType getFieldMapping()
    Get the field name mapping mode to control how extracted meta-data is stored into the record.
    Returns:
      Field name mapping used with meta-data extraction

  - ### setPreferredAdapter

    public void setPreferredAdapter(String adapterid)
    Assign the ID of the adapter that must be used to perform the analysis. If not set, any suitable one installed on the server will be used.
    Parameters:
      `adapterid` - ID of the TRIPcof NLP adapter to use

  - ### getPreferredAdapter

    public String getPreferredAdapter()
    Get the ID of the adapter that must be used to perform the analysis.
    Returns:
      Preferred adapter or an empty string if not set.

  - ### setFallback

    public void setFallback(boolean enable)
    Enable or disable fallback behavior. If fallback is enabled and processing fails using one adapter, TRIPcof will attempt to use other NLP adapters if any are available.
    Parameters:
      `enable` - True to enable fallback behavior and false to disable.

  - ### getFallback

    public boolean getFallback()
    Get state of fallback behavior. If fallback is enabled and processing fails using one adapter, TRIPcof will attempt to use other NLP adapters if any are available.
    Returns:
      True if fallback is enabled and false otherwise.

  - ### setKeywordField

    public void setKeywordField(String fieldname) throws TdbException
    Set the name of the field to receive extracted keywords.
    Parameters:
      `fieldname` - Name of phrase field
    Throws:
      `TdbException` - If field does not exist in the database or is not a phrase field.

  - ### getKeywordField

    public String getKeywordField()
    Get the name of the field to receive extracted keywords.
    Returns:
      Phrase field name or empty string if no field is defined.

  - ### setMetadataTupleFields

    public void setMetadataTupleFields(String namefield, String valuefield) throws TdbException
    Set the names of the field to receive extracted meta-data. The field mapping must be set to FieldMappingType.Tuples if these field names are to be considered by TRIPcof.
    Parameters:
      `namefield` - Name of phrase field to hold meta-data category names
      `valuefield` - Name of phrase field to hold meta-data category values
    Throws:
      `TdbException` - If either field does not exist in the database or is not a phrase field.

  - ### getMetadataNameField

    public String getMetadataNameField()
    Get the name of the tupled field to receive extracted meta-data names.
    Returns:
      Phrase field name or empty string if no field is defined.

  - ### getMetadataValueField

    public String getMetadataValueField()
    Get the name of the tupled field to receive extracted meta-data values.
    Returns:
      Phrase field name or empty string if no field is defined.

  - ### mapMetadataField

    public void mapMetadataField(String categoryName, String fieldName) throws TdbException
    Define a field to hold the values for a particular meta-data category. Please refer to TRIPnlp documentation for valid category names. The field mapping must be set to FieldMappingType.Fields if this information is to be considered by TRIPnlp.
    Parameters:
      `categoryName` - Name of meta-data category
      `fieldName` - Field to hold the values of the category
    Throws:
      `TdbException` - If field does not exist in the database or is not a phrase field.

  - ### addInputField

    public void addInputField(String name) throws TdbException
    Add the name of a field on which to base meta-data processing. The aggregated value of several fields can be used.
    Parameters:
      `name` - Name of TEXT or PHRASE field from which to get text to analyze.
    Throws:
      `TdbException` - If field does not exist in the database or is not of type phrase or text.