Skip to content
Snippets Groups Projects
Commit 6f07224d authored by Aria Givi's avatar Aria Givi
Browse files

Vergleich von Phrasen mit Ergebnisbeschreibungen. Ergebnisse, welche die...

Vergleich von Phrasen mit Ergebnisbeschreibungen. Ergebnisse, welche die Phrase enthalten werden besser bewertet.
parent b56cfcb9
Branches
No related tags found
1 merge request!1365Resolve "Filter Options for MetaGer"
......@@ -1098,7 +1098,7 @@ class MetaGer
// matches '[... ]"test satz"[ ...]'
while (preg_match("/(^|.+\s)\"(.+)\"(?:\s(.+)|($))/si", $tmp, $match)) {
$tmp = $match[1] . $match[3];
$this->phrases[] = strtolower($match[2]);
$this->phrases[] = $match[2];
}
foreach ($this->phrases as $phrase) {
$p .= "\"$phrase\", ";
......@@ -1133,8 +1133,16 @@ class MetaGer
public function rankAll()
{
foreach ($this->engines as $engine) {
$engine->rank($this->getQ());
$phraseSearch = sizeof($this->getPhrases()) > 0 ? true : false;
if($phraseSearch) {
foreach ($this->engines as $engine) {
$engine->rank($this->getQ(), $this->getPhrases());
}
} else {
foreach ($this->engines as $engine) {
$engine->rank($this->getQ());
}
}
}
......
......@@ -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,10 @@ class Result
$rank -= $this->calcYandexBoost($eingabe);
}
if(!empty($phrases)) {
$rank += $this->calcPhraseSearchBoost($phrases);
}
$this->rank = $rank;
}
......@@ -131,6 +136,17 @@ class Result
return 0;
}
private function calcPhraseSearchBoost($phrases) {
$containsPhrase = true;
foreach($phrases as $phrase) {
if(strstr($this->longDescr, $phrase) == false) {
$containsPhrase = false;
}
}
return $containsPhrase ? 1 : 0;
}
# Berechnet den Ranking-Boost durch ??? URL
public function calcURLBoost($tmpEingabe)
{
......
......@@ -166,10 +166,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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment