title: Using a regular expression to find all noun phrases in a paragraph following the occurrence of a specific phrase
body: <p>I have a data frame of paragraphs, which I have (*can) split into word tokens and sentence tokens and am looking to find all the noun phrases following any instance where the phrase: "contribute to" or "donate to" occurs.</p>
  
  <p>Or really some form of that, so: </p>
  
  <pre><code>"Contributions are welcome to be made to the charity of your choice." 
  
  ---&gt; would return: "the charity of your choice"
  </code></pre>
  
  <p>and </p>
  
  <pre><code>"blah blah blah donations, in honor of Firstname Lastname, can be made to ABC Foundation"
  
  ---&gt; would return: "ABC Foundation"
  </code></pre>
  
  <p>I've created a regular expression work-around that captures the correct phrase about 90% of the time... see below: </p>
  
  <pre><code>text = nltk.Text(nltk.word_tokenize(x))
  donation = TokenSearcher(text).findall(r"&lt;\.&gt; &lt;.*&gt;{,15}? &lt;donat.*|contrib.*&gt; &lt;.*&gt;*? &lt;to&gt; (&lt;.*&gt;+?) &lt;\.|\,|\;&gt; ")
  donation = [' '.join(tokens) for tokens in donation]
  return donation
  </code></pre>
  
  <p>I'd like to clean up that regular expression to get rid of the "{,15}" requirements because it's missing some of the values that I need. However, I'm not too polished with the "greedy" expressions and can't get it to work correctly. </p>
  
  <p>so this phrase: </p>
  
  <pre><code>While she lived a full life , had many achievements and made many 
  **contributions** , FirstName is remembered by most for her cheerful smile ,
  colorful track suits , and beautiful necklaces hand made by daughter FirstName .
  FirstName always cherished her annual visit home for Thanksgiving to visit
  brother FirstName LastName
  </code></pre>
  
  <p>is returning: "visit brother FirstName Lastname" due to the previous mentioning of contributions even though the word "to" comes well after 15 words later.</p>