Skip to content

JaiSamyukth/WordCounterTool

Repository files navigation

Text Analyzer

A Java-based text analysis tool that provides detailed statistical information about text input. This program offers both interactive input and file-based analysis capabilities.

Features

  • Multiple input methods:
    • Direct keyboard input
    • Text file analysis
  • Comprehensive text statistics:
    • Total character count
    • Character count (excluding spaces)
    • Word count
    • Sentence count
    • Average word length
  • Results management:
    • View results on screen
    • Save analysis to timestamped files
  • Interactive menu system
  • Detailed help documentation

Requirements

  • Java Development Kit (JDK) 8 or higher
  • Any operating system (Windows, macOS, Linux)

Installation

  1. Clone or download this repository
  2. Ensure Java is installed on your system
  3. Navigate to the project directory

Usage

Compiling the Program

javac TextAnalyzer.java

Running the Program

java TextAnalyzer

Menu Options

  1. Analyze text from keyboard input

    • Type or paste your text
    • Type 'END' on a new line when finished
    • View analysis results
    • Optionally save results to file
  2. Analyze text from file

    • Enter the path to your text file
    • View analysis results
    • Optionally save results to file
  3. Help

    • Display detailed usage instructions
  4. Exit

    • Close the program

Example Usage

  1. Analyzing keyboard input:

    1. Select option 1
    2. Type or paste your text
    3. Type 'END' on a new line
    4. View results
    5. Choose whether to save results
    
  2. Analyzing a file:

    1. Select option 2
    2. Enter file path (e.g., sample.txt)
    3. View results
    4. Choose whether to save results
    

Output Format

The analysis results include:

  • Total character count
  • Character count (excluding spaces)
  • Word count
  • Sentence count
  • Average word length (characters per word)

Example output:

=== Analysis Results ===
Total characters: 150
Characters (no spaces): 125
Word count: 30
Sentence count: 3
Average word length: 4.17 characters

Saving Results

When saving results, the program:

  • Creates a timestamped file (format: analysis_YYYYMMDD_HHMMSS.txt)
  • Includes the original text
  • Lists all statistical measurements
  • Saves in the current directory

File Structure

  • TextAnalyzer.java - Main program file
  • sample.txt - Example text file for testing
  • README.md - Documentation (this file)

Testing

A sample text file (sample.txt) is included for testing the file analysis feature.

Error Handling

The program handles various error cases:

  • Invalid menu selections
  • File not found
  • Invalid file paths
  • Empty text input
  • Input/output errors

Contributing

Feel free to fork this repository and submit pull requests for any improvements.

License

This project is open source and available for personal and educational use.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages