Replication Functions

Available functions:

  • replace_word_with_synonym(word): Replace the given word with a synonym.

  • augment_text_with_synonyms(text, augmentation_factor, probability, progress=True): Augment the input text by replacing words with synonyms.

  • load_text_file(filepath): Load the contents of a text file.

  • augment_file_with_synonyms(file_path, augmentation_factor, probability, progress=True): Augment a text file by replacing words with synonyms.

  • insert_random_word(text, word): Insert a random word into the input text.

  • delete_random_word(text): Delete a random word from the input text.

  • insert_synonym(text, word): Insert a synonym of the given word into the input text.

  • paraphrase(text): Paraphrase the input text.

  • flip_horizontal(image): Flip the input image horizontally.

  • flip_vertical(image): Flip the input image vertically.

  • rotate(image, angle): Rotate the input image by a specified angle.

  • random_rotation(image, max_angle): Randomly rotate the input image by an angle within the specified range.

  • resize(image, size): Resize the input image to the specified size.

  • crop(image, box): Crop the input image to the specified rectangular region.

  • random_crop(image, size): Randomly crop a region from the input image.

  • shuffle_words(text): Randomly shuffle the order of words in each sentence.


Replace word with synonym

Replace the given word with a synonym.

Params:
- `word` (str): The input word to replace with a synonym.

Returns:
- `str`: The synonym for the word.

Augment text with synonyms

Augment the input text by replacing words with synonyms.

Parameters:
- `text` (str): The input text to be augmented.
- `augmentation_factor` (int): The number of times to augment the text.
- `probability` (float): The probability of replacing a random word with a synonym.
- `progress` (bool): Whether or not to return current progress during augmentation.

Returns:
- `list`: A list of augmented text.

Load text file

Load the contents of a text file.

Parameters:
- `file_path` (str): The path to the target input data.

Returns:
- `str`: The read text from the file.

Augment file with synonyms

Augment a text file by replacing words with synonyms.

Parameters:
- `file_path` (str): The path to the target input data.
- `augmentation_factor` (int): The number of times to augment the data.
- `probability` (float): The probability of replacing a random word with its synonym.
- `progress` (bool): Whether or not to print the current progress during augmentation.

Returns:
- `list`: A list of augmented text.

Insert random word

Insert a random word into the input text.

Parameters:
- `text` (str): The input text for word insertion.
- `word` (str): The word to be inserted into the text.

Returns:
- `str`: The text with the randomly inserted word.

Delete random word

Delete a random word from the input text.

Parameters:
- `text` (str): The input text for word deletion.

Returns:
- `str`: The text with a randomly deleted word.

Insert synonym

Insert a synonym of the given word into the input text.

Parameters:
- `text` (str): The input text for synonym insertion.
- `word` (str): The word for which a synonym will be inserted.

Returns:
- `str`: The text with a synonym of the word inserted.

Paraphrase

Paraphrase the input text.

Parameters:
- `text` (str): The input text to be paraphrased.

Returns:
- `str`: The paraphrased text.

Flip horizontal

Flip the input image horizontally.

Parameters:
- `image` (PIL.Image.Image): The input image to be flipped.

Returns:
- `PIL.Image.Image`: The horizontally flipped image.

Flip vertical

Flip the input image vertically.

Parameters:
- `image` (PIL.Image.Image): The input image to be flipped.

Returns:
- `PIL.Image.Image`: The vertically flipped image.

Rotate

Rotate the input image by a specified angle.

Parameters:
- `image` (PIL.Image.Image): The input image to be rotated.
- `angle` (float): The angle of rotation in degrees.

Returns:
- `PIL.Image.Image`: The rotated image.

Random rotation

Randomly rotate the input image by an angle within the specified range.

Parameters:
- `image` (PIL.Image.Image): The input image to be randomly rotated.
- `max_angle` (float, optional): The maximum absolute angle of rotation in degrees. Default is 30.

Returns:
- `PIL.Image.Image`: The randomly rotated image.

Resize

Resize the input image to the specified size.

Parameters:
- `image` (PIL.Image.Image): The input image to be resized.
- `size` (tuple): The new size in the format (width, height).

Returns:
- `PIL.Image.Image`: The resized image.

Crop

Crop the input image to the specified rectangular region.

Parameters:
- `image` (PIL.Image.Image): The input image to be cropped.
- `box` (tuple): A tuple (left, upper, right, lower) specifying the region to crop.

Returns:
- `PIL.Image.Image`: The cropped image.

Random crop

Randomly crop a region from the input image.

Parameters:
- `image` (PIL.Image.Image): The input image from which to extract the random crop.
- `size` (tuple): The size of the output crop in the format (width, height).

Returns:
- `PIL.Image.Image`: The randomly cropped image region.

Shuffle words

This function takes a list of sentences and randomly shuffles the order of words in each sentence, creating variations for text augmentation or diversity.

Parameters:
- `text` (list of str): List of sentences where each sentence's words needs to be shuffled.

Returns:
- `list of str`: List of sentences with randomly shuffled words.

Last updated