Today we’ll talk about how does Siri Answers our query and from where does Siri gets all the information.
Well Siri uses Many API’s like Google, Yahoo!, Wikipedia and others to get all the information it has and its not possible to cover all the API’s siri uses in a single blog post.
Hence today we’ll learn an interesting API (I think so) known as WolfRam | Alpha API which was utilized quite a times when I asked Siri to look for something.
- Calculations, Mathematics
- Checking Weather, Route
- Current Time in a City
When you ask a question to Siri, it feeds your query to an API and provides you the information on basis of data returned from API call. Like in the below screenshot Siri fullfiled my query using WolfRam | Alpha API, as you can see there is a small icon in Right bottom corner of the Second screenshot.
I thought of giving this API a try with PowerShell and see if we can make a Pseudo Search Engine ( Kinda! 😉 ) in PowerShell.
HOW IT WORKS :
Making this API fetch data like Siri is a Five step process :
- Start code Execution : Call the first function of the code in order to start execution of code
- Create the Windows form : The function called in the previous step Generate a Windows form so that user feed in his query
- Create a Listener to listen Search now Events : Wait until User feeds his query in TextBox and either hit ENTER or Click the Search Button.
- Call the WolfRam|Alpha API : Once the Event mentioned in previous step is triggered call the Wolfram|Alpha API with the user Query, which will return some information based upon the Query.
- Display Output : Once information is retrieved from the API, Structure the information like the way Siri presents it on IPhones. Then Display it in the same Windows Form.Below is the structure of my code, for the better understanding how it works.
NOTE : Please note that in order understand how it works and the Terms and Attributes I used in my code, I’ll advise you to go through the API documentation Here.
And navigate Here to know the Structure of data API Call returns in a Pictorial representation.
GET THE SCRIPT :
Click Here to go to my GitHub gist to get the complete script.
HOW TO USE IT :
Run the Script and Type in your query in the TextBox then Hit Enter or click on Search Button, script will do the rest for you, just like a Search Engine in the below animation.
Hoping you’ll find this fun.
Happy Reading 🙂