title: Whats a good way to match text to sets of keywords (NLP)
body: <p>I'm trying to match an input text (e.g. a headline of a news article) to sets of keywords, s.t. the best-matching set can be selected.</p>
  <p>Let's assume, I have some sets of keywords:</p>
  <pre><code>[['democracy', 'votes', 'democrats'], ['health', 'corona', 'vaccine', 'pandemic'], ['security', 'police', 'demonstration']]
  </code></pre>
  <p>and as input the (hypothetical) headline: <code>New Pfizer vaccine might beat COVID-19 pandemic in the next few months.</code>. Obviously, it fits well to the second set of keywords.</p>
  <p>Exact matching words is one way to do it, but more complex situations might arise, for which it might make sense to use base forms of words (e.g. <code>duck</code> instead of <code>ducks</code>, or <code>run</code> instead of <code>running</code>) to enhance the algorithm. Now we're talking NLP already.</p>
  <p>I experimented with <a href="https://spacy.io" rel="nofollow noreferrer">Spacy</a> word and document embeddings (<a href="https://spacy.io/usage/vectors-similarity#converting" rel="nofollow noreferrer">example</a>) to determine similarity between a headline and each set of keywords. Is it a good idea to calculate document similarity between a full sentence and a limited number of keywords? Are there other ways?</p>
  <p>Related: <a href="https://stackoverflow.com/questions/11798389/what-nlp-tools-to-use-to-match-phrases-having-similar-meaning-or-semantics">What NLP tools to use to match phrases having similar meaning or semantics</a></p>