124 lines
3.6 KiB
Python
Executable File
124 lines
3.6 KiB
Python
Executable File
"""
|
|
Jednoduchý skript na prezeranie databázy factchecker.db
|
|
"""
|
|
import sqlite3
|
|
import json
|
|
from datetime import datetime
|
|
|
|
DB_NAME = "factchecker.db"
|
|
|
|
def print_separator():
|
|
print("=" * 80)
|
|
|
|
def view_fact_checks():
|
|
"""Zobrazí všetky fact-checky"""
|
|
conn = sqlite3.connect(DB_NAME)
|
|
conn.row_factory = sqlite3.Row
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute('SELECT * FROM fact_checks ORDER BY checked_at DESC')
|
|
rows = cursor.fetchall()
|
|
|
|
print_separator()
|
|
print(f"📊 FACT CHECKS (celkom: {len(rows)})")
|
|
print_separator()
|
|
|
|
for row in rows:
|
|
print(f"\n🔍 ID: {row['id']}")
|
|
print(f" Tvrdenie: {row['claim']}")
|
|
print(f" Verdikt: {row['verdict']}")
|
|
|
|
# Zobraziť model (ak existuje stĺpec model_name)
|
|
try:
|
|
model = row['model_name']
|
|
if model:
|
|
print(f" Model: {model}")
|
|
else:
|
|
print(f" Model: neznámy (starý záznam)")
|
|
except IndexError:
|
|
pass # Stĺpec neexistuje v starej databáze
|
|
|
|
print(f" Počet kontrol: {row['check_count']}")
|
|
print(f" Posledná kontrola: {row['checked_at']}")
|
|
|
|
if row['nli_votes']:
|
|
votes = json.loads(row['nli_votes'])
|
|
print(f" NLI hlasy: {votes}")
|
|
|
|
if row['sources']:
|
|
sources = json.loads(row['sources'])
|
|
if sources:
|
|
print(f" Zdroje: {sources[0] if sources else 'žiadne'}")
|
|
|
|
print()
|
|
|
|
conn.close()
|
|
|
|
def view_verified_facts():
|
|
"""Zobrazí manuálne overené fakty"""
|
|
conn = sqlite3.connect(DB_NAME)
|
|
conn.row_factory = sqlite3.Row
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute('SELECT * FROM verified_facts ORDER BY added_at DESC')
|
|
rows = cursor.fetchall()
|
|
|
|
print_separator()
|
|
print(f"✅ OVERENÉ FAKTY (celkom: {len(rows)})")
|
|
print_separator()
|
|
|
|
if not rows:
|
|
print("\n⚠️ Žiadne manuálne overené fakty\n")
|
|
else:
|
|
for row in rows:
|
|
print(f"\n✓ ID: {row['id']}")
|
|
print(f" Tvrdenie: {row['claim']}")
|
|
print(f" Verdikt: {row['verdict']}")
|
|
if row['explanation']:
|
|
print(f" Vysvetlenie: {row['explanation']}")
|
|
if row['source_url']:
|
|
print(f" Zdroj: {row['source_url']}")
|
|
print(f" Pridané: {row['added_at']} ({row['added_by']})")
|
|
print()
|
|
|
|
conn.close()
|
|
|
|
def view_stats():
|
|
"""Zobrazí štatistiky"""
|
|
conn = sqlite3.connect(DB_NAME)
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute('SELECT COUNT(*) as total FROM fact_checks')
|
|
total_claims = cursor.fetchone()[0]
|
|
|
|
cursor.execute('SELECT SUM(check_count) as total FROM fact_checks')
|
|
total_checks = cursor.fetchone()[0] or 0
|
|
|
|
cursor.execute('SELECT COUNT(*) as total FROM verified_facts')
|
|
verified = cursor.fetchone()[0]
|
|
|
|
print_separator()
|
|
print("📈 ŠTATISTIKY")
|
|
print_separator()
|
|
print(f" Unikátne tvrdenia: {total_claims}")
|
|
print(f" Celkový počet kontrol: {total_checks}")
|
|
print(f" Overené fakty: {verified}")
|
|
print_separator()
|
|
print()
|
|
|
|
conn.close()
|
|
|
|
def main():
|
|
print("\n" + "🔎 DATABÁZA FACT-CHECKERA".center(80))
|
|
|
|
try:
|
|
view_stats()
|
|
view_fact_checks()
|
|
view_verified_facts()
|
|
except sqlite3.OperationalError as e:
|
|
print(f"❌ Chyba: {e}")
|
|
print(" Skontroluj či existuje factchecker.db")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|