com.tietoenator.trip.jxp.data

## Class TdbNlpInfo

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

-     public class TdbNlpInfo
      extends java.lang.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 and Description
    --- | ---
    `static class` | `TdbNlpInfo.FieldMappingType` Field name mapping mode for extracted meta-data.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addInputField(java.lang.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.
    `java.lang.String` | `getKeywordField()` Get the name of the field to receive extracted keywords.
    `java.lang.String` | `getMetadataNameField()` Get the name of the tupled field to receive extracted meta-data names.
    `java.lang.String` | `getMetadataValueField()` Get the name of the tupled field to receive extracted meta-data values.
    `java.lang.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(java.lang.String categoryName, java.lang.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(java.lang.String 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` | `setKeywordField(java.lang.String fieldname)` Set the name of the field to receive extracted keywords.
    `void` | `setMetadataTupleFields(java.lang.String namefield, java.lang.String valuefield)` Set the names of the field to receive extracted meta-data.
    `void` | `setPreferredAdapter(java.lang.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 Detail

    - #### 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:
        `TdbNlpInfo.setExtractKeywords(boolean)`, `TdbNlpInfo.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(java.lang.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(java.lang.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 java.lang.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(java.lang.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 java.lang.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(java.lang.String namefield,
                                             java.lang.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 java.lang.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 java.lang.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(java.lang.String categoryName,
                                       java.lang.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(java.lang.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.