From 9c37d30d89ee861d13cc6d53d8da378d691541d4 Mon Sep 17 00:00:00 2001 From: Dominik Pfennig <dominik@suma-ev.de> Date: Thu, 23 Aug 2018 09:48:05 +0200 Subject: [PATCH] Fixed a bug in the Stopwords --- app/MetaGer.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/MetaGer.php b/app/MetaGer.php index c8b309558..fdecde0f8 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -1213,11 +1213,18 @@ class MetaGer private function searchCheckStopwords($request) { + $oldQ = $this->q; // matches '[... ]-test[ ...]' - while (preg_match("/(^|.*?\s)-(\S+)(\s.*|$)/si", $this->q, $match)) { - $this->stopWords[] = $match[2]; - $this->q = $match[1] . $match[3]; + $words = preg_split("/\s+/si",$this->q); + $newQ = ""; + foreach($words as $word){ + if(strpos($word, "-") === 0 && strlen($word) > 1){ + $this->stopWords[] = substr($word, 1); + }else{ + $newQ .= " " . $word; + } } + $this->q = trim($newQ); # Overwrite Setting if submitted via Parameter if ($request->has('stop')) { $this->stopWords = []; @@ -1231,6 +1238,7 @@ class MetaGer } else { $this->stopWords[] = $stop; } + $this->q = $oldQ; } // print the stopwords as a user warning if (sizeof($this->stopWords) > 0) { -- GitLab