title: Replacing acronyms with their full forms in Python
body: <p>I have an acronym dictionary that has <code>keys</code> as an acronym and <code>values</code> as full forms.</p>
  <p>I want to replace the acronyms found in the <code>text_list</code> with the full forms to arrive at the <code>ouput_list</code></p>
  <pre><code>acronym_dict = {
      'QUO': 'Quotation',
      'IN': 'India',
      'SW': 'Software',
      'RE': 'Regular Expression'
  }
  
  text_list = [
      'The status QUO has changed', 'I SWEAR, This is part of IN_SW',
      'The update does not belong to the SW, version, branch',
      'This is a RE_Text'
  ]
  
  output_list = [
      'The status Quotation has changed',
      'I SWEAR, This is part of India_Software',
      'The update does not belong to the Software, version, branch',
      'This is Regular Expression_Text'
  ]
  </code></pre>
  <p>I wrote a method to do that</p>
  <pre><code>import string
  def remove_punctuations(text):
      punct_str = string.punctuation  # !&quot;#$%&amp;\'()*+,-./:;&lt;=&gt;?@[\\]^_`{|}~
      for punctuation in punct_str:
          text = text.replace(punctuation, ' ')
      return text.strip()
  
  def replace_single_acronym(text, acronym, fullform):
      words = text.split()
      return_words = []
      for w in words:
          if remove_punctuations(w).lower() == acronym.lower():
              return_words.append(w.replace(acronym, fullform))
          else:
              return_words.append(w)
      return &quot; &quot;.join(return_words)
  
  my_op_list = []
  for text in text_list:
      for acronym in acronym_dict.keys():
          text = replace_single_acronym(text, acronym, acronym_dict[acronym])
      my_op_list.append(text)
  </code></pre>
  <p>Ideally <code>output_list</code> and <code>my_op_list</code> should look the same. It prints the below result (failing in 2 instances)</p>
  <pre><code>['The status Quotation has changed',
   'I SWEAR, This is part of IN_SW',
   'The update does not belong to the Software, version, branch',
   'This is a RE_Text']
  </code></pre>
  <p>Also, the method <code>replace_single_acronym</code> is very slow on a corpus of 1000 <code>text_list</code> items.</p>
  <p>Can someone help me in adjusting the method to do it in the right and efficient way?</p>