title: NLP strategy for categorizing multiple multi-word phrases in context in python
body: <p>I'd like some help choosing an NLP strategy for categorizing journal entries. Here's an example of what a journal entry might look like and what a correct categorization would be. </p>
  
  <p>"Yesterday, I got terrible sleep. I felt pretty tired, so my productivity for the day wasn't very good."</p>
  
  <p>Categorization: "Sleep: terrible" and "Productivity: wasn't very good"</p>
  
  <p>I have a large set of personal journals. people are going to be talking about things they've done (or tried to do) and how it worked out ("good", "bad"). There will be multiple attempts and ratings per entry and i need to match them correctly.</p>
  
  <p>Now, one approach I could take is to use Spacy's matcher in Python and come up with a list of multi-word attributes, like</p>
  
  <pre><code># Initialize the Matcher with the shared vocabulary
  matcher = Matcher(nlp.vocab)
  
  # Create a pattern matching two tokens: "iPhone" and "X"
  pattern = [{'TEXT': 'not'}, {'TEXT': 'very'}, {'TEXT': 'good'}]
  </code></pre>
  
  <p>But, the question is, even if I come up with a new dictionary of ratings and elements, how do I match them in context, like the right attribute/adjective/rating with the correct element (like productivity or sleep). </p>
  
  <p>I'm sure there's a more efficient way to do this but I'm not quite sure. Any help would be great and let me know if I can make this question better.</p>