function weight(keywords, obj, fields, weights) {
    var value = 0
    parseKeywords(keywords).forEach(function (keyword) {
      var pattern = new RegExp(keyword, 'img') // Global, Multi-line, Case-insensitive
      fields.forEach(function (field, index) {
        if (obj.hasOwnProperty(field)) {
          var matches = obj[field].match(pattern)
          value += matches ? matches.length * weights[index] : 0
        }
      })
    })
    return value
  }
Calculate the weight of a matched post/page/category/tag.
@param Object            obj     Object to be weighted
@param Array<String>     fields  Object's fields to find matches
@param Array<Integer>    weights Weight of every field