title: Regular expressions in Ruby
body: <p>I've got an external text file which looks like this:</p>
  
  <pre><code>This_ART is_P an_ART example_N.
  Thus_KONJ this_ART is_P a_ART part_N of_PREP it_N.
  </code></pre>
  
  <p>Now I want to open this file in Ruby and make an Array with every annotated word. My attempt looks like this:</p>
  
  <pre><code>def get_entries(file)
    return File.open(file).map { |x| x.split(/\W+_[A-Z]+/) }
  end
  </code></pre>
  
  <p>but the execution just returns an Array with each sentence as a member:</p>
  
  <pre><code>[["This_ART is_P an_ART example_N.\n"],["Thus_KONJ this_ART is_P a_ART part_N of PREP it_N.\n"]]
  </code></pre>
  
  <p>The punctuation and the escape characters are included. Where is the mistake or what do I have to change to get the correct array?</p>