Skip to content
Snippets Groups Projects
Commit 9c37d30d authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Fixed a bug in the Stopwords

parent 89d0e52c
No related branches found
No related tags found
No related merge requests found
...@@ -1213,11 +1213,18 @@ class MetaGer ...@@ -1213,11 +1213,18 @@ class MetaGer
private function searchCheckStopwords($request) private function searchCheckStopwords($request)
{ {
$oldQ = $this->q;
// matches '[... ]-test[ ...]' // matches '[... ]-test[ ...]'
while (preg_match("/(^|.*?\s)-(\S+)(\s.*|$)/si", $this->q, $match)) { $words = preg_split("/\s+/si",$this->q);
$this->stopWords[] = $match[2]; $newQ = "";
$this->q = $match[1] . $match[3]; 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 # Overwrite Setting if submitted via Parameter
if ($request->has('stop')) { if ($request->has('stop')) {
$this->stopWords = []; $this->stopWords = [];
...@@ -1231,6 +1238,7 @@ class MetaGer ...@@ -1231,6 +1238,7 @@ class MetaGer
} else { } else {
$this->stopWords[] = $stop; $this->stopWords[] = $stop;
} }
$this->q = $oldQ;
} }
// print the stopwords as a user warning // print the stopwords as a user warning
if (sizeof($this->stopWords) > 0) { if (sizeof($this->stopWords) > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment