Advanced stylometry analysis system with modular architecture
Project description
Style Transfer AI - Enhanced Deep Stylometry Analyzer v1.0.0
๐ฏ Advanced stylometry analysis system with personalized linguistic fingerprinting and modular architecture
๐ Quick Start
Getting installation errors? โ See QUICK_FIX_INSTALLATION.md
Need detailed setup? โ See INSTALLATION_GUIDE.md
# Simple Method (Works for everyone)
git clone https://github.com/alwynrejicser/style-transfer-ai.git
cd style-transfer-ai
pip install requests
python run.py
# Advanced Method (May need troubleshooting)
pip install -e .
style-transfer-ai
Features
โ ๐๏ธ Modular Architecture:
- Clean separation: Feature-based modules for maintainability
- Scalable design: Easy to extend with new models or features
- Professional structure: Industry-standard Python package organization
โ Personalized Stylometric Fingerprints:
- Name-based file organization: Files saved as
{name}_stylometric_profile_{timestamp} - Personal identity integration: Your name prominently displayed in analysis
- Stylometric fingerprint concept: Treats writing analysis as unique personal identifiers
- Safe filename handling: Automatic sanitization for filesystem compatibility
โ Performance Optimization:
- Multi-model support: Local Ollama + Cloud APIs (OpenAI, Gemini)
- Intelligent processing: Statistical-only or full deep analysis modes
- Resource-aware processing: Optimized for different analysis depths
โ Hierarchical Model Selection:
- Local Processing: Ollama models (privacy-first, free)
- Cloud Processing: OpenAI GPT-3.5-turbo, Google Gemini-1.5-flash
- Automatic fallback: Graceful degradation when models unavailable
- Intuitive navigation: Main menu โ Sub-menus with back navigation
- Professional interface: Clean, emoji-free design for serious analysis
โ Enhanced Deep Analysis:
- 25-point stylometric framework (upgraded from 15-point)
- Dual output formats: JSON (machine-readable) + TXT (human-readable)
- Advanced metrics: Readability scores, lexical diversity, psychological profiling
- Statistical analysis: Word frequencies, punctuation patterns, complexity indices
- Individual file analysis + consolidated profiling
โ Cloud Storage Integration:
- Firebase Firestore: Optional cloud database storage for profiles
- Automatic backup: Profiles saved locally AND in cloud (when configured)
- Cross-device access: Access your stylometric profiles from anywhere
- Search and retrieval: Query profiles by user name and creation date
- Privacy-first: Cloud storage is optional, local-only mode still available
โ Privacy & Flexibility:
- Local processing for confidential content
- Multiple cloud API options (OpenAI, Gemini)
- Flexible API key management
- No data sharing with local models
- Production-ready architecture
Quick Start
1. Setup Requirements
For Local Models (Recommended)
# Install Ollama
# Visit: https://ollama.ai/download
# Pull the models
ollama pull gpt-oss:20b # Advanced model
ollama pull gemma3:1b # Fast model
# Start Ollama server
ollama serve
For Cloud APIs (Optional)
OpenAI API:
- Get your API key from OpenAI Platform
- Replace placeholder in the code:
OPENAI_API_KEY = "your-openai-api-key-here" # Replace with your actual key
Google Gemini API:
- Get your API key from Google AI Studio
- Replace placeholder in the code:
GEMINI_API_KEY = "your-gemini-api-key-here" # Replace with your actual key
Firebase Firestore (Optional - Cloud Storage):
- Create a Firebase project at Firebase Console
- Enable Firestore Database
- Download service account JSON key
- Place the key file as
firebase-credentials.jsonin project root - Update project ID in the code (replace
'styler-24736'with your project ID) - See FIREBASE_SETUP.md for detailed instructions
2. Install Dependencies
pip install -r requirements.txt
# Or manually:
pip install requests openai google-generativeai firebase-admin
3. Prepare Your Text Samples
Place your writing samples in the project directory:
about_my_pet.txtabout_my _pet_1.txt- Or modify file paths in the code
4. Run Analysis
python style_analyzer_enhanced.py
CLI Installation & Usage
Automated Installation (Windows)
For Windows users, use the provided batch files for easy setup:
# Full installation with dependency checks and Ollama detection
install\install_cli.bat
# Quick installation (minimal output)
install\quick_install.bat
The installation script will:
- โ Check Python and pip installation
- โ Create isolated virtual environment
- โ Install ALL AI dependencies (OpenAI, Gemini, Firebase)
- โ Set up global CLI access (adds to user PATH)
- โ Test the installation
- โ Check for Ollama and AI models
- โ Provide next steps and usage examples
Post-Installation:
- Restart your command prompt for global access
- Use
style-transfer-aifrom any directory - All AI models and APIs ready to use
Manual Installation
Install the package to use the style-transfer-ai command globally:
# From project root directory
pip install -e .
For Global Access (Recommended): The installation automatically adds the CLI to your PATH. If you encounter issues, the virtual environment path is added automatically. You can now use the CLI from anywhere:
# Works from any directory
style-transfer-ai
# Run from anywhere on your system
cd C:\
style-transfer-ai --help
Note: The CLI automatically changes to the correct project directory when run, so it works regardless of your current working directory.
CLI Usage Examples
Interactive Mode (Default)
# Run interactive menu (same as python style_analyzer_enhanced.py)
style-transfer-ai
style-transfer-ai --interactive
Batch Analysis
# Analyze single file
style-transfer-ai --analyze sample.txt
# Analyze multiple files
style-transfer-ai --analyze file1.txt file2.txt file3.txt
# Analyze with specific model
style-transfer-ai --analyze sample.txt --model gpt-oss:20b
# Force local processing
style-transfer-ai --analyze sample.txt --local
# Force cloud processing
style-transfer-ai --analyze sample.txt --cloud
Custom Output
# Custom output filename base
style-transfer-ai --analyze sample.txt --output "my_analysis"
# Disable cloud storage for this run
style-transfer-ai --analyze sample.txt --no-cloud-storage
Data Management
# Open Firestore data retention management
style-transfer-ai --data-retention
CLI Options Reference
| Option | Description | Example |
|---|---|---|
--interactive |
Run in interactive menu mode (default) | style-transfer-ai --interactive |
--analyze FILE [FILE ...] |
Analyze one or more text files | style-transfer-ai --analyze text1.txt text2.txt |
--model MODEL |
Specify model (gpt-oss:20b, gemma3:1b, openai, gemini) | style-transfer-ai --analyze file.txt --model gemma3:1b |
--local |
Force use of local Ollama models | style-transfer-ai --analyze file.txt --local |
--cloud |
Force use of cloud models (OpenAI/Gemini) | style-transfer-ai --analyze file.txt --cloud |
--output NAME |
Base name for output files (no extension) | style-transfer-ai --analyze file.txt --output my_profile |
--no-cloud-storage |
Disable Firestore cloud storage for this run | style-transfer-ai --analyze file.txt --no-cloud-storage |
--data-retention |
Open Firestore data retention management | style-transfer-ai --data-retention |
--help |
Show help message and exit | style-transfer-ai --help |
Advanced CLI Workflows
Research Pipeline
# Analyze academic papers with cloud processing
style-transfer-ai --analyze paper1.txt paper2.txt --cloud --output "academic_style"
# Quick analysis with local fast model
style-transfer-ai --analyze draft.txt --local --model gemma3:1b
Batch Processing
# Analyze all text files in current directory (Windows PowerShell)
Get-ChildItem *.txt | ForEach-Object { style-transfer-ai --analyze $_.Name --output $_.BaseName }
# Analyze with privacy mode (no cloud storage)
style-transfer-ai --analyze sensitive.txt --local --no-cloud-storage
Development & Testing
# Test different models on same content
style-transfer-ai --analyze test.txt --model gpt-oss:20b --output "test_advanced"
style-transfer-ai --analyze test.txt --model gemma3:1b --output "test_fast"
CLI vs Interactive Mode
| Feature | CLI Mode | Interactive Mode |
|---|---|---|
| Speed | Fast, direct analysis | Menu navigation required |
| Automation | Perfect for scripts/batch | Manual operation |
| Customization | Command-line arguments | Interactive prompts |
| User Experience | Technical users | User-friendly menus |
| Integration | CI/CD, automation tools | Stand-alone usage |
Troubleshooting CLI
Command not found after installation:
# Verify installation
pip list | grep style-transfer-ai
# Reinstall in development mode
pip uninstall style-transfer-ai
pip install -e .
Permission errors:
# Use user installation
pip install --user -e .
# Or with elevated permissions (Windows)
# Run PowerShell as Administrator, then install
Path issues:
# Check if Python Scripts directory is in PATH
python -m site --user-base
# Add to PATH if needed (Windows PowerShell)
$env:PATH += ";$(python -m site --user-base)\Scripts"
Key Workflow
Personal Profile Setup
- Name Collection: Your name is collected first as stylometric profiles are personal fingerprints
- Cultural Context: Language background, nationality, education details
- Writing Experience: Frequency and background information
- Streamlined Process: Only essential information collected for meaningful analysis
Processing Modes (GPT-OSS)
When using GPT-OSS models, choose your processing mode:
- Turbo Mode: Faster analysis (2000 tokens, 120s timeout) for quick insights
- Normal Mode: Thorough analysis (3000 tokens, 180s timeout) for comprehensive profiling
Usage
Model Selection
The analyzer features a hierarchical menu system for intuitive model selection:
Main Menu:
- Local Processing (Privacy-focused)
- Online Processing (Cloud-based)
Local Models Sub-menu:
- GPT-OSS 20B - Advanced comprehensive analysis
- Gemma 3:1B - Fast efficient processing
Online Models Sub-menu:
- OpenAI GPT-3.5-turbo - Cloud-based analysis
- Google Gemini-1.5-flash - Google's latest language model
Navigation: Use '0' to go back to the previous menu or exit the application.
Enhanced Output
The analyzer generates personalized stylometric fingerprints:
- Individual analyses for each text file with 25-point deep analysis
- Consolidated style profile combining all samples
- Personalized file naming:
{your_name}_stylometric_profile_{timestamp}- Example:
John_Doe_stylometric_profile_20250915_123456.json
- Example:
- Dual format outputs:
- JSON file - Machine-readable data for further processing
- TXT file - Human-readable report with your name prominently displayed
- Writer Identity Section: Your name featured prominently in analysis header
- Advanced metrics: Readability scores, lexical diversity, statistical analysis
- Comprehensive metadata with timestamps and detailed file information
- Automatic cleanup: Option to remove old reports with both naming patterns
API Key Configuration
Method 1: Direct Code Modification
Replace the placeholders in style_analyzer_enhanced.py:
OPENAI_API_KEY = "your-actual-openai-api-key-here"
GEMINI_API_KEY = "your-actual-gemini-api-key-here"
Method 2: Interactive Setup (Recommended)
The analyzer will automatically:
- Detect existing API keys for both OpenAI and Gemini
- Prompt for new keys if needed based on your model choice
- Validate key format and provide helpful URLs
- Handle setup cancellation gracefully
- Support switching between different API providers
Project Structure
style-transfer-ai/
โโโ style_analyzer_enhanced.py # Enhanced deep analyzer v4.5 (25-point framework)
โโโ .github/
โ โโโ copilot-instructions.md # Development guidelines for GitHub Copilot
โโโ IMPLEMENTATION.md # Detailed technical documentation
โโโ README.md # This file
โโโ futureimprov.md # Future improvement plans
โโโ FIREBASE_SETUP.md # Firebase Firestore setup guide
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment configuration template
โโโ .gitignore # Git ignore for security
โโโ about_my_pet.txt # Sample text file 1
โโโ about_my_pet_1.txt # Sample text file 2
โโโ {name}_stylometric_profile_*.json # Your personalized analysis (JSON)
โโโ {name}_stylometric_profile_*.txt # Your personalized analysis (TXT)
What's New
๐ Personalized Stylometric Fingerprints:
- Your name is now collected and used for file naming
- Files saved as
{Name}_stylometric_profile_{timestamp} - Writer identity prominently displayed in analysis
- Automatic filename sanitization for safe storage
โก GPT-OSS Performance Modes:
- Turbo Mode: Quick analysis with optimized parameters
- Normal Mode: Comprehensive deep analysis
- User choice for processing speed vs thoroughness
โ๏ธ Firebase Firestore Integration:
- Cloud Database Storage: Optional backup to Firebase Firestore
- Cross-Device Access: Access profiles from any device
- Search & Retrieval: Query profiles by user and date
- Privacy Maintained: Local storage still default, cloud is optional
๐๏ธ Enhanced Architecture:
- Streamlined user profile collection (8 essential fields)
- Professional interface without emoji clutter
- Improved error handling and connection validation
- Updated cleanup functionality for all naming patterns
Enhanced Stylometric Analysis Framework
The analyzer evaluates 25 comprehensive dimensions across 7 categories:
Part 1: Linguistic Architecture
- Sentence Structure Mastery: Exact averages, complexity ratios with percentages
- Clause Choreography: Subordinate clause frequency, coordination patterns
- Punctuation Symphony: Complete punctuation analysis with frequencies
- Syntactic Sophistication: Sentence variety index, grammatical complexity scoring
Part 2: Lexical Intelligence
- Vocabulary Sophistication: Word complexity levels, formal/informal ratios
- Semantic Field Preferences: Domain categorization (abstract/concrete, emotional/logical)
- Lexical Diversity Metrics: Type-token ratio, vocabulary richness index
- Register Flexibility: Formality spectrum analysis, colloquialism detection
Part 3: Stylistic DNA
- Tone Architecture: Confidence indicators, emotional markers with examples
- Voice Consistency: Person preference analysis, active/passive voice ratios
- Rhetorical Weaponry: Metaphor counting, parallel structures, repetition patterns
- Narrative Technique: Point of view consistency, storytelling vs explanatory modes
Part 4: Cognitive Patterns
- Logical Flow Design: Argument structure, cause-effect pattern analysis
- Transition Mastery: Transition word categorization, coherence mechanisms
- Emphasis Engineering: Key point highlighting strategies, linguistic intensity
- Information Density: Concept-to-word ratios, information packaging efficiency
Part 5: Psychological Markers
- Cognitive Processing Style: Linear vs circular thinking, analytical patterns
- Emotional Intelligence: Empathy markers, emotional vocabulary richness
- Authority Positioning: Hedging language, assertiveness markers, expertise indicators
- Risk Tolerance: Certainty language analysis, qualification usage patterns
Part 6: Structural Genius
- Paragraph Architecture: Length variance, topic development patterns
- Coherence Engineering: Text cohesion measurement, referential chains
- Temporal Dynamics: Tense usage patterns, time reference preferences
- Modal Expression: Modal verb counting, probability vs obligation language
Part 7: Unique Fingerprint
- Personal Signature Elements: Unique phrases, idiosyncratic expressions, personal habits
Stylistic Markers
- Tone Indicators: Confidence, emotional markers, certainty
- Narrative Voice: Person preference, active/passive ratio
- Rhetorical Devices: Metaphors, repetition, parallel structure
Structural Preferences
- Paragraph Organization: Length, transition methods
- Flow Patterns: Idea connection, progression style
- Emphasis Techniques: Highlighting methods
Personal Markers
- Idiomatic Expressions: Unique phrases, expressions
- Cultural References: Reference types and patterns
- Formality Range: Casual to formal adaptability
Security & Best Practices
๐ API Key Security:
- Never commit real API keys to version control
- Use environment variables for production
- Rotate keys regularly
- Monitor usage and costs
๐ก๏ธ Privacy:
- Use local models for sensitive content
- Local processing keeps data on your machine
- No internet connection required for Ollama models
Troubleshooting
Common Issues
Ollama Connection Failed:
# Make sure Ollama is running
ollama serve
# Check if models are installed
ollama list
# Pull missing models
ollama pull gpt-oss:20b
ollama pull gemma3:1b
GPT-OSS Performance Issues:
- Try Turbo Mode for faster processing
- Switch to Normal Mode for detailed analysis
- Check system resources during processing
- Verify model is fully loaded in Ollama
OpenAI API Errors:
- Check API key validity
- Verify account has sufficient credits
- Ensure proper key format (starts with 'sk-')
File Naming Issues:
- Special characters in names are automatically sanitized
- Long names are truncated to 50 characters
- Empty names default to "Anonymous_User"
- Files are timestamped for unique identification
File Not Found:
- Verify text files exist in project directory
- Check file names match exactly
- Ensure proper file encoding (UTF-8)
Contributing
Contributions welcome! Please ensure:
- No real API keys in commits
- Update documentation for new features
- Test with all model types and processing modes
- Follow existing code style and naming conventions
- Include personalization features in new developments
Version History
- v4.5 (Current): Personalized stylometric fingerprints, GPT-OSS performance modes
- v4.0: Enhanced deep analysis framework (25-point system)
- v3.0: Hierarchical model selection with local/online options
- v2.0: Dual output formats (JSON + TXT)
- v1.0: Basic stylometry analysis
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file style_transfer_ai-1.0.0.tar.gz.
File metadata
- Download URL: style_transfer_ai-1.0.0.tar.gz
- Upload date:
- Size: 94.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e4fc0710a63b5110638084e461d1ff7b3457a6d3164fb69bd4b119856f41d0a
|
|
| MD5 |
810a54ddda52a0d3ac1baaf574d0911c
|
|
| BLAKE2b-256 |
8ebd5cabcc0d684179fc66113124f82d395560c946b38908fce499ad14c18828
|
File details
Details for the file style_transfer_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: style_transfer_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 69.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac71634ea9e496d250f87161e667ede2abedb4f1771962e07dca3a3d8538c085
|
|
| MD5 |
f28ecae708df676c47bc179c566d5e53
|
|
| BLAKE2b-256 |
3d238777c3521e60f82a9dd0c68b8cbf3c47b97d74c1135a858b5eb70fd41efc
|