Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Veritas News Credibility Analysis System

Veritas Logo Python Flask AI

A comprehensive AI-powered system for analyzing news articles to determine credibility, emotional tone, and provide intelligent summaries. Built with cutting-edge NLP models and a robust credibility scoring algorithm.

πŸš€ Features

Core Analysis Capabilities

  • πŸ“Š Credibility Scoring: Multi-factor analysis combining source reputation with content quality indicators
  • πŸ€– AI Summarization: BART model generates concise, intelligent summaries
  • 😊 Emotion Detection: RoBERTa model analyzes emotional tone (positive/negative/neutral)
  • πŸ•·οΈ Smart Web Scraping: Dual-layer extraction using newspaper3k + BeautifulSoup
  • πŸ“ˆ Visual Analytics: Interactive charts and comprehensive breakdowns

Source Database

  • 50+ News Sources: Pre-rated credibility database covering major outlets
  • Tier System: 4-tier credibility classification (Highly Credible to Mixed)
  • Regular Updates: Continuously updated source reputation scores
  • Coverage: Reuters, BBC, CNN, Fox News, NYT, WSJ, and many more

πŸ—οΈ Architecture

Technology Stack

  • Backend: Python + Flask
  • AI Models:
    • BART (facebook/bart-large-cnn) for summarization
    • RoBERTa (cardiffnlp/twitter-roberta-base-emotion) for emotion detection
  • Web Scraping: newspaper3k + BeautifulSoup4
  • Frontend: HTML5 + CSS3 + JavaScript + Chart.js
  • Data Processing: NumPy, NLTK, transformers

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Scraper   │───▢│   AI Analyzer    │───▢│ Credibility     β”‚
β”‚                 β”‚    β”‚                  β”‚    β”‚ Scorer          β”‚
β”‚ β€’ newspaper3k   β”‚    β”‚ β€’ BART Summary   β”‚    β”‚                 β”‚
β”‚ β€’ BeautifulSoup β”‚    β”‚ β€’ RoBERTa Emotionβ”‚    β”‚ β€’ Source DB     β”‚
β”‚ β€’ Fallback      β”‚    β”‚ β€’ Fallbacks      β”‚    β”‚ β€’ Content Eval  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Installation

Prerequisites

  • Python 3.8+
  • 4GB+ RAM (for AI models)
  • Internet connection (for web scraping)

Quick Setup

# Clone the repository
git clone <repository-url>
cd veritas

# Install dependencies
pip install -r requirements.txt

# Download required NLTK data (first time only)
python -c "import nltk; nltk.download('punkt')"

# Run the application
python app.py

Environment Setup

# Optional: Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install requirements
pip install -r requirements.txt

πŸš€ Usage

Web Interface

  1. Start the application: python app.py
  2. Open browser to http://localhost:5000
  3. Enter a news article URL
  4. Get comprehensive analysis in seconds

API Endpoints

Analyze Article

POST /api/analyze
Content-Type: application/json

{
    "url": "https://example.com/news-article"
}

Response Format

{
    "article": {
        "title": "Article Title",
        "source_domain": "example.com",
        "url": "https://example.com/news-article",
        "content_preview": "Article preview..."
    },
    "analysis": {
        "credibility": {
            "final_score": 85.2,
            "confidence": 0.87,
            "interpretation": {
                "level": "High Credibility",
                "description": "Reliable source with good practices"
            },
            "breakdown": {
                "source_reputation": {"score": 12.6, "source_name": "BBC"},
                "article_length": {"score": 10, "word_count": 800},
                "citations": {"score": 9, "citation_count": 3}
            }
        },
        "emotion": {
            "emotion": "neutral",
            "confidence": 0.82,
            "method": "roberta_ai"
        },
        "summary": "AI-generated article summary..."
    }
}

Get Sources Database

GET /api/sources

🎯 Credibility Scoring Algorithm

Scoring Components

Factor Weight Description
Base Score 50% Neutral starting point
Source Reputation Β±30% Known source credibility rating
Article Length Β±10% Comprehensive vs. brief coverage
Citations +15% Source attribution indicators
Factual Content +10% Data, numbers, official references
Emotional Language -10% Penalty for sensational wording

Source Tiers

  • Tier 1 (85-95%): Reuters, BBC, AP, NPR, PBS
  • Tier 2 (75-85%): NYT, WashPost, WSJ, Guardian, Economist
  • Tier 3 (65-75%): CNN, NBC, ABC, CBS, Time
  • Tier 4 (55-65%): Fox News, MSNBC, NY Post, HuffPost

