AI-powered fact-checking tool with fallback mechanisms
Project description
FactCheckr 🔍
A powerful AI-powered fact-checking tool that helps you verify claims and statements with confidence scores and detailed evidence.
Features
- 🤖 AI-Powered Analysis: Uses advanced AI models to fact-check claims
- 📊 Confidence Scoring: Provides confidence levels for each fact-check
- 📝 Detailed Evidence: Returns comprehensive evidence and reasoning
- 🔄 Fallback System: Robust fallback for common claims when AI is unavailable
- 💻 Cross-Platform: Works on Windows, macOS, and Linux
- 🎯 Multiple Input Methods: Command-line, interactive mode, and stdin support
- 📋 JSON Output: Machine-readable output format available
- 🚀 Easy Installation: Available on PyPI with simple pip install
Quick Start
Installation
From PyPI (Recommended)
pip install factcheckr
From GitHub
pip install git+https://github.com/yourusername/factcheckr.git
Development Installation
git clone https://github.com/yourusername/factcheckr.git
cd factcheckr
pip install -e .
Basic Usage
Command Line
# Check a single claim
factcheckr "The Earth is round"
# Alternative syntax
python -m factcheckr "Cats have 9 lives"
# Get JSON output
factcheckr "Water boils at 100°C" --json
# Interactive mode
factcheckr --interactive
# Read from stdin
echo "The moon is made of cheese" | factcheckr --stdin
# Verbose output
factcheckr "Birds can fly" --verbose
Python API
from factcheckr import CompleteFactCheckr
# Initialize the fact checker
checker = CompleteFactCheckr()
# Check a claim
result = checker.fact_check_with_ai("The Earth is flat")
print(f"Verdict: {result['verdict']}")
print(f"Evidence: {result['evidence']}")
print(f"Confidence: {result['confidence']}")
Installation Verification
After installation, verify that FactCheckr is working correctly:
# Check version
factcheckr --version
# Test with a simple claim
factcheckr "Water is wet"
# Test JSON output
factcheckr "The sky is blue" --json
Command Line Options
usage: factcheckr [-h] [--version] [--interactive] [--stdin] [--json] [--verbose] [claim]
AI-powered fact-checking tool
positional arguments:
claim The claim to fact-check
options:
-h, --help show this help message and exit
--version show program's version number and exit
--interactive Enter interactive mode
--stdin Read claims from stdin
--json Output results in JSON format
--verbose Enable verbose output
Output Format
Standard Output
Claim: "The Earth is round"
Verdict: True
Evidence: The Earth is an oblate spheroid, confirmed by satellite imagery, physics, and centuries of scientific observation.
Confidence: 0.95
JSON Output
{
"claim": "The Earth is round",
"verdict": "True",
"evidence": "The Earth is an oblate spheroid, confirmed by satellite imagery, physics, and centuries of scientific observation.",
"confidence": 0.95
}
Platform-Specific Instructions
Windows
# Using Command Prompt
pip install factcheckr
factcheckr "Your claim here"
# Using PowerShell
pip install factcheckr
factcheckr "Your claim here"
macOS
# Using Homebrew Python (recommended)
brew install python
pip3 install factcheckr
factcheckr "Your claim here"
# Using system Python
python3 -m pip install factcheckr
python3 -m factcheckr "Your claim here"
Linux
# Ubuntu/Debian
sudo apt update
sudo apt install python3-pip
pip3 install factcheckr
factcheckr "Your claim here"
# CentOS/RHEL/Fedora
sudo yum install python3-pip # or dnf on newer versions
pip3 install factcheckr
factcheckr "Your claim here"
Troubleshooting
Common Issues
"Command not found" Error
If you get a "command not found" error, try:
-
Use the module syntax:
python -m factcheckr "Your claim"
-
Check your PATH (add Python Scripts directory):
- Windows: Add
%APPDATA%\Python\Python3x\Scriptsto PATH - macOS/Linux: Add
~/.local/binto PATH
- Windows: Add
-
Reinstall with user flag:
pip install --user factcheckr
Installation Issues
-
Upgrade pip first:
python -m pip install --upgrade pip
-
Use virtual environment:
python -m venv factcheckr_env # Windows factcheckr_env\Scripts\activate # macOS/Linux source factcheckr_env/bin/activate pip install factcheckr
-
Install from source:
git clone https://github.com/yourusername/factcheckr.git cd factcheckr pip install -e .
AI Service Issues
FactCheckr includes a robust fallback system for common claims when the AI service is unavailable. If you encounter AI-related errors:
- The tool will automatically fall back to heuristic-based checking for common claims
- Check your internet connection
- The fallback system handles claims like:
- "Cats have 9 lives" → Likely False
- "The Earth is flat" → False
- "Water boils at 100 degrees Celsius" → Likely True
Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/yourusername/factcheckr.git
cd factcheckr
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
# Install in development mode
pip install -e .
# Install development dependencies
pip install pytest build twine
Running Tests
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/test_core.py
# Run with coverage
pytest --cov=factcheckr
Building and Publishing
# Clean previous builds
rm -rf build/ dist/ *.egg-info/
# Build the package
python -m build
# Check the package
twine check dist/*
# Upload to Test PyPI
twine upload --repository testpypi dist/*
# Upload to PyPI
twine upload dist/*
Using the Deployment Script
A comprehensive deployment script is included:
# Full deployment to PyPI
python deploy.py
# Deploy to Test PyPI
python deploy.py --test
# Skip tests during deployment
python deploy.py --skip-tests
# Build only (skip upload)
python deploy.py --skip-upload
API Reference
CompleteFactCheckr Class
class CompleteFactCheckr:
def __init__(self, api_url: str = None)
def fact_check_with_ai(self, claim: str) -> dict
def extract_claim(self, text: str) -> str
Methods
-
fact_check_with_ai(claim: str) -> dict: Main fact-checking method- Parameters:
claim- The claim to fact-check - Returns: Dictionary with
verdict,evidence, andconfidence
- Parameters:
-
extract_claim(text: str) -> str: Extract the main claim from text- Parameters:
text- Input text - Returns: Extracted claim string
- Parameters:
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Quick Contribution Steps
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Add tests for new functionality
- Run tests:
pytest - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
v1.0.1
- Enhanced error handling and fallback system
- Improved cross-platform compatibility
- Added comprehensive test suite
- Better CLI argument parsing
- JSON output support
- Interactive mode improvements
v1.0.0
- Initial release
- Basic fact-checking functionality
- Command-line interface
- AI integration
Support
If you encounter any issues or have questions:
- Check the Troubleshooting section
- Search existing issues
- Create a new issue
Acknowledgments
- Thanks to the Hack Club AI for providing the AI fact-checking capabilities
- Inspired by the need for reliable fact-checking tools in the digital age
- Built with Python and modern packaging best practices
Made with ❤️ for truth and accuracy
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 factcheckr-1.0.1.tar.gz.
File metadata
- Download URL: factcheckr-1.0.1.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.4 requests-toolbelt/1.0.0 urllib3/2.5.0 tqdm/4.66.5 importlib-metadata/8.7.0 keyring/25.6.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dbd553f54a68052e4132c27ff61fa0129226502f100fefba9b9dfebd6981c9e
|
|
| MD5 |
aa7ebcce234354d7153fb5d10d4a0718
|
|
| BLAKE2b-256 |
e6a6564c203dbe1d501c582bf3aa38eae650ed7b41b43d88ffadebdb6e621f07
|
File details
Details for the file factcheckr-1.0.1-py3-none-any.whl.
File metadata
- Download URL: factcheckr-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.4 requests-toolbelt/1.0.0 urllib3/2.5.0 tqdm/4.66.5 importlib-metadata/8.7.0 keyring/25.6.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bccb05f32a761d47fa45d5e3c6e7fe8383e394af6a893611645a666e623cc278
|
|
| MD5 |
c03a63fb4101bd096ef803a8fbaad348
|
|
| BLAKE2b-256 |
c253c3e6521ff6b81ebad1bcab5867cbfa16435eefb09296a9cf19454650d832
|