class_docstr: This class is an implementation of the original EDA algorithm (2019) [1].
  
  [1] Wei, J. and Zou, K., 2019, November. EDA: Easy Data Augmentation Techniques for Boosting Performance on
  Text Classification Tasks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing
  and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP) (pp. 6383-6389).
  https://www.aclweb.org/anthology/D19-1670.pdf
  
  Example usage: ::
      >>> from textaugment import EDA
      >>> t = EDA()
      >>> t.synonym_replacement("John is going to town",top_n=3)
      John is give out to town
      >>> t.random_deletion("John is going to town", p=0.2)
      is going to town
      >>> t.random_swap("John is going to town")
      John town going to is
      >>> t.random_insertion("John is going to town")
      John is going to make up town
class_docstr_tok: ["This","class","is","an","implementation","of","the","original","EDA","algorithm","(","2019",")","[","1","]",".","[","1","]","Wei",",","J.","and","Zou",",","K.",",","2019",",","November",".","EDA",":","Easy","Data","Augmentation","Techniques","for","Boosting","Performance","on","Text","Classification","Tasks",".","In","Proceedings","of","the","2019","Conference","on","Empirical","Methods","in","Natural","Language","Processing","and","the","9th","International","Joint","Conference","on","Natural","Language","Processing","(","EMNLP-IJCNLP",")","(","pp",".","6383-6389",")",".","https",":","\/\/www.aclweb.org\/anthology\/D19-1670.pdf","Example","usage",":",":",":",">",">",">","from","textaugment","import","EDA",">",">",">","t","=","EDA","(",")",">",">",">","t.synonym_replacement","(","``","John","is","going","to","town","''",",","top_n=3",")","John","is","give","out","to","town",">",">",">","t.random_deletion","(","``","John","is","going","to","town","''",",","p=0.2",")","is","going","to","town",">",">",">","t.random_swap","(","``","John","is","going","to","town","''",")","John","town","going","to","is",">",">",">","t.random_insertion","(","``","John","is","going","to","town","''",")","John","is","going","to","make","up","town"]
docstr: Replace n words in the sentence with synonyms from wordnet
  
  :type sentence: str
  :param sentence: Sentence
  :type n: int
  :param n: Number of repetitions to replace
  :type top_n: int
  :param top_n: top_n of synonyms to randomly choose from
  
  :rtype:   str
  :return:  Augmented sentence
docstr_tok: ["Replace","n","words","in","the","sentence","with","synonyms","from","wordnet",":","type","sentence",":","str",":","param","sentence",":","Sentence",":","type","n",":","int",":","param","n",":","Number","of","repetitions","to","replace",":","type","top_n",":","int",":","param","top_n",":","top_n","of","synonyms","to","randomly","choose","from",":","rtype",":","str",":","return",":","Augmented","sentence"]
code: def synonym_replacement(
      self, sentence: str, n: int = 1, top_n: int = None
  ):
      """Replace n words in the sentence with synonyms from wordnet
  
      :type sentence: str
      :param sentence: Sentence
      :type n: int
      :param n: Number of repetitions to replace
      :type top_n: int
      :param top_n: top_n of synonyms to randomly choose from
  
      :rtype:   str
      :return:  Augmented sentence
      """
      self.validate(sentence=sentence, n=n)
      self.n = n
      self.sentence = sentence
      words = sentence.split()
      new_words = words.copy()
      random_word_list = sorted(
          set([word for word in words if word not in self.stopwords])
      )
      random.shuffle(random_word_list)
      replaced = 0
      for random_word in random_word_list:
          synonyms = self._get_synonyms(random_word)
          if len(synonyms) > 0:
              synonyms = synonyms[
                  : top_n if top_n else len(synonyms)
              ]  # use top n or all synonyms
              synonym = random.choice(synonyms)
              new_words = [
                  synonym if word == random_word else word
                  for word in new_words
              ]
              replaced += 1
          if replaced >= self.n:
              break
      sentence = " ".join(new_words)
  
      return sentence
  
file_path: textaugment/textaugment/eda.py
imports: import nltk
  from nltk.corpus import wordnet, stopwords
  import random
label_desc: Use image node_id 6 for calling the EDA obj's underlying member method code with example usage: obj.synonym_replacement(sentence, n, top_n) and returns: sentence