From 25a58578baf32a4b3593f89a9190b481120e7835 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Mon, 28 Sep 2020 10:30:02 +0200 Subject: [PATCH] fix: [decaying] 2-tag base_score ratio. Fix #6352 --- app/Model/DecayingModelsFormulas/Base.php | 2 +- app/webroot/js/decayingModelSimulation.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/Model/DecayingModelsFormulas/Base.php b/app/Model/DecayingModelsFormulas/Base.php index 98d2bc175..be5f2c543 100644 --- a/app/Model/DecayingModelsFormulas/Base.php +++ b/app/Model/DecayingModelsFormulas/Base.php @@ -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']; diff --git a/app/webroot/js/decayingModelSimulation.js b/app/webroot/js/decayingModelSimulation.js index fe8b4177a..f7fb2381c 100644 --- a/app/webroot/js/decayingModelSimulation.js +++ b/app/webroot/js/decayingModelSimulation.js @@ -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 = /^(?[^:="]+):(?[^:="]+)(="(?[^:="]+)")?$/ + 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;