Teradata R Package Function Reference - 16.20 - POSTagger - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
16.20
created_date
February 2020
category
Programming Reference
featnum
B700-4007-098K

Description

The POSTagger function creates part-of-speech (POS) tags for the words in the input text. POS tagging is the first step in the syntactic analysis of a language, and an important preprocessing step in many natural language processing applications.

Usage

  td_pos_tagger_mle (
      data = NULL,
      text.column = NULL,
      language = "en",
      accumulate = NULL,
      data.sequence.column = NULL,
      data.order.column = NULL
  )

Arguments

data

Required Argument.
Specifies the tbl_teradata that contains the input texts to tag.

data.order.column

Optional Argument.
Specifies Order By columns for data.
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

text.column

Required Argument.
Specifies the name of the input column that contains the text to be tagged.
Types: character

language

Optional Argument.
Specifies the language of the input text.
Default Value: "en"
Permitted Values: en (English), zh_CN (Simplified Chinese)
Types: character

accumulate

Optional Argument.
Specifies the names of the input tbl_teradata columns to copy to the output table.
Note: If you intend to use the td_pos_tagger output tbl_teradata as input to the function "td_textchunker", then this argument must specify the input tbl_teradata columns that comprise the partition key.
Types: character OR vector of Strings (character)

data.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "data". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_pos_tagger_mle" which is a named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator using name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("pos_tagger_example", "paragraphs_input")
    
    # Create remote tibble objects.
    paragraphs_input <- tbl(con, "paragraphs_input")
    
    # Example 1 - Applying POSTagger using default language 'en'.
    pos_tagger_out <- td_pos_tagger_mle(data=paragraphs_input,
                              text.column='paratext',
                              language='en',
                              accumulate='paraid')
    
    # Example 2 - This example uses output of SentenceExtractor as Input.
    td_sentence_extractor_out <- td_sentence_extractor_mle(data = paragraphs_input,
                                                       text.column = "paratext",
                                                       accumulate = c("paraid", "paratopic"))
    
    
    pos_tagger_out <- td_pos_tagger_mle(data=td_sentence_extractor_out$result,
                                    text.column='sentence',
                                    accumulate=c('sentence','sentence_sn'))