Skip to content

Commit

Permalink
[Fix] update api prowritingaid
Browse files Browse the repository at this point in the history
  • Loading branch information
coscialp committed Dec 1, 2023
1 parent 317b428 commit 67842ee
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion edenai_apis/apis/prowritingaid/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"fr"
]
},
"version": "v1.0"
"version": "v2"
}
}
}
71 changes: 35 additions & 36 deletions edenai_apis/apis/prowritingaid/outputs/text/spell_check_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -312,7 +299,7 @@
"SubItems": [
{
"TagIds": [
"c228bf39-6495-437a-b83e-e6f7e0ea0b3c"
"c9e5265b-f090-43de-bfe5-a911987324f9"
],
"Text": "wrld (1)",
"SuggestionCategory": "grammarspelling",
Expand All @@ -321,7 +308,7 @@
},
{
"TagIds": [
"b7c5c8b5-f31e-4eb2-b49e-d6b1229c477c"
"51cd7693-f22d-40c0-9b32-989045c1501f"
],
"Text": "yu (1)",
"SuggestionCategory": "grammarspelling",
Expand All @@ -346,7 +333,7 @@
"SubItems": [
{
"TagIds": [
"c228bf39-6495-437a-b83e-e6f7e0ea0b3c"
"c9e5265b-f090-43de-bfe5-a911987324f9"
],
"Text": "wrld (1)",
"SuggestionCategory": null,
Expand All @@ -355,7 +342,7 @@
},
{
"TagIds": [
"b7c5c8b5-f31e-4eb2-b49e-d6b1229c477c"
"51cd7693-f22d-40c0-9b32-989045c1501f"
],
"Text": "yu (1)",
"SuggestionCategory": null,
Expand Down Expand Up @@ -389,15 +376,15 @@
"length": 4,
"suggestions": [
{
"suggestion": "world",
"suggestion": "WRLD",
"score": null
},
{
"suggestion": "wild",
"score": null
},
{
"suggestion": "WRLD",
"suggestion": "weld",
"score": null
}
]
Expand All @@ -413,7 +400,19 @@
"score": null
},
{
"suggestion": "YU",
"suggestion": "ye",
"score": null
},
{
"suggestion": "ya",
"score": null
},
{
"suggestion": "mu",
"score": null
},
{
"suggestion": "nu",
"score": null
}
]
Expand Down
15 changes: 9 additions & 6 deletions edenai_apis/apis/prowritingaid/prowritingaid_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Dict, Sequence
from typing import Dict, Optional, Any, List

import requests

Expand All @@ -10,17 +10,20 @@
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


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"
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 67842ee

Please sign in to comment.