Skip to content

Commit

Permalink
Update transforms.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zpapakipos authored Feb 21, 2022
1 parent 23895b6 commit 7a6ae16
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions augly/text/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __call__(
force: bool = False,
metadata: Optional[List[Dict[str, Any]]] = None,
**kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
@param texts: a string or a list of text documents to be augmented
Expand Down Expand Up @@ -87,7 +87,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
This function is to be implemented in the child classes. From this function, call
the augmentation function, passing in 'texts', 'metadata', & the given
Expand Down Expand Up @@ -138,7 +138,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Apply a user-defined lambda on a list of text documents
Expand Down Expand Up @@ -194,7 +194,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Changes the case (e.g. upper, lower, title) of random chars, words, or the entire
text
Expand Down Expand Up @@ -249,7 +249,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Replaces pairs (or longer strings) of words with contractions given a mapping
Expand All @@ -273,7 +273,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Generates a baseline by tokenizing and detokenizing the text
Expand Down Expand Up @@ -322,7 +322,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Inserts punctuation characters in each input text
Expand Down Expand Up @@ -371,7 +371,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Inserts whitespace characters in each input text
Expand Down Expand Up @@ -420,7 +420,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Inserts zero-width characters in each input text
Expand Down Expand Up @@ -478,7 +478,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Merges words in the text together
Expand Down Expand Up @@ -521,7 +521,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Reverses each word (or part of the word) in each input text and uses
bidirectional marks to render the text in its original order. It reverses
Expand Down Expand Up @@ -590,7 +590,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Replaces words or characters depending on the granularity with fun fonts applied
Expand Down Expand Up @@ -664,7 +664,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Replaces letters in each text with similar characters
Expand Down Expand Up @@ -738,7 +738,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Replaces letters in each text with similar unicodes
Expand Down Expand Up @@ -792,7 +792,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Flips words in the text upside down depending on the granularity
Expand Down Expand Up @@ -855,7 +855,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Replaces words in each text based on a given mapping
Expand Down Expand Up @@ -946,7 +946,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Simulates typos in each text using misspellings, keyboard distance, and swapping.
You can specify a typo_type: charmix, which does a combination of character-level
Expand Down Expand Up @@ -1009,7 +1009,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Splits words in the text into subwords
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def apply_transform(
texts: Union[str, List[str]],
metadata: Optional[List[Dict[str, Any]]] = None,
**aug_kwargs,
) -> List[str]:
) -> Union[str, List[str]]:
"""
Replaces words in each text based on a provided `mapping`, which can either be a
dict already constructed mapping words from one gender to another or a file path
Expand Down

0 comments on commit 7a6ae16

Please sign in to comment.