This is a command-line menu-driven Java application that analyzes input text, calculates the word frequency, and generates a word cloud image of the most common words. It utilizes modular interfaces and multithreading to ensure flexibility and performance.
-
Word Cloud Workflow: The application uses five modular interfaces to create a word cloud step-by-step:
Sourceable: Loads the input text (from a file, URL, etc.).Parseable: Prepares the text by isolating words, removing symbols/abbreviations, and ignoring specified words.Mappable: Maps the frequency of each word.Rankable: Ranks words based on decreasing frequency.Drawable: Outputs the word cloud image as an image file.
-
Input Source Flexibility:
- Accepts input from
.htmlfiles,.txtfiles, and URLs (must includehttp/httpsprotocol). - Automatically appends missing file extensions to input filenames when required.
- Accepts input from
-
Multi-Threading Options:
- Unthreaded Mode: Processes word frequency mapping in a single thread.
- Set Thread Number: Allows the user to specify the number of threads for processing.
- Optimized Mode: Automatically determines the optimal number of threads based on the number of available processors.
-
Error Handling:
- Custom error messages for invalid inputs (e.g., out-of-range integers, invalid file names, empty entries).
- Verifies the existence of input sources before processing.
-
Output Features:
- Automatically names output images by concatenating input file name, filter name, and edge mode used.
- Ensures output images match the file type of the input source.
- Command-Line Menu:
- Main menu options for running the program, setting threading preferences, selecting input sources, and quitting.
- Sub-menus allow navigation between input source options, threading settings, and main menu.
- Program runs until a word cloud is generated or the user chooses to quit.
-
MenuClass:- Provides the interactive command-line interface for user input and settings management.
-
ThreadedMapByHashClass:- Extends the
MapByHashclass for concurrent execution of word frequency mapping usingRunnabletasks.
- Extends the
-
Input Source Processors:
SourceURL: Processes text input from a URL.SourceTxt: Processes text input from a.txtfile.
-
ENUMs for Constants:
- Stores predefined font types and colors for word cloud generation.
- Java Development Kit (JDK): Version 8 or above.
- Integrated Development Environment (IDE): Eclipse, IntelliJ IDEA, or a text editor with Java support.
- Clone the repository or download the source code.
git clone https://github.com/your-username/word-cloud-generator.git
- Open the project in your preferred IDE.
- Compile the Java files:
javac *.java - Run the program by executing the
Runnerclass.
- Select Option 1: Run Program from the main menu.
- Set the number of most common words to display in the word cloud (if not already set).
- Specify the input text source (file name, URL, etc.).
- Verify the source details and execute the program.
- View output messages and check the generated word cloud image.
Access threading settings via Main Menu > Option 2:
- Unthreaded Mode: No multithreading used.
- Set Thread Number: Specify the number of threads to utilize.
- Optimized Mode: Automatically optimizes threading based on system processors.
Navigate to Main Menu > Option 3 to switch between:
.htmlfiles..txtfiles.- URLs (must include
http/https).
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
For further information, contact:
- Name: pj-oboyle
- GitHub: pj-oboyle
Thank you for using the Word Cloud Generator! If you find this project helpful, please give it a star on GitHub.