#!/usr/bin/env python3
"""
Script to reset the dictionary by removing all entries.
"""

from app import create_app, db
from app.models.dictionary import DictionaryEntry

def reset_dictionary():
    """Remove all dictionary entries."""
    app = create_app()
    with app.app_context():
        try:
            # Count entries before deletion
            count = DictionaryEntry.query.count()
            print(f"Found {count} dictionary entries.")

            # Delete all entries
            DictionaryEntry.query.delete()
            db.session.commit()

            print(f"Successfully deleted all {count} dictionary entries.")
            print("Dictionary has been reset.")

        except Exception as e:
            db.session.rollback()
            print(f"Error resetting dictionary: {e}")

if __name__ == "__main__":
    reset_dictionary()