Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

The Dynamic Text Analysis Platform

License Python React

Overview

B12 is a comprehensive, enterprise-grade text analysis platform that combines advanced Natural Language Processing (NLP) capabilities with a modern web interface. It provides end-to-end document processing, analysis, and insights through a scalable REST API powered by machine learning and LLM integration.

The platform demonstrates a complete pipeline from raw document ingestion through sophisticated AI-powered analytics, utilizing state-of-the-art libraries and APIs for production-ready text intelligence.

Key Features

  • ๐Ÿ“„ Multi-Format Document Parsing: Support for PDF, DOCX, PPTX, HTML, and image formats with layout preservation
  • ๐Ÿ” Intelligent Text Analysis: Document summarization, sentiment analysis, and topic modeling
  • ๐Ÿง  Advanced Topic Modeling: BERTopic-powered unsupervised topic discovery with LLM-enhanced labeling
  • ๐Ÿ“Š Interactive Visualizations: Comprehensive charts, word clouds, and trend analysis for insights
  • ๐ŸŒ RESTful API: FastAPI backend with comprehensive endpoints for all analysis tasks
  • ๐Ÿ’ป Modern Web Interface: React-based frontend for document processing and results visualization
  • โšก Concurrent Processing: Batch processing capabilities for large-scale text analysis
  • ๐Ÿ”— LLM Integration: OpenRouter API integration for enhanced summarization and analysis

Technology Stack

Backend

  • Framework: FastAPI with async support
  • Document Processing: PyMuPDF, python-docx, Docling
  • Text Analysis: NLTK, Sentence Transformers
  • Machine Learning: BERTopic, UMAP, HDBSCAN
  • LLM Integration: OpenRouter API
  • Deployment: Uvicorn

Frontend

  • Framework: React 19
  • Language: TypeScript
  • Build Tool: Vite
  • Charting: Recharts for interactive visualizations
  • PDF Export: jsPDF, react-to-pdf
  • Markdown Rendering: react-markdown

Core Dependencies

  • Python 3.9+
  • Node.js 16+
  • Virtual environment (venv)

Project Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Frontend (React + TypeScript)     โ”‚
โ”‚   - Document Upload & Processing   โ”‚
โ”‚   - Results Visualization           โ”‚
โ”‚   - PDF Export Functionality        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ HTTP/REST
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Backend (FastAPI)                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚ Analysis Routers            โ”‚   โ”‚
โ”‚   โ”‚ - Topic Modeling            โ”‚   โ”‚
โ”‚   โ”‚ - Sentiment Analysis        โ”‚   โ”‚
โ”‚   โ”‚ - Document Summarization    โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚ NLP Services & Pipelines    โ”‚   โ”‚
โ”‚   โ”‚ - Async Task Processing     โ”‚   โ”‚
โ”‚   โ”‚ - Model Inference           โ”‚   โ”‚
โ”‚   โ”‚ - Data Extraction           โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   ML/Data Layer                     โ”‚
โ”‚ - BERTopic Models                   โ”‚
โ”‚ - Pretrained Transformers           โ”‚
โ”‚ - External LLM APIs                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Getting Started

Prerequisites

  • Python 3.9 or higher
  • Node.js 16 or higher
  • pip and npm package managers

Installation

1. Clone the Repository

git clone <repository-url>
cd B12---The-Dynamic-text-analysis-Platform

2. Setup Backend

# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate  # On Windows
# source .venv/bin/activate  # On macOS/Linux

# Install dependencies
pip install -r requirements.txt

# Configure environment variables
# Create .env file in backend directory with necessary API keys

3. Setup Frontend

cd frontend

# Install dependencies
npm install

# Build TypeScript
npm run build

Running the Application

Start Backend API

cd backend
uvicorn main:app --reload
# API will be available at http://localhost:8000
# Interactive API docs at http://localhost:8000/docs

Start Frontend Development Server

cd frontend
npm run dev
# Application will be available at http://localhost:5173

Build for Production

# Frontend
cd frontend
npm run build

# Backend is ready for deployment with any ASGI server

API Documentation

Base URL

http://localhost:8000

Health Check

GET /health

Topic Modeling Endpoints

POST /predict          # Predict topics for input text
GET /model-info        # Get model metadata
DELETE /reset-session  # Reset analysis session

Sentiment Analysis Endpoints

POST /sentiment        # Analyze sentiment in documents

Summarization Endpoints

POST /summarize        # Generate document summaries

Full API documentation available at /docs when backend is running.

Project Structure

