title: Extract spelled out numbers from string in R
body: <p>I am trying to extract spelled-out numbers from strings, plus extracting the word that comes after the number. I have managed to do this by a laboursome way of writing my own code including the spelled-out numbers to search for (here an example from <code>stringr::sentences</code>:</p>
  
  <pre><code>numbers &lt;- str_c(c(" one ", " two ", " three ", " four ", " five ", " six ", " seven ", " eight "," nine ", " ten "), "([^ ]+)")
  number_match &lt;- str_c(numbers, collapse = "|")
  
  reduced &lt;- sentences %&gt;%
     str_detect(number_match)
  sent &lt;- sentences[reduced==TRUE]
  str_extract(sent, number_match)
  </code></pre>
  
  <p>These are the extracted strings: </p>
  
  <pre><code> [1] " seven books"   " two met"       " two factors"   " three lists"   " seven is"      " two when"      " ten inches."   " one war"      
   [9] " one button"    " six minutes."  " ten years"     " two shares"    " two distinct"  " five cents"    " two pins"      " five robins." 
  [17] " four kinds"    " three story"   " three inches"  " six comes"     " three batches" " two leaves."
  </code></pre>
  
  <p>As I cannot possibly know upfront if I have considered all numbers possible, I was wondering if R provides a tool that can identify spelled-out numbers? I have found similar questions, e.g. <a href="https://stackoverflow.com/questions/15690974/convert-spelled-out-number-to-number">Convert spelled out number to number</a>
  but this is unfortunately not a question about R.</p>
  
  <p>Any help is appreciated.</p>