================================================================================
  Question 12: Modular Text Analysis Toolkit
================================================================================

FULL QUESTION:
Task: Build a text analysis toolkit using Python modules.

Structure:
your_project_folder/
├── text_preprocessor.py
├── text_analyzer.py
└── main_analyzer.py

Module Specs:
text_preprocessor.py:
- normalize_text(text): lowercase, remove punctuation.
- tokenize_text(text): split into words.
text_analyzer.py:
- word_frequency(word_list): count word occurrences.
- character_count(text): count alphabetic chars.
- unique_word_count(word_list): count unique words.
main_analyzer.py:
- Import and use functions from other modules.
- Prompt for text.
- Display: Original, Normalized, Tokens, Word Frequency, Total Char Count, Unique Word Count.
- Print docstring of the functions.

SHORT QUESTION:
Modular text analysis toolkit featuring preprocessing, tokenization, frequency analysis, and vocabulary counts.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Question 12: Modular Text Analysis Toolkit

- Prerequisites: Python 3.x (Standard library only).
- Setup: Uses companion modules text_preprocessor.py and text_analyzer.py.
- How to Run: python question_12.py  (or python main_analyzer.py)
- Expected Behavior: Imports modular functions, prints their docstrings, analyzes user text, and renders metrics.

================================================================================
SOURCE CODE FILES:
================================================================================

1. question_12.py
--------------------------------------------------------------------------------
import string

def normalize_text(text):
    """Converts a string to lowercase and removes punctuation."""
    new_text = text.lower()
    for punc in string.punctuation:
        new_text = new_text.replace(punc, "")
    return new_text

def tokenize_text(text):
    """Splits a string of normalized text into individual word tokens."""
    return text.split()

def word_frequency(word_list):
    """Counts absolute word occurrences in a list using a dictionary."""
    freq = {}
    for word in word_list:
        freq[word] = word_list.count(word)
    return freq

def character_count(text):
    """Counts only the alphabetic characters in a given text string."""
    count = 0
    for char in text:
        if char.isalpha():
            count += 1
    return count

def unique_word_count(word_list):
    """Calculates the total number of unique words in a word list."""
    return len(set(word_list))

import text_preprocessor as pre
import text_analyzer as ana

user_text = input("Please enter your text to analyze: \n").strip()

normalized = pre.normalize_text(user_text)
tokens = pre.tokenize_text(normalized)

freqs = ana.word_frequency(tokens)
char_count = ana.character_count(user_text)
unique_words = ana.unique_word_count(tokens)

print(f"Original Text:      {user_text}")
print(f"Normalized Text:    {normalized}")
print(f"Tokens:             {tokens}")
print(f"Word Frequency:     {freqs}")
print(f"Total Alpha Chars:  {char_count}")
print(f"Unique Word Count:  {unique_words}")

print()
print(f"normalize_text():\n{pre.normalize_text.__doc__}\n")
print(f"tokenize_text():\n{pre.tokenize_text.__doc__}\n")
print(f"word_frequency():\n{ana.word_frequency.__doc__}\n")
print(f"character_count():\n{ana.character_count.__doc__}\n")
print(f"unique_word_count():\n{ana.unique_word_count.__doc__}\n")
--------------------------------------------------------------------------------
