You are here

public static function SuggestionHelper::calculateDensity in Autocomplete Search Suggestions 7

Calculate the ngram's density.

Parameters

int $src: The ngram source.

int $atoms: The number of atoms in the ngram.

int $qty: The submission count.

Return value

float The suggestion's score.

4 calls to SuggestionHelper::calculateDensity()
SuggestionHelper::insert in src/SuggestionHelper.php
Add a suggestion.
SuggestionHelper::updateSrc in src/SuggestionHelper.php
Calculate the ngram's density.
suggestion_admin_edit_form_submit in ./suggestion.admin.inc
Custom submit function for the suggestion setting form.
suggestion_surfer_submit in ./suggestion.module
Custom submit function to add surfer suggestions.

File

src/SuggestionHelper.php, line 94
Helper methods for the suggestion module.

Class

SuggestionHelper
Provides helper methods for suggestions.

Code

public static function calculateDensity($src = 0, $atoms = 1, $qty = 0) {
  $score = intval($src) * self::C;
  return (double) $score + self::getDelta(self::MAX_SCORE - $score, intval(pow($atoms + $qty, self::EXP)));
}