B12---The-Dynamic-text-analysis-Platform/
โ”œโ”€โ”€ backend/                         # FastAPI application
โ”‚   โ”œโ”€โ”€ main.py                      # Application entry point
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ””โ”€โ”€ config.py               # Configuration management
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ””โ”€โ”€ schemas.py              # Data models & validation
โ”‚   โ”œโ”€โ”€ routers/
โ”‚   โ”‚   โ”œโ”€โ”€ topic.py                # Topic modeling endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ sentiment.py            # Sentiment analysis endpoints
โ”‚   โ”‚   โ””โ”€โ”€ summarize.py            # Summarization endpoints
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ async_tasks.py          # Async task processing
โ”‚       โ”œโ”€โ”€ extractor.py            # Text extraction utilities
โ”‚       โ””โ”€โ”€ pipelines.py            # ML inference pipelines
โ”œโ”€โ”€ frontend/                        # React application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx                 # Main component
โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx                # Entry point
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts                # TypeScript types
โ”‚   โ”‚   โ””โ”€โ”€ assets/                 # Static assets
โ”‚   โ”œโ”€โ”€ index.html                  # HTML template
โ”‚   โ”œโ”€โ”€ package.json                # Frontend dependencies
โ”‚   โ”œโ”€โ”€ vite.config.ts              # Vite configuration
โ”‚   โ””โ”€โ”€ tsconfig.json               # TypeScript configuration
โ”œโ”€โ”€ task1/                          # Parser Evaluation & Research
โ”‚   โ”œโ”€โ”€ task1_eval.py               # Library comparison script
โ”‚   โ””โ”€โ”€ Task1_Parser_Evaluation.md  # Evaluation report
โ”œโ”€โ”€ task2/                          # Basic Parser Implementation
โ”‚   โ””โ”€โ”€ pymupdf_parser.py           # PDF/DOCX extraction
โ”œโ”€โ”€ task3/                          # Advanced Parser
โ”‚   โ””โ”€โ”€ doc_parser.py               # Multi-format parsing with Docling
โ”œโ”€โ”€ task4/                          # Text Preprocessing
โ”‚   โ”œโ”€โ”€ preprocessing.py            # Tokenization, stemming, lemmatization
โ”‚   โ””โ”€โ”€ step_by_step_demo.py        # Pipeline demonstration
โ”œโ”€โ”€ task5/                          # Document Summarization
โ”‚   โ””โ”€โ”€ summarizer_openrouter.py   # LLM-based summarization
โ”œโ”€โ”€ task6/                          # Sentiment Analysis
โ”‚   โ””โ”€โ”€ sentiment_analyzer.py       # Multi-batch sentiment processing
โ”œโ”€โ”€ task7/                          # Topic Modeling
โ”‚   โ”œโ”€โ”€ train_topic_model.py        # BERTopic model training
โ”‚   โ”œโ”€โ”€ run_inference.py            # Topic inference
โ”‚   โ”œโ”€โ”€ models/                     # Trained model artifacts
โ”‚   โ””โ”€โ”€ results/                    # Classification results
โ”œโ”€โ”€ task8/                          # Legacy API Implementation
โ”‚   โ””โ”€โ”€ api.py                      # Original FastAPI setup
โ”œโ”€โ”€ processed_data/                 # Sample outputs
โ”œโ”€โ”€ assets/                         # Input documents
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md                       # This file

Workflow & Data Pipeline

Raw Documents (PDF, DOCX, PPTX, etc.)
           โ†“
   Document Parsing (Task 3)
 [Docling + PyMuPDF Fallback]
           โ”‚
           โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚                                          โ”‚
           โ†“                                          โ†“
  Raw, Formatted Text                     [Archived / Standalone Utility]
(Maintains natural grammar)                 Text Preprocessing (Task 4)
           โ”‚                               (Not used in current pipeline)
           โ”‚
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                              
   โ†“       โ†“              โ†“                              
 Task 5   Task 6        Task 7
(Summ.)  (Sent.)       (Topic)
 [LLM]  [FinBERT]    [BERTopic]
   โ”‚       โ”‚              โ”‚                              
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ†“
   REST API (FastAPI Backend)
           โ†“
   Web Interface (React Frontend)
           โ†“
   Results, Dashboards & Insights

Core Features in Detail

๐Ÿ“„ Document Processing

  • Multi-format support: PDF, DOCX, PPTX, HTML, XML, images
  • Layout preservation: Maintains document structure in Markdown output
  • Batch processing: Handle multiple documents concurrently
  • Format evaluation: Comparative analysis of parsing libraries with WER metrics

๐Ÿ“Š Interactive Visualizations

  • Word Clouds: Visual representation of key themes and keywords
  • Topic Distribution Charts: Bar charts showing all discovered topics with confidence scores
  • Sentiment Distribution: Pie charts for positive/negative/neutral sentiment breakdowns
  • Sentiment Trend Analysis: Scatter plots showing sentiment evolution through the document
  • Custom Tooltips: Interactive hover information for detailed insights
  • PDF Export: All visualizations included in exported reports

๐Ÿง  Intelligent Analysis

  • Sentiment Analysis: LLM-powered sentiment detection with concurrent processing
  • Document Summarization: Extract key information using advanced LLMs (Gemini, Llama)
  • Topic Modeling: Unsupervised topic discovery with semantic understanding
  • Text Preprocessing: Advanced NLP preprocessing pipeline

