{"id":29877663,"url":"https://github.com/hawmex/aut_es_project","last_synced_at":"2025-09-04T09:44:21.930Z","repository":{"id":305392119,"uuid":"1022761076","full_name":"Hawmex/aut_es_project","owner":"Hawmex","description":"This repository contains the files of my project for the \"Expert Systems\" course at AUT (Tehran Polytechnic).","archived":false,"fork":false,"pushed_at":"2025-07-29T14:01:46.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-29T15:48:06.812Z","etag":null,"topics":["expert-system","movie-recommedation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hawmex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-19T19:08:35.000Z","updated_at":"2025-07-29T14:01:50.000Z","dependencies_parsed_at":"2025-07-19T22:31:06.067Z","dependency_job_id":"667e3d18-3e63-499c-9a45-a118a2d70566","html_url":"https://github.com/Hawmex/aut_es_project","commit_stats":null,"previous_names":["hawmex/aut_es_project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Hawmex/aut_es_project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hawmex%2Faut_es_project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hawmex%2Faut_es_project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hawmex%2Faut_es_project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hawmex%2Faut_es_project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hawmex","download_url":"https://codeload.github.com/Hawmex/aut_es_project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hawmex%2Faut_es_project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267989125,"owners_count":24177020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expert-system","movie-recommedation"],"created_at":"2025-07-31T05:11:55.898Z","updated_at":"2025-07-31T05:11:59.519Z","avatar_url":"https://github.com/Hawmex.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Expert Systems\n\nThis repository contains the files of my project for the \"Expert Systems\" course at AUT (Tehran Polytechnic).\n\n## Project: Movie Recommendation\n\nThis project implements a movie recommendation system using an expert system approach. It leverages a rule-based inference engine to recommend movies from The Movie Database (TMDb) API based on user preferences such as mood, favorite genre, movie vibe, era, duration, and rating.\n\n### Project Structure\n\n- **`app.py`**: The main entry point of the application. It integrates the inference engine with the TMDb API to fetch and display movie recommendations based on the inferred query.\n- **`rulebase.py`**: Defines the rulebase with a set of rules combining user inputs (e.g., mood, genre, vibe, era, duration, rating) to generate movie search queries.\n- **`core/inference_engine.py`**: Implements the inference engine, which processes the rulebase and interactively collects user inputs to infer a movie query.\n- **`core/rulebase/dependency.py`**: Defines the `Dependency` class for managing dependencies and priorities of input variables.\n- **`core/rulebase/expression.py`**: Contains classes for expressions (`Assignment` and `Evaluation`) used in rule conditions and actions.\n- **`core/rulebase/logical_operator.py`**: Implements logical operators (`LogicalAnd` and `LogicalOr`) for combining expressions in rules.\n- **`core/rulebase/rule.py`**: Defines the `Rule` class, which combines antecedents (conditions) and consequents (actions) for the inference process.\n- **`core/rulebase/rulebase.py`**: Defines the `Rulebase` class, which manages the collection of rules and their input/output dependencies.\n- **`core/rulebase/types.py`**: Contains type definitions for the state and dependencies used across the system.\n- **`core/rulebase/statement.py`**: Defines the abstract `Statement` class, which is the base for expressions and logical operators.\n\n### How It Works\n\n1. **User Interaction**:\n\n   - The system prompts the user to answer questions about their preferences (e.g., mood, favorite genre, movie vibe, era, duration, rating).\n   - Users can skip questions by pressing Enter, allowing flexibility in input.\n\n2. **Inference Engine**:\n\n   - The `InferenceEngine` class evaluates rules from `rulebase.py` based on user inputs.\n   - It prioritizes rules by the importance of their dependencies and collects missing inputs interactively.\n   - The engine infers a query by matching user inputs against rule conditions and applying the corresponding actions.\n\n3. **Query Refinement**:\n\n   - The inferred query is refined in `app.py` by mapping user-friendly terms (e.g., genre names, keywords) to TMDb API-compatible values (e.g., genre IDs, keyword IDs).\n   - The system uses the TMDb API to fetch movie data based on the refined query.\n\n4. **Output**:\n   - The recommended movies are displayed in a formatted table, including title, release date, vote average, and vote count.\n\n### Key Features\n\n- **Rule-Based System**: 28 predefined rules in `rulebase.py` cover various combinations of user mood, genre, vibe, era, duration, and rating preferences.\n- **Dynamic Query Generation**: The system dynamically constructs API queries based on user inputs and rule outcomes.\n- **TMDb API Integration**: Fetches real-time movie data using the TMDb API, requiring an API token stored in a `.env` file.\n- **Flexible Input Handling**: Users can skip questions, and the system adapts by evaluating only applicable rules.\n- **Extensible Design**: The modular structure allows easy addition of new rules or modifications to existing ones.\n\n### Setup and Installation\n\n1. **Prerequisites**:\n\n   - Python 3.8+\n   - A TMDb API token (obtain from [TMDb](https://www.themoviedb.org/))\n\n2. **Installation**:\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. **Configuration**:\n\n   - Create a `.env` file in the project root with your TMDb API token:\n     ```plaintext\n     TMDB_TOKEN=your_api_token_here\n     ```\n\n4. **Running the Application**:\n   ```bash\n   python app.py\n   ```\n\n### Usage\n\n- Run `app.py` to start the interactive prompt.\n- Answer questions about your movie preferences (e.g., \"What is your mood?\" or \"What is your favorite genre?\").\n- Press Enter to skip any question.\n- The system will infer a query, display it, and fetch movie recommendations from TMDb.\n- View the recommended movies in a table format.\n\n### Example Rules\n\n- **Happy + Comedy**: Recommends feel-good comedies with a minimum vote average of 6.5.\n- **Sad + Cathartic**: Suggests high-quality emotional dramas sorted by vote average.\n- **Adventurous + Epic Journey**: Finds quest-based adventure or fantasy films with a minimum vote average of 7.0.\n- **Modern Classic + Drama/Crime**: Recommends highly rated drama or crime films from 2000–2015.\n\n### Limitations\n\n- Requires a valid TMDb API token.\n- Limited to the predefined rules in `rulebase.py`.\n- Internet connection required for API calls.\n- Skipped questions may result in fewer or no recommendations if insufficient information is provided.\n\n### Future Improvements\n\n- Add support for more complex rule combinations or user-defined rules.\n- Implement caching for API responses to reduce redundant calls.\n- Enhance the user interface (e.g., GUI or web-based frontend).\n- Expand rulebase to include more genres, vibes, or other criteria like specific actors or directors.\n\n### Acknowledgments\n\n- The Movie Database (TMDb) for providing the movie data API.\n- AUT (Tehran Polytechnic) for the \"Expert Systems\" course inspiration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhawmex%2Faut_es_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhawmex%2Faut_es_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhawmex%2Faut_es_project/lists"}