Want to grab a bite during an outing with your dog? Fetch helps you choose from 300+ dog-friendly restaurants in 30+ cities. Natural language processing extracts content from reviews in Yelp's Challenge Database regarding restaurants' dog-friendliness and food quality. Then, scores from 0 (negative) to 5 (positive) are computed based on the sentiment for each category. Dynamic visualizations allow users to seamlessly compare individual restaurants, cities, and states. Restaurants are displayed on an interactive map using the Google Maps and Yelp APIs.
- Back-end: Python, Flask
- Front-end: JavaScript, jQuery, AJAX, Jinja2, D3.js, Bootstrap, HTML5, CSS3
- Libraries: NLTK, TextBlob
- Database: Flask-SQLAlchemy, PostgreSQL
- APIs: Google Maps, Yelp
Dependencies are listed in requirements.txt.
The Yelp Challenge Dataset contains 2.2 million full-length reviews for 77,000 businesses. From this dataset, I was able to extract a list of 300+ dog-friendly restaurants from 30+ cities and their respective reviews (46,000+ total). Then, Yelp API calls were used to gather additional restaurant information.
As a dog-lover who lives in San Francisco, I was disappointed to see that San Francisco was included in Yelp's Challenge Dataset so I hardcoded a list of its dog-friendly restaurants in restaurants.txt. As with the Dataset restaurants, Yelp API calls were used to get more information about San Francisco restaurants.
I generate two different scores for each restaurant to provide information regarding its dog-friendliness and food quality. Because reviews can describe different characteristics, each sentence in a restaurant's reviews is classified as dog-friendliness, food quality, or disregarded as neiher.
This is done using the Naive Bayes Classifier in the Textblob wrapper for the Natural Language Toolkit (NLTK) library. Prior to classifying each sentence, the classifier was trained following the 80:20 rule of thumb split. Based on the test set, the classifier was 75% accurate.
After each sentence is classified as describing dog-friendliness or food quality, a list of each category is generated per restaurant.
The Textblob wrapper includes a sentiment analyzer that was pre-trained on movie ratings. After two lists of sentences are generated per restaurant, sentiment analysis is performed on each sentence and then an average score for each category is computed for each restaurant.
Upon succesful registration, the user is redirected to the homepage.
The user can view all the restaurants he/she has favorited or reviewed on the profile page.
If the browser is allowed to access the user's location, the user can center the map on the user's current location.
The user can then hover over a marker to see that restaurant's name. If the user clicks on the marker, an AJAX request is sent to the Google Maps API to generate an info window and its data is retrieved from the PostgreSQL database via another AJAX request.
Once a restaurant's info window is open, the user can submit a rating and review, which are stored in the PostgreSQL database.
The user can also favorite or unfavorite a restaurant, which will update the database through an AJAX request.
The user can select a city (separated by state/province) in the dropdown menu. Then AJAX requests are made to 1) the Google Maps API's Geocoding service to recenter the map on that location and 2) the PostgreSQL database to populate Fetch's top 5 recommended restaurants in that city based on sentiment analysis scores.
On the initial analysis page, the average scores for restaurants in certain US states and Canadian provinces are displayed with a histogram and pie chart using the D3.js library. The user can hover over the restaurant and see which percentage of the total score each category makes up. Alternatively, the user can hover over a pie slice (dog-friendliness or food quality) and see only that individual score in the histogram.
If the user wants more information, he/she can click on a bar in the histogram to see similar information for the cities in that state/province. Then, the city bar can be clicked to see the scores for restaurants in that city. Clicking on a restaurant will redirect the user to the homepage, where the Google map will automatically recenter on the appropriate restaurant.
- Write more tests
- Train Textblob's sentiment analyzer with restaurant reviews instead of movie reviews
- Train/test enough data to add another category (i.e., service, ambiance, etc)
- Encrypt passwords in database OR implement OAuth 2.0
- Make mobile app version
- Incorporate Twilio API to text user when user is walking near a dog-friendly restaurant
Florence Loi (LinkedIn) is a software engineer in San Francisco, CA. She lives with her partner along with their dog Zorro (her inspiration for this project!), and two cats.









