PowerShell : How SIRI answers your Query


Hello Readers,

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.

Examples.

  • 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 :

  1. Start code Execution : Call the first function of the code in order to start execution of code 
  2. Create the Windows form : The function called in the previous step Generate a Windows form so that user feed in his query
  3. 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.
  4. 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.
  5. 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.

1

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.

ezgif.com-gif-maker (4)

Hoping you’ll find this fun.
Happy Reading  🙂

Prateek Singh

Advertisements

5 thoughts on “PowerShell : How SIRI answers your Query

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s