title: better regular expression for splitting sentences in ruby?
body: <p>I am working on something that counts how frequently a word appears in a bunch of text, tells in which sentence(s) it appears, and sorts the result by the frequency of each word. For example:
  <img src="https://i.stack.imgur.com/LxnkG.png" alt="sample input and out put"></p>
  
  <p>and this is what I have so far:</p>
  
  <pre><code>File.open('sample_text.txt', 'r') do |f| # open a file named "sample_text.txt"
  
  content = f.read # turn the content into a long string
  
  # split the string by sentences
  sentences = content.split(/\.|\?|\!/).each do |es|
  
    es.split(/\W|\s/).each do |w| 
       #split into individual words 
       #and for each word, find matched words in the content
  
    end
  
  end
  end
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <p><strong>1.</strong>
  Is there a better regex for splitting the sentences? Now, <code>split(/\.|\?|\!/)</code> will take <code>web 2.0</code> as two sentences <code>web 2</code> and <code>0</code>.</p>
  
  <p><strong>2.</strong>
  Can anyone give me some hint on how to do the part that returns an array of sentences that a word is in?</p>