title: How to search and replace keywords in strings in python from multiple categories?
body: <p>Assume I have a string which reads:</p>
  
  <pre><code>'''
  Looking closely we find Pepsi and Coca-cola have been the two two biggest brands of soda in the world for the past four years.
  '''
  </code></pre>
  
  <p>and I want to represent mapping of words to its classes as :</p>
  
  <pre><code>classes={"NAME":["pepsi","coca-cola", "james","jill"...],"CATEGORY":["soda","food","automobile"....],"NUMBER":["one","two","three","four"....]}
  </code></pre>
  
  <p>So that at the end I want to have the original string as :</p>
  
  <pre><code>Looking closely we find NAME and NAME have been the two biggest brands of CATEGORY in the world for the past NUMBER years
  </code></pre>
  
  <p>for a simple dict like :</p>
  
  <pre><code>rep = {"NAME": "pepsi", "CATEGORY": "soda"....}
  </code></pre>
  
  <p>I can replace the words for above dict but how do I do that if there more than one word per key?</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>stringh=sentence.lower()
  
  for i,j in rep.items():
      stringh = stringh.replace(j, i)
  
  print stringh
  </code></pre>