gingerit icon indicating copy to clipboard operation
gingerit copied to clipboard

Long text strings cause a KeyError: 'Corrections'

Open Pikamander2 opened this issue 5 years ago • 6 comments

When passing GingerIt a 700+ character string, it throws KeyError: 'Corrections'.

from gingerit.gingerit import GingerIt

text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vitae felis sed felis convallis egestas vel ornare massa. Fusce vehicula odio at sem pharetra condimentum. Pellentesque mattis tincidunt bibendum. Integer ultrices odio lorem. Sed venenatis turpis a commodo malesuada. Nunc bibendum tincidunt sem in sodales. Suspendisse non ligula ac ligula venenatis imperdiet eu ut ex. Fusce aliquet, ligula et tristique dignissim, nisi lorem accumsan libero, in porttitor velit erat et tortor. Fusce at libero aliquam, porttitor ligula quis, pellentesque leo. Fusce vitae diam ac quam suscipit pharetra vel hendrerit nisi. Curabitur eu magna sit amet enim porta lacinia. In hac habitasse platea proin."

ginger_parser = GingerIt()

ginger_grammar_results = ginger_parser.parse(text)
Traceback (most recent call last):
  File "\grammar-checker-1.py", line 11, in <module>
    ginger_grammar_results = ginger_parser.parse(text)
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\gingerit\gingerit.py", line 27, in parse
    return self._process_data(text, data)
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\gingerit\gingerit.py", line 39, in _process_data
    for suggestion in reversed(data['Corrections']):
KeyError: 'Corrections'

Is this a bug? I'm assuming that it's an API limitation, but it doesn't seem to be documented anywhere.

Pikamander2 avatar May 26 '20 02:05 Pikamander2

I'm having the exact same problem with the latest version of GingerIt, with the exact same traceback

sohalsdr avatar Mar 04 '21 21:03 sohalsdr

Hi, I am getting same issue with 600+ characters. Anyone managed to resolve it on their end ?

Sid-Bisram avatar Apr 25 '21 12:04 Sid-Bisram

Hi, I am facing the same issue the same issue! Did anybody find a workaround?

Akshar-code avatar Apr 25 '21 16:04 Akshar-code

@Sidd-Amateur-Dvlper @Akshar-code - It's most likely just an undocumented API limitation. If that's the case, then you'll need to split your paragraphs apart into smaller ones and make multiple API calls.

Pikamander2 avatar Apr 25 '21 18:04 Pikamander2

@Sidd-Amateur-Dvlper @Akshar-code - It's most likely just an undocumented API limitation. If that's the case, then you'll need to split your paragraphs apart into smaller ones and make multiple API calls.

Thanks, thats the solution i went though. Rgds

Sid-Bisram avatar Apr 25 '21 19:04 Sid-Bisram

as mentioned earlier by @Pikamander2:

"it's most likely just an undocumented API limitation."

Even on their official website, it throws a limitation issue - limitation appears on both UI and API response.

  • https://www.gingersoftware.com/grammarcheck
screenshot A screenshot B
image image

igorlima avatar Jun 27 '21 15:06 igorlima