mirror of https://github.com/MISP/MISP
chg: [decaying] Better Inheritance and comments
parent
ed98d73be7
commit
46f6b92360
|
@ -11,7 +11,8 @@ abstract class DecayingModelBase
|
|||
return 'BONFIRE LIT';
|
||||
}
|
||||
|
||||
// get effective taxonomy ratio based on taxonomies attached to the attribute
|
||||
// Get effective taxonomy ratio based on taxonomies attached to the attribute
|
||||
// Basically, it adapts the ratio defined in the model to fit the actual attached tags
|
||||
protected function __getRatioScore($model, $tags)
|
||||
{
|
||||
$ratioScore = array();
|
||||
|
@ -89,7 +90,7 @@ abstract class DecayingModelBase
|
|||
return array('base_score' => $base_score, 'overridden' => $overridden_tags, 'tags' => $tags, 'taxonomy_effective_ratios' => $taxonomy_effective_ratios, 'default_base_score' => $default_base_score);
|
||||
}
|
||||
|
||||
// compute the current score for the provided attribute according to the last sighting with the provided model
|
||||
// Compute the current score for the provided attribute according to the last sighting with the provided model
|
||||
final public function computeCurrentScore($user, $model, $attribute, $base_score = false, $last_sighting_timestamp = false)
|
||||
{
|
||||
if ($base_score === false) {
|
||||
|
@ -111,8 +112,9 @@ abstract class DecayingModelBase
|
|||
return $this->computeScore($model, $attribute, $base_score, $timestamp - $last_sighting_timestamp);
|
||||
}
|
||||
|
||||
// compute the score for the provided attribute according to the elapsed time with the provided model
|
||||
// Compute the score for the provided attribute according to the elapsed time with the provided model
|
||||
abstract public function computeScore($model, $attribute, $base_score, $elapsed_time);
|
||||
// Return a True if the attribute should be marked as decayed
|
||||
abstract public function isDecayed($model, $attribute, $score);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,7 @@ class PolynomialExtended extends Polynomial
|
|||
|
||||
public function computeScore($model, $attribute, $base_score, $elapsed_time)
|
||||
{
|
||||
if ($elapsed_time < 0) {
|
||||
return 0;
|
||||
}
|
||||
$decay_speed = $model['DecayingModel']['parameters']['decay_speed'];
|
||||
$lifetime = $model['DecayingModel']['parameters']['lifetime']*24*60*60;
|
||||
$score = $base_score * (1 - pow($elapsed_time / $lifetime, 1 / $decay_speed));
|
||||
$score = parent::computeScore($model, $attribute, $base_score, $elapsed_time);
|
||||
|
||||
// handle `retention` taxonomy tags
|
||||
$temp = $this->__getPrioritizedTag($attribute);
|
||||
|
@ -53,8 +48,7 @@ class PolynomialExtended extends Polynomial
|
|||
|
||||
public function isDecayed($model, $attribute, $score)
|
||||
{
|
||||
$threshold = $model['DecayingModel']['parameters']['threshold'];
|
||||
return $threshold > $score;
|
||||
return parent::isDecayed($model, $attribute, $score);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue