title: Bigram detection: Comparing a string with a list in order to merge certain substrings
body: <p>Considering I have a string:</p>
  
  <pre><code>text = "You are good at data mining and machine learning"
  </code></pre>
  
  <p>and also a list of possible bigrams:</p>
  
  <pre><code>bigrams = ["data mining", "machine learning"]
  </code></pre>
  
  <p>How could I detect those bigrams in the text and merge the two words together, so that my result would be a string like:</p>
  
  <pre><code>new_text = "You are good at data_mining and machine_learning"
  </code></pre>
  
  <p>I need to apply this to a much bigger string (corpus) and a longer list of bigrams.</p>
  
  <p>I tried it with string.replace() in:</p>
  
  <pre><code>new_text = [x.replace(" ","_") for x in text if x in bigrams]
  </code></pre>
  
  <p>But this results in an empty list.</p>