From d391efb067fbc8e54bd142a312d14709ea301cd9 Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 1 Nov 2023 09:29:33 +0000 Subject: [PATCH 1/2] Add define (keyword) to make a dictionary search --- engines/special/definition.php | 4 ++-- engines/special/special.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/special/definition.php b/engines/special/definition.php index 1ca5479a..037e74d3 100644 --- a/engines/special/definition.php +++ b/engines/special/definition.php @@ -7,7 +7,7 @@ public function get_request_url() { $word_to_define = $reversed_split_q[1]; return "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define"; } - + public function parse_results($response) { $json_response = json_decode($response, true); @@ -23,7 +23,7 @@ public function parse_results($response) { ) ); } - + } } ?> diff --git a/engines/special/special.php b/engines/special/special.php index 41f706f1..2eee8ef0 100644 --- a/engines/special/special.php +++ b/engines/special/special.php @@ -13,7 +13,7 @@ function check_for_special_search($query) { if ($amount_to_convert != 0) return 1; } - else if (strpos($query_lower, "mean") && count($split_query) >= 2) // definition + else if ((strpos($query_lower, "mean") || strpos($query_lower, "define")) && count($split_query) >= 2) // definition { return 2; } From 88bdcb1c35e6066620b2c0cf33ffe166029887ff Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 1 Nov 2023 11:24:40 +0000 Subject: [PATCH 2/2] Fix using define for definition --- engines/special/definition.php | 2 +- engines/special/special.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/special/definition.php b/engines/special/definition.php index 037e74d3..30be8d2f 100644 --- a/engines/special/definition.php +++ b/engines/special/definition.php @@ -4,7 +4,7 @@ class DefinitionRequest extends EngineRequest { public function get_request_url() { $split_query = explode(" ", $this->query); $reversed_split_q = array_reverse($split_query); - $word_to_define = $reversed_split_q[1]; + $word_to_define = $reversed_split_q[1] == "define" ? $reversed_split_q[0] : $reversed_split_q[1]; return "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define"; } diff --git a/engines/special/special.php b/engines/special/special.php index 2eee8ef0..a05975b6 100644 --- a/engines/special/special.php +++ b/engines/special/special.php @@ -13,7 +13,7 @@ function check_for_special_search($query) { if ($amount_to_convert != 0) return 1; } - else if ((strpos($query_lower, "mean") || strpos($query_lower, "define")) && count($split_query) >= 2) // definition + else if ((strpos($query_lower, "mean") || strpos($query_lower, "define") == 0) && count($split_query) >= 2) // definition { return 2; }