Not logged in!

Text

The Text object allows you to receive input and output text data
Introduction

The Text class allows you to receive textual input, or display some text to the end user.

Contents

Text.In

Text.In allows you to receive text input from a user

Example Applications:

  • Sentence simplification

Example Usage
1import feather as ftr
2from my_model import my_text_simplification_model
3            
4def init():
5    defaults = ["Alexander's legacy includes the cultural diffusion and syncretism which his conquests engendered",
6                "The domestic dog is a domesticated descendant of an ancient, extinct wolf"]
7    #################### CONSTRUCTOR ####################
8    text_input = ftr.Text.In(default_text=defaults, num_inputs=2, max_chars=140,
9                            title="Enter sentences to be simplified!")
10    #####################################################
11    return text_input
12    
13def run_simplification(text_input):
14    #################### ACCESSOR ####################
15    inputs = text_input.get_text() # eqivalent to 'text_input.get()'
16    ##################################################
17    # inputs = ["Alexander's legacy includes the cultural diffusion and syncretism which his conquests engendered",
18    #           "A cat is the only domesticated species in the family Felidae, often referred to as the domestic cat"]
19    
20    simple_texts = my_text_simplification_model(inputs)
21    # simple_texts = ["Alexander shared ideas between different cultures in his conquests",
22    #                 "A house cat is a domesticated cat from the family Felidae"]
23    return ftr.Text.View(output_text=simple_texts)
24    
25if __name__ == "__main__":
26    bundle = ftr.bundle(code_files=[__file__, "my_model.py"], model_files=["outputs/model.ckpt"])
27    ftr.build(name="Text Simplification model", init=init, steps=[run_simplification], file_bundle=bundle)

Constructor:
  • default_text: Optional[Union[str, ListType[str]]] - optionally initialise the text boxes with default values. If str, all text boxes will be initialised with this piece of text. If ListType[str], the length of default_text should be the same as num_inputs
  • num_inputs: int = 1 - the number of text boxes to collect information from
  • max_chars: Optional[int] = 256 - an optional argument which specifies the maximum amount of characters a user can enter into each text box.
  • title: Optional[str] = None - a title semantically attached to the component
  • description: Optional[str] = None - a description semantically attached to the component

Accessors:
  • get_text() -> ListType[str] - gets the text submitted by the end user
  • get() - see below
get() (usage of .get() is not recommended)
get():
    return get_text()

Component Playground:
Arg NameValue
default_text
num_inputs
max_chars
title
description
ftr.Text.In(
    default_text=["Alexander's legacy includes the cultural diffusion and syncretism which his conquests engendered", "A cat is the only domesticated species in the family Felidae, often referred to as the domestic cat"], 
    max_chars=256,
    title="Enter some complicated text", 
    description="For sentence simplifcation")
Text.View

Text.View allows you to output text to a user.

Example Applications:

  • Returning the outputs of a sequence to sequence model

Example Usage
1import feather as ftr
2from my_model import my_text_simplification_model
3            
4def init():
5    defaults = ["Alexander's legacy includes the cultural diffusion and syncretism which his conquests engendered",
6                "The domestic dog is a domesticated descendant of an ancient, extinct wolf"]
7    text_input = ftr.Text.In(default_text=defaults, num_inputs=2, max_chars=140,
8                            title="Enter sentences to be simplified!")
9    return text_input
10
11def run_simplification(text_input):
12    inputs = text_input.get_text() # eqivalent to 'text_input.get()'
13    # inputs = ["Alexander's legacy includes the cultural diffusion and syncretism which his conquests engendered",
14    #           "A cat is the only domesticated species in the family Felidae, often referred to as the domestic cat"]
15    
16    simple_texts = my_text_simplification_model(inputs)
17    # simple_texts = ["Alexander shared ideas between different cultures in his conquests",
18    #                 "A house cat is a domesticated cat from the family Felidae"]
19    #################### CONSTRUCTOR ####################
20    return ftr.Text.View(output_text=simplified_texts)
21    #####################################################
22    
23if __name__ == "__main__":
24    bundle = ftr.bundle(code_files=[__file__, "my_model.py"], model_files=["outputs/model.ckpt"])
25    ftr.build(name="Text Simplification model", init=init, steps=[run_simplification], file_bundle=bundle)

Constructor:
  • output_text: Union[str, ListType[str]] - text to be displayed/output to an end user
  • title: Optional[str] = None - a title semantically attached to the component
  • description: Optional[str] = None - a description semantically attached to the component

Component Playground:
Arg NameValue
output_text
title
description
ftr.Text.View(
    output_text=["Alexander shared ideas between different cultures in his conquests", "A house cat is a domesticated cat from the family Felidae"], 
    title="Simplified outputs", 
    description="Do these outputs look correct?")