Spaces:
Sleeping
Sleeping
Ryan Christian D. Deniega commited on
Commit Β·
9724119
1
Parent(s): 6c9b8f1
docs: add README
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174# PhilVerify π΅ππ
**Multimodal fake news detection for Philippine social media.**
PhilVerify combines ML-based text classification with evidence retrieval to detect misinformation in Tagalog, English, and Taglish content. It supports text, URL, image (OCR), and video (ASR) inputs.
---
## Features
- **4 Input Types** β raw text, news URL, image (Tesseract OCR), video/audio (Whisper ASR)- **Language-Aware** β detects Tagalog / English / Taglish automatically- **NLP Pipeline** β NER, sentiment, emotion, clickbait detection, claim extraction- **Two-Layer Scoring** - Layer 1: TF-IDF + Logistic Regression classifier (β fine-tuned XLM-RoBERTa) - Layer 2: NewsAPI evidence retrieval + cosine similarity + stance detection- **Final Score** = `(ML Γ 0.40) + (Evidence Γ 0.60)` β Credible / Unverified / Likely Fake- **Philippine Domain Credibility DB** β 4-tier system (Rappler Tier 1 β known fake sites Tier 4)
---
## Tech Stack
| Layer | Tech ||---|---|| Backend | FastAPI, Python 3.12, Pydantic v2 || NLP | spaCy, HuggingFace Transformers, langdetect || ML Classifier | scikit-learn (TF-IDF + LogReg β XLM-RoBERTa) || OCR | Tesseract (`fil+eng`) || ASR | OpenAI Whisper || Evidence | NewsAPI, sentence-transformers || Frontend *(planned)* | React, TailwindCSS, Chart.js || Extension *(planned)* | Chrome Manifest V3 |
---
## Project Structure
```PhilVerify/βββ main.py # FastAPI app entry pointβββ config.py # Settings (pydantic-settings)βββ requirements.txtβββ .env.exampleβββ domain_credibility.json # PH domain tier databaseββββ api/β βββ schemas.py # Pydantic request/response modelsβ βββ routes/β βββ verify.py # POST /verify/text|url|image|videoβ βββ history.py # GET /historyβ βββ trends.py # GET /trendsββββ nlp/ # NLP preprocessing pipelineβ βββ preprocessor.py # Clean, tokenize, remove stopwords (EN+TL)β βββ language_detector.py # Tagalog / English / Taglish detectionβ βββ ner.py # Named entity recognition + PH entity hintsβ βββ sentiment.py # Sentiment + emotion analysisβ βββ clickbait.py # Clickbait pattern detectionβ βββ claim_extractor.py # Extract falsifiable claim for evidence searchββββ ml/β βββ tfidf_classifier.py # Layer 1 β TF-IDF baseline classifierββββ evidence/β βββ news_fetcher.py # Layer 2 β NewsAPI + cosine similarityββββ scoring/β βββ engine.py # Orchestrates full pipeline + final scoreββββ inputs/β βββ url_scraper.py # BeautifulSoup article extractorβ βββ ocr.py # Tesseract OCRβ βββ asr.py # Whisper ASRββββ tests/ βββ test_philverify.py # 23 unit + integration tests```
---
## Getting Started
### 1. Clone & set up environment
```bashgit clone https://github.com/SemiAutomat1c/philverify.gitcd philverifypython3 -m venv venvsource venv/bin/activatepip install -r requirements.txt```
### 2. Configure environment variables
```bashcp .env.example .env# Edit .env and add your NEWS_API_KEY (optional but recommended)```
### 3. Run the API
```bashuvicorn main:app --reload --port 8000```
### 4. Explore the docs
Open **http://localhost:8000/docs** for the interactive Swagger UI.
---
## API Endpoints
| Method | Endpoint | Description ||---|---|---|| `POST` | `/verify/text` | Verify raw text || `POST` | `/verify/url` | Verify a news URL || `POST` | `/verify/image` | Verify an image (OCR) || `POST` | `/verify/video` | Verify audio/video (Whisper ASR) || `GET` | `/history` | Verification history (paginated) || `GET` | `/trends` | Trending fake-news entities & topics |
### Example request
```bashcurl -X POST http://localhost:8000/verify/text \ -H "Content-Type: application/json" \ -d '{"text": "GRABE! Namatay daw ang tatlong tao sa bagong sakit na kumakalat sa Pilipinas!"}'```
### Example response
```json{ "verdict": "Likely Fake", "confidence": 82.4, "final_score": 34.2, "layer1": { "verdict": "Likely Fake", "confidence": 82.4, "triggered_features": ["namatay", "sakit", "kumakalat"] }, "layer2": { "verdict": "Unverified", "evidence_score": 50.0, "sources": [] }, "entities": { "persons": [], "organizations": [], "locations": ["Pilipinas"], "dates": [] }, "sentiment": "high negative", "emotion": "fear", "language": "Tagalog"}```
---
## Running Tests
```bashpytest tests/ -v# 23 passed in ~1s```
---
## Roadmap
- [x] Phase 1 β FastAPI backend skeleton- [x] Phase 2 β NLP preprocessing pipeline- [x] Phase 3 β TF-IDF baseline classifier- [ ] Phase 4 β NewsAPI evidence retrieval- [ ] Phase 5 β Scoring engine refinement (stance detection)- [ ] Phase 6 β React web dashboard- [ ] Phase 7 β Chrome Extension (Manifest V3)- [ ] Phase 8 β Fine-tune XLM-RoBERTa / TLUnified-RoBERTa
---
## License
MITREADME.mdAdded+174