title: Algorithms for matching based on keywords intersection
body: <p>Suppose we have buyers and sellers that are trying to find each other in a market. Buyers can tag their needs with keywords; sellers can do the same for what they are selling. I'm interested in finding algorithm(s) that rank-order sellers in terms of their relevance for a particular buyer on the basis of their two keyword sets. </p>
  
  <p>Here is an example:    </p>
  
  <pre><code>buyer_keywords = {"furry", "four legs", "likes catnip", "has claws"} 
  </code></pre>
  
  <p>and then we have two potential sellers that we need to rank order in terms of their relevance: </p>
  
  <pre><code>seller_keywords[1] = {"furry", "four legs", "arctic circle", "white"}
  seller_keywords[2] = {"likes catnip", "furry", 
                        "hates mice", "yarn-lover", "whiskers"}
  </code></pre>
  
  <p>If we just use the intersection of keywords, we do not get much discrimination: both intersect on 2 keywords. If we divide the intersection count by the size of the set union, seller 2 actually does worse because of the greater number of keywords. This would seem to introduce an automatic penalty for any method not correcting keyword set size (and we definitely don't want to penalize adding keywords). </p>
  
  <p>To put a bit more structure on the problem, suppose we have some truthful measure of intensity of keyword attributes (which have to sum to 1 for each seller), e.g.,: </p>
  
  <pre><code>seller_keywords[1] = {"furry":.05, 
                        "four legs":.05, 
                        "arctic circle":.8, 
                        "white":.1}
  
  seller_keywords[2] = {"likes catnip":.5, 
                        "furry":.4, 
                        "hates mice":.02, 
                        "yarn-lover":.02, 
                        "whiskers":.06}
  </code></pre>
  
  <p>Now we could sum up the value of hits: so now Seller 1 only gets a score of .1, while Seller 2 gets a score of .9. So far, so good, but now we might get a third seller with a very limited, non-descriptive keyword set:</p>
  
  <pre><code>seller_keywords[3] = {"furry":1}
  </code></pre>
  
  <p>This catapults them to the top for any hit on their sole keyword, which isn't good.  </p>
  
  <p>Anyway, my guess (and hope) is that this is a fairly general problem and that there exist different algorithmic solutions with known strengths and limitations. This is probably something covered in CS101, so I think a good answer to this question might just be a link to the relevant references.  </p>