class_docstr: A set of functions used to augment data.
  
  Typical usage: ::
      >>> import nltk
      >>> nltk.download('punkt')
      >>> nltk.download('wordnet')
      >>> nltk.download('averaged_perceptron_tagger')
      >>> from textaugment import Wordnet
      >>> t = Wordnet(v=True,n=True,p=0.5)
      >>> t.augment('I love school')
      i adore school
docstr: The method to replace words with synonyms
  
  :type data: str
  :param data: sentence used for data augmentation
  :rtype:   str
  :return:  The augmented data
  :type lang: str
  :param lang: choose lang
  :type top_n: int
  :param top_n: top_n of synonyms to randomly choose from
  
  :rtype:   str
  :return:  The augmented data
code: def replace(self, data, lang, top_n):
      """
      The method to replace words with synonyms
  
      :type data: str
      :param data: sentence used for data augmentation
      :rtype:   str
      :return:  The augmented data
      :type lang: str
      :param lang: choose lang
      :type top_n: int
      :param top_n: top_n of synonyms to randomly choose from
  
      :rtype:   str
      :return:  The augmented data
      """
      data = data.lower().split()
      data_tokens = [
          [i, x, y] for i, (x, y) in enumerate(nltk.pos_tag(data))
      ]  # Convert tuple to list
      if self.v:
          for loop in range(self.runs):
              words = [[i, x] for i, x, y in data_tokens if y[0] == "V"]
              words = [
                  i for i in self.geometric(data=words)
              ]  # List of selected words
              if len(words) >= 1:  # There are synonyms
                  for word in words:
                      synonyms1 = wordnet.synsets(
                          word[1], wordnet.VERB, lang=lang
                      )  # Return verbs only
                      synonyms = list(
                          set(
                              chain.from_iterable(
                                  [
                                      syn.lemma_names(lang=lang)
                                      for syn in synonyms1
                                  ]
                              )
                          )
                      )
                      synonyms_ = (
                          []
                      )  # Synonyms with no underscores goes here
                      for w in synonyms:
                          if "_" not in w:
                              synonyms_.append(
                                  w
                              )  # Remove words with underscores
                      if len(synonyms_) >= 1:
                          synonyms_ = synonyms_[
                              : top_n if top_n else len(synonyms_)
                          ]  # use top n or all synonyms
                          synonym = self.geometric(
                              data=synonyms_
                          ).tolist()
                          if synonym:  # There is a synonym
                              data[int(word[0])] = synonym[
                                  0
                              ].lower()  # Take the first success
  
      if self.n:
          for loop in range(self.runs):
              words = [[i, x] for i, x, y in data_tokens if y[0] == "N"]
              words = [
                  i for i in self.geometric(data=words)
              ]  # List of selected words
              if len(words) >= 1:  # There are synonyms
                  for word in words:
                      synonyms1 = wordnet.synsets(
                          word[1], wordnet.NOUN, lang=lang
                      )  # Return nouns only
                      synonyms = list(
                          set(
                              chain.from_iterable(
                                  [
                                      syn.lemma_names(lang=lang)
                                      for syn in synonyms1
                                  ]
                              )
                          )
                      )
                      synonyms_ = (
                          []
                      )  # Synonyms with no underscores goes here
                      for w in synonyms:
                          if "_" not in w:
                              synonyms_.append(
                                  w
                              )  # Remove words with underscores
                      if len(synonyms_) >= 1:
                          synonyms_ = synonyms_[
                              : top_n if top_n else len(synonyms_)
                          ]  # use top n or all synonyms
                          synonym = self.geometric(
                              data=synonyms_
                          ).tolist()
                          if synonym:  # There is a synonym
                              data[int(word[0])] = synonym[
                                  0
                              ].lower()  # Take the first success
  
      return " ".join(data)
  
file_path: textaugment/textaugment/wordnet.py
imports: import numpy
  import nltk
  from itertools import chain
  from nltk.corpus import wordnet
label_desc: Use image node_id 3 for calling the Wordnet obj's underlying member method code with example usage: obj.replace(data, lang, top_n) and returns: str