Commit 4817fac4 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '486-ergebniskorrektur-bei-phrasensuchen' into 'development'

Resolve "Ergebnisranking bei Phrasensuchen"

Closes #486

See merge request !838
parents bc48f16f e17f72af
......@@ -1145,7 +1145,7 @@ class MetaGer
public function rankAll()
{
foreach ($this->engines as $engine) {
$engine->rank($this->getQ());
$engine->rank($this->getQ(), $this->getPhrases());
}
}
......
......@@ -72,8 +72,9 @@ class Result
* + 0.02 * Sourcerank (20 - Position in Ergebnisliste des Suchanbieters)
* * Engine-Boost
*/
public function rank($eingabe)
{
public function rank($eingabe, $phrases = [])
{
$rank = 0;
# Boost für Source Ranking
......@@ -95,6 +96,11 @@ class Result
$rank -= $this->calcYandexBoost($eingabe);
}
# Boost für Vorkommen der Suchwörter in der Beschreibung bei Phrasensuchen
if(!empty($phrases)) {
$rank += $this->calcPhraseSearchBoost($phrases);
}
$this->rank = $rank;
}
......@@ -131,6 +137,18 @@ class Result
return 0;
}
# Berechnet den Ranking-Boost bei Phrasensuchen
private function calcPhraseSearchBoost($phrases) {
$containsPhrase = true;
foreach($phrases as $phrase) {
if(strstr($this->longDescr, $phrase) == false) {
$containsPhrase = false;
}
}
return $containsPhrase ? 0.1 : 0;
}
# Berechnet den Ranking-Boost durch ??? URL
public function calcURLBoost($tmpEingabe)
{
......
......@@ -182,10 +182,10 @@ abstract class Searchengine
}
# Ruft die Ranking-Funktion aller Ergebnisse auf.
public function rank($eingabe)
public function rank($eingabe, $phrases = [])
{
foreach ($this->results as $result) {
$result->rank($eingabe);
$result->rank($eingabe, $phrases);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment