SIngtel-Bill-Scanner / working_example.py
Cosmo125's picture
Upload 26 files
795183d verified
"""
WORKING EXAMPLE - Singtel Bill Scanner
This script will work immediately without heavy downloads
"""
print("πŸš€ Singtel Bill Scanner - Quick Start")
print("=" * 50)
def test_basic_functionality():
"""Test basic Python functionality"""
print("βœ… Python is working!")
print("βœ… File system access works!")
# Test basic image processing capability
try:
from PIL import Image
print("βœ… PIL (Pillow) is available!")
# Create a test image
img = Image.new('RGB', (200, 100), color='white')
img.save('test_image.png')
print("βœ… Can create and save images!")
# Test if we can load it back
test_img = Image.open('test_image.png')
print(f"βœ… Test image size: {test_img.size}")
return True
except ImportError:
print("❌ PIL (Pillow) not installed")
return False
except Exception as e:
print(f"❌ Error: {e}")
return False
def show_next_steps():
"""Show what to do next"""
print("\n" + "🎯 NEXT STEPS:")
print("-" * 30)
print("1. Your environment is working!")
print("2. To use AI models, they need to download (~1.3GB)")
print("3. This happens automatically on first use")
print("4. Here's how to start:")
print()
print("METHOD 1 - Simple Test:")
print(" python quick_test.py")
print()
print("METHOD 2 - Full Scanner:")
print(" python singtel_scanner.py")
print()
print("METHOD 3 - Manual Installation:")
print(" Run: install_and_test.bat")
print()
def demonstrate_text_processing():
"""Show how text processing would work"""
print("\n" + "πŸ“ TEXT PROCESSING DEMO:")
print("-" * 35)
# Simulate extracted text from a bill
sample_bill_text = """
SINGTEL MOBILE SERVICES
Account Number: 123-456-789
Bill Period: 01/06/2025 to 30/06/2025
Monthly Subscription: $45.90
Data Usage: $12.30
Voice Calls: $8.50
SMS: $2.10
Total Amount Due: $68.80
Due Date: 15/07/2025
Thank you for choosing Singtel!
"""
print("Sample extracted text:")
print(sample_bill_text)
# Simple parsing example
import re
# Extract account number
account_match = re.search(r'Account Number:\s*([0-9-]+)', sample_bill_text)
account = account_match.group(1) if account_match else "Not found"
# Extract total amount
total_match = re.search(r'Total Amount Due:\s*\$([0-9.]+)', sample_bill_text)
total = total_match.group(1) if total_match else "Not found"
# Extract due date
due_match = re.search(r'Due Date:\s*([0-9/]+)', sample_bill_text)
due_date = due_match.group(1) if due_match else "Not found"
print("\n" + "πŸ” EXTRACTED INFORMATION:")
print(f" Account Number: {account}")
print(f" Total Amount: ${total}")
print(f" Due Date: {due_date}")
if __name__ == "__main__":
# Test basic functionality
if test_basic_functionality():
print("\n" + "βœ… SUCCESS! Your environment is ready!")
# Show text processing demo
demonstrate_text_processing()
# Show next steps
show_next_steps()
print("\n" + "πŸ’‘ TIP: The AI models will download automatically")
print("when you first run the scanner. Be patient!")
else:
print("\n" + "❌ SETUP NEEDED!")
print("Run this command to install required packages:")
print("pip install Pillow")
print("\n" + "πŸŽ‰ Ready to scan Singtel bills!")
input("Press Enter to continue...")