public static function SuggestionHelper::calculateDensity in Autocomplete Search Suggestions 8
Same name and namespace in other branches
- 8.2 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::calculateDensity()
- 3.0.x src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::calculateDensity()
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()
- SuggestionEditForm::submitForm in src/
Form/ SuggestionEditForm.php - AJAX callback for the indexing form.
- SuggestionHelper::insert in src/
SuggestionHelper.php - Add a suggestion.
- SuggestionHelper::updateSrc in src/
SuggestionHelper.php - Calculate the ngram's density.
- suggestion_surfer_submit in ./
suggestion.module - Custom submit function to add surfer suggestions.
File
- src/
SuggestionHelper.php, line 90
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Namespace
Drupal\suggestionCode
public static function calculateDensity($src = 0, $atoms = 1, $qty = 0) {
$score = intval($src) * self::C;
return (double) $score + self::getDelta(self::MAX - $score, intval(pow($atoms + $qty, self::EXP)));
}