From 67842ee0be9974652aaea8a55a418c60629fb48f Mon Sep 17 00:00:00 2001 From: coscialp Date: Fri, 1 Dec 2023 10:14:09 +0100 Subject: [PATCH] [Fix] update api prowritingaid --- edenai_apis/apis/prowritingaid/info.json | 2 +- .../outputs/text/spell_check_output.json | 71 +++++++++---------- .../apis/prowritingaid/prowritingaid_api.py | 15 ++-- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/edenai_apis/apis/prowritingaid/info.json b/edenai_apis/apis/prowritingaid/info.json index 973bbfed..826804f7 100644 --- a/edenai_apis/apis/prowritingaid/info.json +++ b/edenai_apis/apis/prowritingaid/info.json @@ -7,7 +7,7 @@ "fr" ] }, - "version": "v1.0" + "version": "v2" } } } \ No newline at end of file diff --git a/edenai_apis/apis/prowritingaid/outputs/text/spell_check_output.json b/edenai_apis/apis/prowritingaid/outputs/text/spell_check_output.json index 6ad1d24b..78c7b983 100644 --- a/edenai_apis/apis/prowritingaid/outputs/text/spell_check_output.json +++ b/edenai_apis/apis/prowritingaid/outputs/text/spell_check_output.json @@ -8,10 +8,10 @@ "categoryDisplayName": "Grammar (spelling)", "color": 1, "endPos": 10, - "helpArticleId": 1000042, - "helpId": "SIMPLE_SPELLING", + "helpArticleId": 1008127, + "helpId": "SSNE_6494BEF6CD7959A1EC50B930066AE3EA", "hint": "Unknown word: wrld", - "id": "c228bf39-6495-437a-b83e-e6f7e0ea0b3c", + "id": "c9e5265b-f090-43de-bfe5-a911987324f9", "invisible": false, "isSubTag": false, "realtimeCategory": "Spelling", @@ -22,13 +22,15 @@ "startPos": 7, "subcategory": "wrld", "suggestions": [ - "world", + "WRLD", "wild", - "WRLD" + "weld" ], "suggestionsDiffs": null, "urls": null, - "hashId": "3644128978907544576" + "allowsOverlaps": false, + "hashId": "-5233648282546357248", + "premiumState": 0 }, { "category": "grammarspelling", @@ -38,7 +40,7 @@ "helpArticleId": 1000042, "helpId": "SIMPLE_SPELLING", "hint": "Unknown word: yu", - "id": "b7c5c8b5-f31e-4eb2-b49e-d6b1229c477c", + "id": "51cd7693-f22d-40c0-9b32-989045c1501f", "invisible": false, "isSubTag": false, "realtimeCategory": "Spelling", @@ -50,11 +52,16 @@ "subcategory": "yu", "suggestions": [ "you", - "YU" + "ye", + "ya", + "mu", + "nu" ], "suggestionsDiffs": null, "urls": null, - "hashId": "2733048643129150032" + "allowsOverlaps": false, + "hashId": "2733048643129150032", + "premiumState": 0 } ], "WordCount": 5, @@ -263,26 +270,6 @@ ], "Value": 0.0 }, - { - "StatType": "WordCount", - "StatTypeValue": 1, - "StatTypeString": "StyleGuideIssue", - "RealtimeTagsCategories": [], - "Values": [ - 0.0 - ], - "Value": 0.0 - }, - { - "StatType": "WordCount", - "StatTypeValue": 1, - "StatTypeString": "StyleGuideSet", - "RealtimeTagsCategories": [], - "Values": [ - 0.0 - ], - "Value": 0.0 - }, { "StatType": "WordCount", "StatTypeValue": 1, @@ -312,7 +299,7 @@ "SubItems": [ { "TagIds": [ - "c228bf39-6495-437a-b83e-e6f7e0ea0b3c" + "c9e5265b-f090-43de-bfe5-a911987324f9" ], "Text": "wrld (1)", "SuggestionCategory": "grammarspelling", @@ -321,7 +308,7 @@ }, { "TagIds": [ - "b7c5c8b5-f31e-4eb2-b49e-d6b1229c477c" + "51cd7693-f22d-40c0-9b32-989045c1501f" ], "Text": "yu (1)", "SuggestionCategory": "grammarspelling", @@ -346,7 +333,7 @@ "SubItems": [ { "TagIds": [ - "c228bf39-6495-437a-b83e-e6f7e0ea0b3c" + "c9e5265b-f090-43de-bfe5-a911987324f9" ], "Text": "wrld (1)", "SuggestionCategory": null, @@ -355,7 +342,7 @@ }, { "TagIds": [ - "b7c5c8b5-f31e-4eb2-b49e-d6b1229c477c" + "51cd7693-f22d-40c0-9b32-989045c1501f" ], "Text": "yu (1)", "SuggestionCategory": null, @@ -389,7 +376,7 @@ "length": 4, "suggestions": [ { - "suggestion": "world", + "suggestion": "WRLD", "score": null }, { @@ -397,7 +384,7 @@ "score": null }, { - "suggestion": "WRLD", + "suggestion": "weld", "score": null } ] @@ -413,7 +400,19 @@ "score": null }, { - "suggestion": "YU", + "suggestion": "ye", + "score": null + }, + { + "suggestion": "ya", + "score": null + }, + { + "suggestion": "mu", + "score": null + }, + { + "suggestion": "nu", "score": null } ] diff --git a/edenai_apis/apis/prowritingaid/prowritingaid_api.py b/edenai_apis/apis/prowritingaid/prowritingaid_api.py index db6a3fe2..5323db30 100644 --- a/edenai_apis/apis/prowritingaid/prowritingaid_api.py +++ b/edenai_apis/apis/prowritingaid/prowritingaid_api.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Dict, Sequence +from typing import Dict, Optional, Any, List import requests @@ -10,7 +10,8 @@ SuggestionItem, ) from edenai_apis.features.text.text_interface import TextInterface -from edenai_apis.loaders.loaders import load_provider, ProviderDataEnum +from edenai_apis.loaders.data_loader import ProviderDataEnum +from edenai_apis.loaders.loaders import load_provider from edenai_apis.utils.exception import ProviderException from edenai_apis.utils.types import ResponseType @@ -18,9 +19,11 @@ class ProWritingAidApi(ProviderInterface, TextInterface): provider_name = "prowritingaid" - def __init__(self, api_keys: Dict = {}): + def __init__(self, api_keys: Optional[Dict[str, Any]] = None): api_settings = load_provider( - ProviderDataEnum.KEY, provider_name=self.provider_name, api_keys=api_keys + ProviderDataEnum.KEY, + provider_name=self.provider_name, + api_keys=api_keys or {}, ) self.api_key = api_settings["api_key"] self.api_url = "https://cloud.prowritingaid.com/analysis/api/async" @@ -62,9 +65,9 @@ def text__spell_check( code=response.status_code, ) - items: Sequence[SpellCheckItem] = [] + items: List[SpellCheckItem] = [] for tag in (original_response.get("Result", {}) or {}).get("Tags", []) or []: - suggestions: Sequence[SuggestionItem] = [] + suggestions: List[SuggestionItem] = [] for suggestion in tag["suggestions"]: suggestions.append(SuggestionItem(suggestion=suggestion, score=None)) items.append(