import sys
sys.path.insert(0, 'GoogleDocumentOCR')
from db import get_conn

conn = get_conn()
cur  = conn.cursor()

cur.execute("""
    SELECT nationality, corpus, chunk_type, COUNT(*)
    FROM document_chunks
    GROUP BY nationality, corpus, chunk_type
    ORDER BY nationality, corpus, chunk_type
""")
print(f"{'Nationality':<12} {'Corpus':<26} {'Type':<14} {'Count':>6}")
print("-" * 64)
for nat, corpus, ctype, count in cur.fetchall():
    print(f"{nat:<12} {corpus:<26} {ctype:<14} {count:>6}")

cur.execute("SELECT COUNT(*) FROM document_chunks")
print(f"\nTOTAL: {cur.fetchone()[0]} chunks")

cur.close()
conn.close()

