From 4d8a510c45186a067a4b2fd4747dcdf2b72cb13d Mon Sep 17 00:00:00 2001 From: Netkas Date: Sat, 29 Jul 2023 16:23:30 -0400 Subject: [PATCH] Bumped version to 1.0.2 --- CHANGELOG.md | 8 ++++++++ project.json | 2 +- src/Keybert/Keybert.php | 25 +++++++++++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8f1b10..aacd642 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.2] - 2023-07-29 + +### Fixed + * Minor bug fix + + + ## [1.0.1] - 2023-07-29 ### Fixed @@ -12,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 wrapper class. + ## [1.0.0] - 2023-07-23 ### Added diff --git a/project.json b/project.json index 8d2252e..5bda46f 100644 --- a/project.json +++ b/project.json @@ -12,7 +12,7 @@ "assembly": { "name": "Keybert", "package": "net.nosial.keybert", - "version": "1.0.1", + "version": "1.0.2", "uuid": "1695515c-2857-11ee-a7a6-6d740ea6cd07" }, "execution_policies": [ diff --git a/src/Keybert/Keybert.php b/src/Keybert/Keybert.php index e99aac1..3d66bb0 100644 --- a/src/Keybert/Keybert.php +++ b/src/Keybert/Keybert.php @@ -346,26 +346,27 @@ */ private function parseResults($results): array { - if (is_array($results)) + $parsedResults = []; + + if (is_array($results) && isset($results[0])) { - // check if the results are multi or single - if(is_array($results[0][0])) + // Check if the results are multi or single + if (is_array($results[0]) && isset($results[0][0]) && is_array($results[0][0])) { - // This is a multi-results - $parsedResults = []; - foreach($results as $result) + // This is multi-results + foreach ($results as $result) { $parsedResults[] = $this->parseSingleResult($result); } } - else + elseif (is_array($results[0])) { // This is a single-result $parsedResults = $this->parseSingleResult($results); } } - return $parsedResults ?? []; + return $parsedResults; } /** @@ -377,9 +378,13 @@ private function parseSingleResult($result): array { $parsedResult = []; - foreach($result as $keywordScore) + + foreach ($result as $keywordScore) { - $parsedResult[$keywordScore[0]] = $keywordScore[1]; + if (is_array($keywordScore) && count($keywordScore) === 2) + { + $parsedResult[$keywordScore[0]] = $keywordScore[1]; + } } return $parsedResult;