Documentation

main.py

main.cronUpdate()[source]

Google Cloud Platform scheduled CRON request handler. Checks for changes to MDining API data (Location/Meal), sends notification to Slack channel if change detected. Ignores changes to specified terms in ignore.json file. Authenticates requests by checking for user and passw in POST request body.

main.findLocationAndMeal(req_data)[source]

Dialogflow findLocationAndMeal intent handler. Checks for valid Location and Meal and sends HTTP response with appropriate data.

Parameters:req_data (JSON) – Dialogflow POST request data
main.home()[source]

Web app home page for quick successful deployment check.

main.isPartialTerm(search, filename)[source]

Checks if input term is part of a larger official term by looking for any matches with split up versions of regular terms.

Parameters:
  • search (string) – The searched term (e.g. ‘north quad’)
  • filename (string) – Name of the file the term is being searched for in (‘LocationExtra.txt’)
main.similarSearch(search, category)[source]

Handles user input that doesn’t match official terms exactly using isPartialTerm. If input search is a partial term of any official terms, returns list of recommended official terms.

Parameters:
  • search (string) – The searched term (e.g. ‘north quad’)
  • category – Entity category of the search term (‘Location’/’Meal’)
main.webhookPost()[source]

Dialogflow webhook POST Request handler requiring authentication. Uses findLocationAndMeal or findItem intent handlers and returns appropriate JSON response.

datahandle.py

datahandle.checkCourseAvailable(data, course)[source]

Searches response data to check if course is available in specified meal.

Parameters:
  • data (JSON) – MDining API HTTP response data
  • course (string) – Name of course
datahandle.checkMealAvailable(data, meal)[source]

Searches response data to check if meal is available at specified location/date.

Parameters:
  • data (JSON) – MDining API HTTP response data
  • meal (string) – Name of meal
datahandle.findItemFormatting(possiblematches)[source]

Formatting list of possible matches into more natural sentence structure by removing redundancy: [Chicken during lunch, chicken wings during lunch, and chicken patty during dinner] -> [Chicken, chicken wings during lunch, and chicken patty during dinner]

Parameters:possiblematches (list) – List of food items in data that matched user input
datahandle.findMatches(coursedata, possiblematches, item_in, mealname)[source]

Appends matches of specified food item in data of an individual course to list of possible matches.

Parameters:
  • coursedata (JSON) – Chosen course subsection of MDining API HTTP response data
  • possiblematches (list) – List of food items in data that matched user input
  • item_in (string) – User input food item
  • mealname (string) – Name of meal
datahandle.getCoursesAndItems(data)[source]

Returns string of courses and food items of each course in response data for fulfillmentText in response to Dialogflow.

Parameters:data (JSON) – MDining API HTTP response data
datahandle.getItemsInCourse(coursedata, course)[source]

Returns string of food items of specified valid course in response data for fulfillmentText in response to Dialogflow.

Parameters:
  • coursedata (JSON) – Chosen course subsection of MDining API HTTP response data
  • course (string) – Name of course
datahandle.removeSpaces(url_block)[source]

Removes spaces in url string to create valid url string.

Parameters:url_block – The url string to be manipulated
datahandle.requestItem(date_in, loc_in, meal_in, item_in)[source]

Handles searching for appropriate data response for valid specified location and food item entities (and meal entity if included) from findItem intent.

Parameters:
  • date_in (string) – Input date
  • loc_in (string) – Input location
  • meal_in (string) – Input meal
  • item_in (string) – Input food item
datahandle.requestLocationAndMeal(date_in, loc_in, meal_in)[source]

Handles searching for appropriate data response for valid specified location and meal entities from findLocationAndMeal intent.

Parameters:
  • date_in (string) – Input date
  • loc_in (string) – Input location
  • meal_in (string) – Input meal

remove_ignore_entities.py

remove_ignore_entities.removeIgnoreEntities(data, category)[source]

Removes entity terms to be ignored found in ignore.json when comparing current local data and potentially updated MDining API data.

Parameters:
  • data (list) – List of items in current version of specified entity
  • category (string) – Entity category of the search term (‘Location’/’Meal’)