Teradata Python Package Function Reference - TextChunker - Teradata Python Package - Look here for syntax, methods and examples for the functions included in the Teradata Python Package.

Teradata® Python Package Function Reference

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-07-17
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.TextChunker = class TextChunker(builtins.object)
     Methods defined here:
__init__(self, data=None, word_column=None, pos_column=None, data_sequence_column=None, data_partition_column=None, data_order_column=None)
DESCRIPTION:
    The TextChunker function divides text into phrases and assigns each
    phrase a tag that identifies its type.
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the teradataml DataFrame that contains the text to be
        scanned.
 
    data_partition_column:
        Required Argument.
        Specifies Partition By columns for data.
        Values to this argument can be provided as list, if multiple
        columns are used for partition.
        Types: str OR list of Strings (str)
 
    data_order_column:
        Required Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    word_column:
        Required Argument.
        Specifies the name of the input teradataml DataFrame column that
        contains the words to chunk into phrases. Typically, this is the
        word column of the output teradataml DataFrame of the "PosTagger"
        function.
        Types: str
 
    pos_column:
        Required Argument.
        Specifies the name of the input teradataml DataFrame column the
        part-of-speech (POS) tag of words. Typically, this is the pos_tag
        column of the output teradataml DataFrame of the "PosTagger"
        function
        Types: str
 
    data_sequence_column:
        Optional Argument.
        Specifies the list 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: str OR list of Strings (str)
 
RETURNS:
    Instance of TextChunker.
    Output teradataml DataFrames can be accessed using attribute
    references, such as TextChunkerObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data.
    load_example_data("textchunker", "posttagger_output")
 
    # Create teradataml DataFrame objects.
    # "posttagger_output" is the ouput of POSTagger function.
    posttagger_output = DataFrame.from_table("posttagger_output")
 
    # Example 1 - This example uses the persisted output of POSTagger
    # as Input.
    textchunker_out =TextChunker(data=posttagger_output,
                                 data_order_column=['paraid','word_sn'],
                                 word_column='word',
                                 pos_column='pos_tag',
                                 data_sequence_column='paraid',
                                 data_partition_column='paraid'
                                 )
 
    # Print the result DataFrame
    print(textchunker_out)
 
    # Load the data to run the example.
    load_example_data("postagger","paragraphs_input")
 
    # Create input teradataml dataframe.
    paragraphs_input = DataFrame.from_table("paragraphs_input")
 
 
    # Example 2 - This example uses output of SentenceExtractor and POSTagger
    # as Input.
    sentenceextractor_out = SentenceExtractor(data=paragraphs_input,
                                              text_column='paratext',
                                              accumulate='paraid'
                                              )
 
    se_res = sentenceextractor_out.result
    sentenceextractor_out = se_res.assign(True,sentence_id = se_res.paraid*1000+se_res.sentence_sn,
                                          sentence = se_res.sentence)
 
    pos_tagger_out = POSTagger(data=sentenceextractor_out,
                       text_column='sentence',
                       accumulate='sentence_id')
 
    textchunker_out =TextChunker(data=pos_tagger_out.result,
                                 data_partition_column='word_sn',
                                 data_order_column='word_sn',
                                 word_column='word',
                                 pos_column='pos_tag')
 
    # Print the result DataFrame
    print(textchunker_out)
__repr__(self)
Returns the string representation for a TextChunker class instance.