title: use a custom function to find all words in a column
body: <p><strong>Background</strong></p>
  
  <p>The following question is a variation from <a href="https://stackoverflow.com/questions/56826420/unnest-grab-keywords-nextwords-beforewords-function">Unnest grab keywords/nextwords/beforewords function</a>. </p>
  
  <p><strong>1)</strong> I have the following <code>word_list</code></p>
  
  <pre><code>word_list = ['crayons', 'cars', 'camels']
  </code></pre>
  
  <p><strong>2)</strong> And <code>df1</code></p>
  
  <pre><code>l = ['there are many crayons, in the blue box crayons that are',
       'cars! i like a lot of sports cars because they go fast',
       'the camels, in the middle east have many camels to ride ']
  df1 = pd.DataFrame(l, columns=['Text'])
  
  df1
           Text
  0   there are many crayons, in the blue box crayons that are
  1   cars! i like a lot of sports cars because they go fast
  2   the camels, in the middle east have many camels to ride
  </code></pre>
  
  <p><strong>3)</strong> I also have a function <code>find_next_words</code> which uses <code>word_list</code> to grab words from <code>Text</code> column in <code>df1</code></p>
  
  <pre><code>def find_next_words(row, word_list):
  
      sentence = row[0]
  
      trigger_words = []
      next_words = []
  
      for keyword in word_list:
  
          words = sentence.split()
  
          for index in range(0, len(words) - 1):
              if words[index] == keyword:
                  trigger_words.append(keyword)
                  next_words.append(words[index + 1:index + 3]) 
  
      return pd.Series([trigger_words, next_words], index = ['TriggerWords','NextWords'])
  </code></pre>
  
  <p><strong>4)</strong> And it's pieced together with the following</p>
  
  <pre><code>df2 = df1.join(df.apply(lambda x: find_next_words(x, word_list), axis=1))
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>    Text           TriggerWords        NextWords
  0                   [crayons]        [[that, are]]
  1                   [cars]           [[because, they]]
  2                   [camels]         [[to, ride]]
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p><strong>5)</strong> The output misses the following </p>
  
  <p><code>crayons,</code> from row <code>0</code> of <code>Text</code> column <code>df1</code></p>
  
  <p><code>cars!</code>    from row <code>1</code> of <code>Text</code> column <code>df1</code></p>
  
  <p><code>camels,</code>  from row <code>2</code> of <code>Text</code> column <code>df1</code></p>
  
  <p><strong>Goal</strong></p>
  
  <p><strong>6)</strong> Grab all corresponding words from <code>df1</code> even if the words in <code>df1</code> have a slight variation e.g. <code>crayons,</code> <code>cars!</code> from the words in <code>word_list</code> </p>
  
  <p><em>(For this toy example, I know I can easily fix this problem by just adding these word variations to <code>word_list = ['crayons,','crayons', 'cars!',</code>cars<code>, 'camels,', 'camels'].</code> But this would be impractical to do with my my real word_list, which contains ~20K words)</em></p>
  
  <p><strong>Desired Output</strong></p>
  
  <pre><code>Text           TriggerWords              NextWords
  0               [crayons, crayons]  [[in, the], [that, are]]
  1               [cars, cars]        [[i,like],[because, they]]
  2               [camels, camels]    [[in, the], [to, ride]]
  </code></pre>
  
  <p><strong>Questions</strong></p>
  
  <p>How do I 1) tweak my <code>word_list</code> (e.g. regex?) 2) or <code>find_next_words</code> function to achieve my desired output?</p>