title: How to make a formal text when there is a repeating letters in a word?
body: <p>I have a function and inserted a new method in my code. I need to make a formal text that includes detection of repeated letters in a word</p>
  <p>For example of the input text: Helllooooo. I don't know this.</p>
  <p>Expected output: Hello. I do not know this.</p>
  <p>This is my code for function:</p>
  <pre><code>import re
  from nltk.corpus import wordnet
  R_patterns = [
     (r'won\'t', 'will not'),
     (r'can\'t', 'cannot'),
     (r'i\'m', 'i am'),
     (r'(\w+)\'ll', '\g&lt;1&gt; will'),
     (r'(\w+)n\'t', '\g&lt;1&gt; not'),
     (r'(\w+)\'ve', '\g&lt;1&gt; have'),
     (r'(\w+)\'s', '\g&lt;1&gt; is'),
     (r'(\w+)\'re', '\g&lt;1&gt; are'),
  ]
  
  class REReplacer(object):
      def __init__(self, patterns=R_patterns):
          self.patterns = [(re.compile(regex), repl) for (regex, repl) in patterns]
  
          self.repeat_regexp = re.compile(r'(\w*)(\w)\2(\w*)') #for not repeating letters in a word
          self.reple = r'\1\2\3' #for not repeating letters in a word
  
      def replace(self, text):
          s = text
          for (pattern, repl) in self.patterns:
              s = re.sub(pattern, repl, s)
          return s
  
          #for not repeating letters in a word 
          if wordnet.synsets(s): 
              return s
          repl_word = self.repeat_regexp.sub(self.reple, s)
          if repl_word != s:
              return self.replace(repl_word)
          else:
              return repl_word
  </code></pre>
  <p>The code for not repeating letters in a word is not working. I did make a comment in the part for not repeating letters.</p>