fix: [decaying] 2-tag base_score ratio. Fix #6352

pull/6294/head
mokaddem 2020-09-28 10:30:02 +02:00
parent d0c7c44a2f
commit 25a58578ba
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 17 additions and 5 deletions

View File

@ -106,7 +106,7 @@ abstract class DecayingModelBase
$flag_contain_matching_taxonomy = false;
if (!empty($taxonomy_effective_ratios)) {
foreach ($tags as $k => $tag) {
$taxonomy = explode('=', $tag['Tag']['name'])[0];
$taxonomy = $this->__extractTagBasename($tag['Tag']['name'])['base'];
if (isset($taxonomy_effective_ratios[$taxonomy])) {
$flag_contain_matching_taxonomy = true;
$base_score += $taxonomy_effective_ratios[$taxonomy] * $tag['Tag']['numerical_value'];

View File

@ -548,11 +548,11 @@
if (tag === false) {
return ['', '', '', this.base_score.toFixed(2)];
}
var namespace = tag.Tag.name.split('=')[0];
var basename = this._extractTagPart(tag.Tag.name);
if (this.base_score_config.taxonomy_effective_ratios[namespace] !== undefined) {
var html1 = this.base_score_config.taxonomy_effective_ratios[namespace].toFixed(2);
var html4 = (parseFloat(tag.Tag.numerical_value) * this.base_score_config.taxonomy_effective_ratios[namespace]).toFixed(2);
if (this.base_score_config.taxonomy_effective_ratios[basename] !== undefined) {
var html1 = this.base_score_config.taxonomy_effective_ratios[basename].toFixed(2);
var html4 = (parseFloat(tag.Tag.numerical_value) * this.base_score_config.taxonomy_effective_ratios[basename]).toFixed(2);
} else {
var html1 = '0';
var html4 = '0';
@ -639,6 +639,18 @@
}
this.$container;
},
_extractTagPart: function(tag) {
var reTag = /^(?<namespace>[^:="]+):(?<predicate>[^:="]+)(="(?<value>[^:="]+)")?$/
var result = tag.match(reTag);
var tagBaseName = '';
if (result.groups.value !== undefined) {
tagBaseName = result.groups.namespace + ':' + result.groups.predicate;
} else {
tagBaseName = result.groups.namespace;
}
return tagBaseName;
}
}
$.BasescoreComputationTable = BasescoreComputationTable;