Content Analysis Indicators

βœ… Positive Signals

  • Citations: "according to", "study shows", "expert says"
  • Facts: dates, percentages, official names, statistics
  • Length: 500+ words indicates thorough coverage

❌ Negative Signals

  • Emotional words: "shocking", "unbelievable", "outrageous"
  • Brief articles: <200 words suggests incomplete coverage
  • Missing sources: claims without attribution

πŸ“Š Sample Analysis

Input

URL: https://bbc.com/news/climate-change-study

Output

Credibility Score: 84.6%
β”œβ”€β”€ Base Score: +50.0%
β”œβ”€β”€ Source (BBC): +12.6%
β”œβ”€β”€ Length (800 words): +10.0%
β”œβ”€β”€ Citations (3 found): +9.0%
β”œβ”€β”€ Facts (5 indicators): +5.0%
└── Emotional (-1 word): -2.0%

Emotion: Neutral (82% confidence)
Summary: "Climate researchers report significant temperature increases..."

πŸ”§ Configuration

Environment Variables

# Optional configurations
export SECRET_KEY="your-secret-key"
export DEBUG=False
export PORT=5000

Model Configuration

Models are loaded automatically on first use. For custom configurations:

# In modules/ai_analyzer.py
self.summarizer = pipeline(
    "summarization",
    model="facebook/bart-large-cnn",  # Change model here
    device=0 if torch.cuda.is_available() else -1
)

πŸ“ API Documentation

Endpoints

Method Endpoint Description
GET / Main web interface
POST /api/analyze Analyze news article
GET /api/sources Get source database
GET /api/health Health check

Error Handling

All endpoints return structured error responses:

{
    "error": "Description of error",
    "code": 400,
    "timestamp": "2026-01-07T12:00:00Z"
}

πŸ§ͺ Testing

Run Sample Analysis

# Test with a known article
curl -X POST http://localhost:5000/api/analyze \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.bbc.com/news"}'

Validate Installation

# Check health endpoint
curl http://localhost:5000/api/health

πŸ“š Example Use Cases

1. Fact Checking

Quickly assess the credibility of news articles shared on social media

2. Media Literacy Education

Help students understand credibility indicators in journalism

3. Research Validation

Verify source quality for academic or professional research

4. Content Curation

Filter high-quality articles for news aggregation platforms

⚠️ Limitations

What We DON'T Do

  • ❌ Real-time fact-checking of specific claims
  • ❌ Political bias assessment (we focus on factual accuracy)
  • ❌ Individual journalist reputation tracking
  • ❌ Content verification against external databases

Known Issues

  • AI models require significant RAM (4GB+ recommended)
  • Some websites may block automated scraping
  • Summarization quality varies with article complexity
  • Emotion detection trained primarily on English text

πŸ”’ Privacy & Ethics

Data Handling

  • No Storage: Articles are processed in memory only
  • No Tracking: No user behavior or article analysis stored
  • Respectful Scraping: Implements delays and respects robots.txt

Ethical Considerations

  • Tool is designed to supplement, not replace, critical thinking
  • Source database aims for objectivity but reflects editorial choices
  • Results should be considered alongside other verification methods

🀝 Contributing

Development Setup

# Install development dependencies
pip install pytest black flake8

# Run tests
pytest

# Format code
black modules/ *.py

# Lint code
flake8 modules/ *.py

Adding New Sources

Update modules/source_database.py:

new_sources = {
    'example.com': {
        'name': 'Example News',
        'credibility': 75,
        'tier': 3,
        'description': 'Regional news outlet'
    }
}

πŸ“ž Support

Common Issues

  1. Model Loading Errors: Ensure 4GB+ RAM available
  2. Scraping Failures: Some sites block automated access
  3. Slow Performance: First AI model load takes time

Getting Help

  • Check the logs for detailed error messages
  • Ensure all requirements are properly installed
  • Verify internet connectivity for both scraping and model downloads

πŸ“œ License

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

πŸ™ Acknowledgments

  • Hugging Face for BART and RoBERTa models
  • newspaper3k for news extraction capabilities
  • Chart.js for visualization components
  • Media research organizations for credibility benchmarks

Veritas - "Truth through Analysis"

Built for journalists, researchers, educators, and anyone who values informed decision-making in our information age.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages