text_extensions_for_pandas/jupyter/widget/table.py
def TokenSpanHandler(
    column, column_index, TokenSpanOnBeginChange, TokenSpanOnEndChange
):
    """Creates a custom widget for the Text Extensions for Pandas TokenSpan object type."""
    # Create input bounded int boxes
    data_begin = DataTypeHandler(
        column,
        column[column_index].begin_token,
        min=0,
        max=column[column_index].end_token,
        description="Begin Token: ",
    )

    data_end = DataTypeHandler(
        column,
        column[column_index].end_token,
        min=column[column_index].begin_token,
        max=len(column[column_index].tokens),
        description="End Token: ",
    )

    # Create output text box
    text = ipw.Text(str(column[column_index]), disabled=True)

    # Trigger functions on changing values in input int boxes
    data_begin.observe(
        lambda change, index=column_index, text=text, column_name=column.name: TokenSpanOnBeginChange(
            change, column[index], text, column_name, index, data_begin, data_end
        ),
        names="value",
    )

    data_end.observe(
        lambda change, index=column_index, text=text, column_name=column.name: TokenSpanOnEndChange(
            change, column[index], text, column_name, index, data_begin, data_end
        ),
        names="value",
    )

    # Add some identifying classed
    data_begin.add_class("tep--dfwidget--span-widget")
    data_end.add_class("tep--dfwidget--span-widget")

    return data_begin, data_end, text
Creates a custom widget for the Text Extensions for Pandas TokenSpan object type.
Creates a custom widget for the Text Extensions for Pandas TokenSpan object type.
Creates a custom widget for the Text Extensions for Pandas TokenSpan object type .
def TokenSpanHandler(
    column, column_index, TokenSpanOnBeginChange, TokenSpanOnEndChange
):
    data_begin = DataTypeHandler(
        column,
        column[column_index].begin_token,
        min=0,
        max=column[column_index].end_token,
        description="Begin Token: ",
    )
    data_end = DataTypeHandler(
        column,
        column[column_index].end_token,
        min=column[column_index].begin_token,
        max=len(column[column_index].tokens),
        description="End Token: ",
    )
    text = ipw.Text(str(column[column_index]), disabled=True)
    data_begin.observe(
        lambda change, index=column_index, text=text, column_name=column.name: TokenSpanOnBeginChange(
            change, column[index], text, column_name, index, data_begin, data_end
        ),
        names="value",
    )
    data_end.observe(
        lambda change, index=column_index, text=text, column_name=column.name: TokenSpanOnEndChange(
            change, column[index], text, column_name, index, data_begin, data_end
        ),
        names="value",
    )
    data_begin.add_class("tep--dfwidget--span-widget")
    data_end.add_class("tep--dfwidget--span-widget")
    return data_begin, data_end, text
def TokenSpanHandler ( column , column_index , TokenSpanOnBeginChange , TokenSpanOnEndChange ) : data_begin = DataTypeHandler ( column , column [ column_index ] . begin_token , min = 0 , max = column [ column_index ] . end_token , description = "Begin Token: " , ) data_end = DataTypeHandler ( column , column [ column_index ] . end_token , min = column [ column_index ] . begin_token , max = len ( column [ column_index ] . tokens ) , description = "End Token: " , ) text = ipw . Text ( str ( column [ column_index ] ) , disabled = True ) data_begin . observe ( lambda change , index = column_index , text = text , column_name = column . name : TokenSpanOnBeginChange ( change , column [ index ] , text , column_name , index , data_begin , data_end ) , names = "value" , ) data_end . observe ( lambda change , index = column_index , text = text , column_name = column . name : TokenSpanOnEndChange ( change , column [ index ] , text , column_name , index , data_begin , data_end ) , names = "value" , ) data_begin . add_class ( "tep--dfwidget--span-widget" ) data_end . add_class ( "tep--dfwidget--span-widget" ) return data_begin , data_end , text
Creates a custom widget for the Text Extensions for Pandas TokenSpan object type.
Creates a custom widget for the Text Extensions for Pandas TokenSpan object type .
"""Creates a custom widget for the Text Extensions for Pandas TokenSpan object type.""" # Create input bounded int boxes # Create output text box # Trigger functions on changing values in input int boxes # Add some identifying classed
column
column_index
TokenSpanOnBeginChange
TokenSpanOnEndChange