BookGoogle is a website aimed at making it easier for its users to decide on what book to read.
It provides its user with the following functionality:
- Searching books by title.
- Showing the rating and other characteristics of books.
- Providing the most useful reviews for the book.
The usefulness is determined by the analysis of the reviews and calculating the amount of emotionally neutral vocabulary.
Table of Contents
The following technologies were used to develop the system:
- Python 3.9
- HTML, CSS
The backend of the website takes advantage of the following cloud services:
- GoodReads API - for retrieving text book reviews from GoodReads website.
- YouTube Data API v3 - for retrieving links to video book reviews.
The backend also makes use of the following non-standard Python libraries:
- nltk - natural language toolkit.
- langdetect - language-detection library.
- flask - micro web framework.
- requests - convenient library for sending HTTP requests.
- dask - library for parallel computing.
The approximate description of the client-server communication is as follows:
- The server receives the title of the book from the client.
- The server gets information about the book with the most similar title using GoodReads API.
- The server retrieves the reviews of the book using GoodReads API.
- The server determines the language of each retrieved review using langdetect library.
- The server measures the neutrality of each English review using nltk library.
- The server selects the reviews with the most emotionally neutral vocabulary.
- The server retrieves the link to the video review of the book using YouTube Data API v3.
- The server sends the response to the client's request. The response contains the information about the book, most useful reviews and the link to the video book review on YouTube.
The following is a tree representing the project structure with all the important files:
└───root directory
├───app.py - main file of the web aplication linking all routes to python code
│ ├───index() function - provides "/" endpoint for main page
│ └───show_book_info_page() function - provides "/book_info" endpoint for receiving page with info about boook
├───review_classes.py - provides the implementation of ReviewList ADT
│ ├───class Review
│ └───class ReviewList
├───review_parser.py - provides functions for retrieving book reviews by scraping GoodReads, utilizes ReviewList ADT
│ ├───scrape_reviews() function - return reviews of the book given its ISBN
│ ... - some other helper methods
├───goodreads_search.py - provides book search
│ ├───search_book() function - return info about books found
│ ├───get_book_isbn() helper function - return ISBN of the book given its GoodReads ID
│ └───element_to_dict() helper function - converts xml.etree.ElementTree.Element to the dictionary of dictionaries
├───youtube_search.py
│ ├───get_video_ids() function - return list of IDs of YouTube videos from search query.
│ ├───get_video_info() function - return information on the video given its ID.
├───test_review_classes.py - module for testing class Review and class ReviewList.
│ └───class TestReviews
├───static
│ └───styles - a folder with css styles
│ ...
└───templates - HTML templates
├───book.html
├───index.html
└───layout.html
Class ReviewList is a container for instances of Review class.
Class Review represents a review with associated text, rating, name of author and calculated level of neutrality. The instances of Review can be compared (<, => etc.) with each other. The following methods are implemented in Review:
- __init__(self, info_tuple) - creates instance of Review from passed in tuple containing the name of the author, the rating and the text of the review.
- calc_neutrality(self) - calculate and return the level of neutrality of the review.
- __lt__(self, other) - compare two reviews. If the ratings are equal, the one with the greater level of neutrality is greater. We suppose that greater neutrality corresponds to the greater reliability.
- __repr__(self) - return text represetation of the review.
Class ReviewList is an implemantation of the ReviewList ADT. It is designed to contain and sort by reliability the instances of Review. The class has the following methods:
- __init__(self) - create ReviewList
- __repr__(self) - return text representation of ReviewList
- clear(self) - clears itself and returns all of the data
- add_review(self, review) - add Review object to ReviewList
- reliability_sort() - sort the interal list of reviews
- get_mood_range(self, mood_lst) - return the most reliable (with the most emotionally neutral vocabulary) reviews that have ratings from mood_lst.
Class TestReviews in test_review_classes.py is a unittest testcase. It is designed to test class Review and class ReviewList from review_classes.py. The TestReviews class has the following methods:
- setUp(self) - create isntances of Review for futher testing in each test example.
- test_correct_review(self) - test the correctness of attributes of reviews.
- test_reviews_compare(self) - test the order of the instances of Review (>, <= etc.).
- test_add_review_list(self) - test adding reviews to the instance of ReviewList.
- test_review_list_sorting1(self) - test extracting the most neutral reviews from ReviewList.
- test_review_list_sorting2(self) - test extracting the most neutral reviews from ReviewList.
- test_review_list_sorting3(self) - test extracting the most neutral reviews from ReviewList.
- Enter the title of the book and press Enter.
- Wait till the server gives a response with some information about the book.
- After some time the website will also display the reviews of the book.
Alternatively, you can run the website on the local computer (Python 3.9 is supported):
- Clone this repository with
$ git clone https://github.com/UstymHanyk/BookGoogle.git
- Install the needed dependecies with
$ pip install -r requirements.txt
- Replace the missing API keys in project files with your own GoodReads API key and Youtube API key.
- To run the server locally, type the following commands in your terminal:
$ export FLASK_APP=app.py
$ python -m flask run
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
The project was developed as a group home assignment within the course "Basics of programming" at UCU by the following people:
Ustym Hanyk 💻 |
Nadiia Zaiachkovska 💻 |
Bohdan Mahometa 💻 |
Dmytro Komarynskyi 💻 |
Daryna Cheban 💻 |
Every other developer is welcome to contribute to this project too (see Contributing).