Skip to content

UstymHanyk/BookGoogle

Repository files navigation

BookGoogle

Description:

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:

  1. Searching books by title.
  2. Showing the rating and other characteristics of books.
  3. 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:

Table of Contents
  1. Description
  2. Table of Contents
  3. Implementation
  4. Usage
  5. Contributing
  6. Credits
  7. License

🔧 Implementation

Used technologies

The following technologies were used to develop the system:

  1. Python 3.9
  2. HTML, CSS

The backend of the website takes advantage of the following cloud services:

  1. GoodReads API - for retrieving text book reviews from GoodReads website.
  2. YouTube Data API v3 - for retrieving links to video book reviews.

The backend also makes use of the following non-standard Python libraries:

  1. nltk - natural language toolkit.
  2. langdetect - language-detection library.
  3. flask - micro web framework.
  4. requests - convenient library for sending HTTP requests.
  5. dask - library for parallel computing.

Algorithm

The approximate description of the client-server communication is as follows:

  1. The server receives the title of the book from the client.
  2. The server gets information about the book with the most similar title using GoodReads API.
  3. The server retrieves the reviews of the book using GoodReads API.
  4. The server determines the language of each retrieved review using langdetect library.
  5. The server measures the neutrality of each English review using nltk library.
  6. The server selects the reviews with the most emotionally neutral vocabulary.
  7. The server retrieves the link to the video review of the book using YouTube Data API v3.
  8. 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.

Project structure

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.

💻 Usage:

Our website

  1. Visit book-google-app.herokuapp.com/

  1. Enter the title of the book and press Enter.

  1. Wait till the server gives a response with some information about the book.

  1. After some time the website will also display the reviews of the book.

Running website locally

Alternatively, you can run the website on the local computer (Python 3.9 is supported):

  1. Clone this repository with
$ git clone https://github.com/UstymHanyk/BookGoogle.git
  1. Install the needed dependecies with
$ pip install -r requirements.txt
  1. Replace the missing API keys in project files with your own GoodReads API key and Youtube API key.
  2. To run the server locally, type the following commands in your terminal:
$ export FLASK_APP=app.py
$ python -m flask run

📝 Contributing:

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

👥 Credits:

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).

🔐 License:

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages