And this video, you learn how to perform grammar checking with Python.
And we're going to do this using an API called Language Tool API, so we're going to be sending requests
to Vets Rest API in the request.
We will send the text we want to check for grammar and we will return the corrected text back.
This will work through a post through requests, not a gets requests, as we have done so far.
So we've get requests.
You just get some ready made dots on there, but with post requests, you send some data.
In this case, we're going to send some text there and the server will process that.
So this time in this post request scenario, the server has to process our data and do calculations
and then return those data to our clients to our program.
The tool will be using, though again, requests so important quests and then create a response object
requests that post this time not gets.
Previously, we used gets no use post and the URL is the first argument.
So you URL is this will be the URL of this API.
So if you go to a language tool dot org slash HTP Dash API and then you go to default in here, so you're
going to see these.
If you press here, check a text.
You're going to see the parameters I'll return in just a while.
What these parameters mean, but the routes you earl is.
HTP as.
Colin Slash slash API dot language tool.
Dot org.
That's a v two slash v to slash check.
So that's where L is going to go in here, but then we have to pass parameters here.
Unlike in the gets requests here, you have to parse dots all you want to process.
So see here what data we can pass.
We can pass text, for example.
This is the text that we need to send for grammar checking.
All you can pass it as Jason, not as a string.
So in that case, you would pass a delta arguments and then you have language, which is a required
argument and all of the parameters as well.
What language is the only required arguments and also texts if you want to check some actual text?
So how do we give these parameters?
Well, we give them through a dictionary.
So first we creates a dictionary, let's say delta, or use just any valuable you like that would be
equal to this dictionary.
And then here you pass keys.
So text, for example, of this key as to reflects one of the parameters in here.
So text and then you parse the text you want to check.
Let's write something grammatically wrong by purpose.
So let's say this is a nice day.
So I wanted to say this is a nice date, but I did want typo in here and one typo in here.
Mm.
So that's the text key and then a comma, and then you pass more parameters.
Language is a required arguments and it will be equal to.
Well, you can press and but you can also say Alter so that you can get the checking, even if this
is another language for any language that this API supports.
And then once you have defined your dictionary there, then in here you provide data.
That's how it's a parameter of the post requests and that is equal to this variable delta.
So data is equal to delta and then print responds the text and run.
And that's the output.
Let's check the type of this output using a type function.
So wrap that expression inside the type and run and you'll see this is a string.
So first of all, we want to convert this into a dictionary.
Therefore, I'm going to import Jason.
And then what I'll do here is, I'll say results is equal to response dot text, but that will go inside
Jason.
That loads.
So JSON that loads converts a string into a dictionary so that we are able to parse that dictionary
we can.
Extracted items of the dictionary, and we cannot do that if the format is a string because a string
is made of characters and the dictionary is recognized by Python as a more compound, other type which
has items and which are made of keys and values.
So Ron, this oh, let me print out results.
So we've got the same outputs as before, but now this will be a dictionary if I check the type of that.
So it's addiction it.
And I'd like to stop here.
So that is a final output for this video.
No, you know how to parse dictionaries, so how to extract Delta from a dictionary?
Using the dictionary keys.
So depending on the application that you want to make, which contains grammar correction functionality,
you might want to extract different values from the dictionary, so you may extract the suggestion of
the correct word.
And in this dictionary, you also have the information where that word is located in the text.
So you can extract the index of the word that is wrong.
Maybe you create a web and then you show this information as popups on the app.
So I'd like to close this video here and to leave you with this dictionary.
So I'll thank you for following this and I'll see you later.