{"id":24388185,"url":"https://github.com/lfmramos/tool-word-histogram-generator","last_synced_at":"2026-05-23T08:03:01.197Z","repository":{"id":261937708,"uuid":"885771536","full_name":"lfmramos/tool-word-histogram-generator","owner":"lfmramos","description":"This Java project creates a word histogram using inheritance and composition, analyzing text strings to generate word frequency counts while showcasing OOP and design patterns.","archived":false,"fork":false,"pushed_at":"2024-11-09T11:06:55.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T20:12:13.010Z","etag":null,"topics":["composition","histogram","inheritence","java"],"latest_commit_sha":null,"homepage":"","language":"Java","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/lfmramos.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}},"created_at":"2024-11-09T11:02:22.000Z","updated_at":"2024-11-13T09:17:41.000Z","dependencies_parsed_at":"2024-11-09T12:18:34.891Z","dependency_job_id":"2b0c50d0-bf6a-455c-b312-9b8945ef133f","html_url":"https://github.com/lfmramos/tool-word-histogram-generator","commit_stats":null,"previous_names":["lfmramos/tool-word-histogram-generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lfmramos/tool-word-histogram-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfmramos%2Ftool-word-histogram-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfmramos%2Ftool-word-histogram-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfmramos%2Ftool-word-histogram-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfmramos%2Ftool-word-histogram-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lfmramos","download_url":"https://codeload.github.com/lfmramos/tool-word-histogram-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfmramos%2Ftool-word-histogram-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33387657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["composition","histogram","inheritence","java"],"created_at":"2025-01-19T13:56:36.680Z","updated_at":"2026-05-23T08:03:01.155Z","avatar_url":"https://github.com/lfmramos.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Word Histogram Generator\n\nA Java implementation demonstrating two different approaches to creating a word histogram: inheritance and composition. This project analyzes text strings and generates frequency counts of words, showcasing Object-Oriented Programming principles and different design patterns.\n\n## Features\n\n- Count word frequencies in a given text string\n- Two implementation approaches:\n  - Composition-based (`WordHistogramComp`)\n  - Inheritance-based (`WordHistogramInheritance`)\n- Iterable interface implementation for easy word traversal\n- Memory-efficient storage using HashMap\n\n## Implementation Details\n\n### Composition vs Inheritance\n\nThe project implements the same functionality using two different approaches to demonstrate their pros and cons:\n\n#### Composition (`WordHistogramComp`)\n- Uses a `HashMap` as an internal data structure\n- Implements `Iterable\u003cString\u003e`\n- Provides controlled access to the underlying map\n- Better encapsulation and flexibility\n- Follows \"favor composition over inheritance\" principle\n\n#### Inheritance (`WordHistogramInheritance`)\n- Extends `HashMap\u003cString, Integer\u003e`\n- Implements `Iterable\u003cString\u003e`\n- Direct access to all HashMap methods\n- More concise implementation but less flexible\n\n## Usage\n\n### Basic Usage\n\n```java\n// Using Composition\nWordHistogramComp histogramComp = new WordHistogramComp(\"your text here\");\nSystem.out.println(\"Distinct words: \" + histogramComp.size());\n\n// Using Inheritance\nWordHistogramInheritance histogramInher = new WordHistogramInheritance(\"your text here\");\nSystem.out.println(\"Distinct words: \" + histogramInher.size());\n\n// Iterate through words and their frequencies\nfor (String word : histogramComp) {\n    System.out.println(word + \" : \" + histogramComp.get(word));\n}\n```\n\n### Example Output\nFor the input string \"test word words test 1 10 1\":\n```\nMAP has 6 distinct words\ntest : 2\nword : 1\nwords : 1\n1 : 2\n10 : 1\n```\n\n## Technical Details\n\n### Key Methods\n\nBoth implementations provide:\n- `size()`: Returns the number of distinct words\n- `get(String word)`: Returns the frequency of a specific word\n- `iterator()`: Allows iteration over all words\n\n### Data Structure\n\n- Uses `HashMap` for O(1) access time\n- Space complexity: O(n) where n is the number of unique words\n- Time complexity: \n  - Word counting: O(n)\n  - Word frequency lookup: O(1)\n\n## Design Considerations\n\n### Composition Advantages\n1. Better encapsulation\n2. More flexible for future modifications\n3. Controlled interface exposure\n4. Easier to maintain\n\n### Inheritance Advantages\n1. Less code duplication\n2. Direct access to HashMap methods\n3. Simpler implementation\n\n## Getting Started\n\n### Prerequisites\n- Java Development Kit (JDK) 8 or higher\n- Java IDE (recommended: IntelliJ IDEA or Eclipse)\n\n### Running the Project\n\n1. Compile the Java files:\n```bash\njavac io/codeforall/fanstatics/*.java\n```\n\n2. Run the main class:\n```bash\njava io.codeforall.fanstatics.Main\n```\n\n## Future Enhancements\n\nPotential improvements could include:\n1. Case-insensitive word counting\n2. Punctuation handling\n3. Support for file input\n4. Statistical analysis features\n5. Performance optimizations for large texts\n\n## Contributing\n\nFeel free to submit issues and enhancement requests!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfmramos%2Ftool-word-histogram-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flfmramos%2Ftool-word-histogram-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfmramos%2Ftool-word-histogram-generator/lists"}