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

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
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.
get_build_time(self)
Function to return the build time of the algorithm in seconds.
When model object is created using retrieve_model(), then the value returned is 
as saved in the Model Catalog.
get_prediction_type(self)
Function to return the Prediction type of the algorithm.
When model object is created using retrieve_model(), then the value returned is 
as saved in the Model Catalog.
get_target_column(self)
Function to return the Target Column of the algorithm.
When model object is created using retrieve_model(), then the value returned is 
as saved in the Model Catalog.
show_query(self)
Function to return the underlying SQL query.
When model object is created using retrieve_model(), then None is returned.