πŸ“„ Whitespace Prefix SuffixΒΆ

augmentors.text.whitespace_prefix_suffix

type: AugmentPrefixSuffix
prefixes: 
  " ": 20
  \t: 10
  \n: 40
  "": 30
suffixes: 
  " ": 20
  \t: 10
  \n: 40
  "": 30
prefix_len: 5
suffix_len: 5
remove_existing_whitespaces: True
[source]

Explanation about AugmentPrefixSuffixΒΆ

Augments the input by prepending and appending randomly selected patterns (typically, whitespace).

Args:

prefixes (list or dict or None): the potential patterns (typically, whitespace) to select prefix from. The dictionary version allows the specification of relative weights for the different patterns. Set to None if not needed (i.e., only suffixes are needed).

suffixes (list or dict or None): the potential patterns (typically, whitespace) to select suffix from. The dictionary version allows the specification of relative weights for the different patterns. Set to None if not needed (i.e., only prefixes are needed).

prefix_len (positive int): the length of the prefix to be added.

suffix_len (positive int): The length of the suffix to be added.

remove_existing_whitespaces (bool): Clean any existing leading and trailing whitespaces. The selected pattern(s) are then prepended and/or appended to the potentially trimmed input.

Examples:

To prepend the input with a prefix made of 4 \n-s or \t-s, employ AugmentPrefixSuffix(augment_model_input=True, prefixes=['\n','\t'], prefix_len=4, suffixes = None).

To append the input with a suffix made of 3 \n-s or \t-s, with \n being preferred over \t, at 2:1 ratio, employ AugmentPrefixSuffix(augment_model_input=True, suffixes={'\n':2,'\t':1}, suffix_len=3, prefixes = None) which will append \n-s twice as often as \t-s.

Read more about catalog usage here.