Wiki Process Flow
Getting Results from Wikipedia
Transformed Text is passed to wikiSearch flow to get the Summary from Wikipedia. By default Aryan gets 2 sentences from Wikipedia for the given Human query.
If Human explicitly mentions to get details about a particular topic, then Aryan gets 5 sentences from Wikipedia, This is achieved by passing a detailFlag as "Y" by the Speech Action flow which invokes Wikipedia flow.
Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia.
Search Wikipedia, get article summaries, get data like links and images from a page, and more. Wikipedia wraps the MediaWiki API so you can focus on using Wikipedia data, not getting it.
Cleaning the Wikipedia Output
Once Aryan gets output from Wikipedia, Next step is to Clean the Wiki Result, Regular Expressions are used to parse the wiki data and clean it to make it usable for speaking and readability by Aryan. cleanWikiResult flow takes care of it
Below is an example of usage of the Regular Expressions to clean the output response of "Can you tell me about Queen Victoria?"
Wiki Raw Output:
Victoria (Alexandrina Victoria; 24 May 1819 – 22 January 1901) was Queen of the United Kingdom of Great Britain and Ireland from 20 June 1837 until her death in 1901. Known as the Victorian era, her reign of 63 years and seven months was longer than any previous British monarch.
Wiki Cleaned Output:
Victoria was Queen of the United Kingdom of Great Britain and Ireland from 20 June 1837 until her death in 1901. Known as the Victorian era, her reign of 63 years and seven months was longer than any previous British monarch.
Do you want to Know more?
By default, Aryan fetches 2 sentences from Wikipedia for the given query, Thus in this flow Aryan asks Human if they want to know more? wikiMoreDetailsCheck flow is executed to fulfill this task,
It starts by asking the Human "Do you want to know more?",
In case Human says "yes", getMoreDetailsWiki flow is executed to fetch more information, i.e. 3 more sentences.
If Human says "no", Aryan triggers the NextStep flow to proceed with further execution.
In case of no response the Aryan worker thread exits and Aryan goes back to sleeping mode.
Get More Information from Wikipedia
In case the user wants to know more about a particular query then getMoreDetailsWiki flow is executed to get additional 3 sentences it is achieved by getting total 5 sentences and thereafter removing the sentences which is already communicated to our Human friend
Wikipedia Disambiguation Error
In case for a user query, Aryan get's more then one topics from Wikipedia then disambiguation Error occurs, mentioning user to be more specific in their search as several options are present and flow fall backs to starting point of worker thread.
Wikipedia Exception Handling
Besides this, if for any topic Aryan is unable to get the response from Wiki, then Human is politely mentioned "Sorry could not get it" and Flow fall backs to starting point of worker thread.
Last updated
Was this helpful?