๐Ÿ”— Extensible Architecture

  • Modular design: Each analysis component is independently deployable
  • Async-first: Built for high-throughput concurrent processing
  • LLM integration: Seamless integration with external AI APIs
  • RESTful endpoints: Standard HTTP API for all functionality

Development

Running Tests & Validation

# Example: Run document parser
python task3/doc_parser.py

# Example: Run preprocessing demo
python task4/step_by_step_demo.py

# Example: Run sentiment analysis
python task6/sentiment_analyzer.py

# Example: Train topic model
python task7/train_topic_model.py

Code Quality

cd frontend
npm run lint          # Run ESLint
npm run build         # Verify TypeScript compilation

Environment Variables

Backend requires the following environment variables (.env file):

OPENROUTER_API_KEY=your_api_key_here
DATABASE_URL=optional_database_url
LOG_LEVEL=INFO

Deployment

Production Deployment

Backend (Using Gunicorn + Uvicorn)

# Install production server
pip install gunicorn

# Run with multiple workers
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

Frontend (Static Files)

# Build for production
npm run build

# Serve with your preferred web server (nginx, Apache, etc.)
# Outputs to: frontend/dist/

Docker Deployment (Optional)

Create Dockerfile for backend:

FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Performance Optimization

  • Backend: Consider using Redis for caching model predictions
  • Frontend: Implement lazy loading for large document uploads
  • Database: Monitor query performance with appropriate indexing
  • API: Implement rate limiting for production use

Troubleshooting

Common Issues

Issue: Backend fails to start with model loading errors

# Solution: Ensure all model dependencies are installed
pip install -r requirements.txt
python -c "import torch; import transformers; print('Dependencies OK')"

Issue: Frontend cannot connect to backend API

# Solution: Check backend is running and CORS is properly configured
# Verify Backend is running on http://localhost:8000
# Check frontend environment configuration

Issue: Out of memory errors during topic modeling

# Solution: Reduce batch size in task7/train_topic_model.py
# or use GPU acceleration if available

Issue: API returns 500 errors during document processing

# Solution: Check backend logs and ensure OpenRouter API key is valid
# Verify input documents are in supported formats

Performance Benchmarks

  • Document Parsing: ~50-100 KB/s depending on format complexity
  • Text Preprocessing: ~10,000 tokens/second
  • Topic Modeling Inference: <1s per document
  • API Response Time: <500ms for single document analysis

API Response Examples

Topic Prediction

{
  "topics": [
    {
      "id": 0,
      "label": "Finance",
      "probability": 0.95
    },
    {
      "id": 1,
      "label": "Technology",
      "probability": 0.03
    }
  ],
  "processing_time_ms": 245
}

Sentiment Analysis

{
  "sentiment": "positive",
  "confidence": 0.92,
  "entities": ["company", "growth", "innovation"],
  "summary": "Document discusses positive business developments"
}

Document Summary

{
  "original_length": 2500,
  "summary_length": 450,
  "summary": "Key points about the document...",
  "key_phrases": ["metric1", "metric2", "metric3"]
}

Research & Evaluation

The project includes comprehensive research documentation:

  • Parser Evaluation (Task 1): Comparative analysis of PDF parsing libraries
  • Preprocessing Techniques (Task 4): Detailed results and comparisons
  • Model Performance (Task 7): Topic modeling accuracy and metrics

See individual task directories for detailed reports and evaluation results.

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Standards

  • Python: Follow PEP 8 guidelines
  • TypeScript: Use provided ESLint configuration
  • Documentation: Update README and add docstrings for new functions
  • Testing: Include test cases for new features

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • BERTopic: Advanced topic modeling framework
  • Sentence Transformers: Semantic embeddings
  • OpenRouter: LLM API aggregation
  • FastAPI: Modern web framework
  • React: UI framework

Project Timeline

  • Phase 1: Document parsing and evaluation
  • Phase 2: Text preprocessing pipeline
  • Phase 3: Advanced analysis modules (summarization, sentiment)
  • Phase 4: Topic modeling integration
  • Phase 5: API deployment and backend integration
  • Phase 6: Frontend development and visualization

Roadmap

v1.1 (Planned)

  • Multi-language support
  • Advanced visualization dashboard
  • Real-time collaborative analysis
  • Model fine-tuning interface

v1.2 (Planned)

  • GraphDB integration for entity relationships
  • Knowledge graph extraction
  • Advanced search capabilities
  • Batch processing optimization

v2.0 (Long-term)

  • Distributed processing support
  • Custom model training UI
  • Advanced reporting and analytics
  • Enterprise integrations

Support & Contact

For issues, feature requests, or questions:

  • Issues: Use GitHub Issues tracker
  • Documentation: See task-specific markdown files
  • API Docs: Visit http://localhost:8000/docs when running backend

Quick Links


Last Updated: March 2026 Maintainer: B12 Development Team Status: Active Development

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages