rarity_sum

rarity_sum(str fieldname)calculates the rarity score for matched keywords. The function calculates the score over keywords or lists of keywords, using the TF-IDF formula.

Input

  • fieldname1 (str) - the name of the field to match in query document. params[fieldname1] must be of type keyword or list[keyword]

  • fieldname2 (str, default=fieldname1) - the name of the field to match in database document. V[fieldname2] must be of type keyword or list[keyword]

Output

  • score (float) - TF-IDF for the matched keywords. If params[fieldname] and params[fieldname] are lists of, the function will return the sum of rarity score out of all matched keywords

Example:

score = rarity_sum("cities")

The function will return the sum of rarity scores of all matched keywords between params["cities"] and doc["cities"]

Last updated