Spaces:
Sleeping
Sleeping
| """ | |
| Quick test to verify the enhanced T5 title generator works correctly | |
| """ | |
| import sys | |
| import os | |
| # Add the parent directory to the path | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from title_generator import extract_keywords, score_repo_name, generate_title_with_t5 | |
| # Test 1: Keyword Extraction | |
| print("=" * 60) | |
| print("TEST 1: Keyword Extraction") | |
| print("=" * 60) | |
| text = "Creative Digital Designer focusing on minimalist UI/UX and motion graphics. I transform complex problems into beautiful, intuitive interfaces." | |
| keywords = extract_keywords(text, max_keywords=5) | |
| print(f"Input: {text[:80]}...") | |
| print(f"Keywords: {keywords}") | |
| print() | |
| # Test 2: Quality Scoring | |
| print("=" * 60) | |
| print("TEST 2: Quality Scoring") | |
| print("=" * 60) | |
| test_names = [ | |
| "creative-designer-portfolio", | |
| "website-project-app", | |
| "creative-digital-designer-minimalist-ui-ux-motion-graphics-portfolio", | |
| "ai-analytics-platform", | |
| "premium-leather-goods-shop" | |
| ] | |
| for name in test_names: | |
| score = score_repo_name(name) | |
| words = len(name.split('-')) | |
| chars = len(name) | |
| print(f"{name:60} | Score: {score:3} | Words: {words} | Chars: {chars}") | |
| print() | |
| # Test 3: T5 Generation (if model is loaded) | |
| print("=" * 60) | |
| print("TEST 3: T5 Title Generation") | |
| print("=" * 60) | |
| try: | |
| test_text = "Creative Digital Designer focusing on minimalist UI/UX and motion graphics. I transform complex problems into beautiful, intuitive interfaces. Over five years of experience working with global brands." | |
| title_tag = "Modern Photography Portfolio" | |
| print(f"Title Tag: {title_tag}") | |
| print(f"Content: {test_text[:100]}...") | |
| print("\nGenerating repository name...") | |
| result = generate_title_with_t5(test_text, title_tag) | |
| if result: | |
| score = score_repo_name(result) | |
| words = len(result.split('-')) | |
| chars = len(result) | |
| print(f"\n✅ Generated: {result}") | |
| print(f" Score: {score}/100") | |
| print(f" Words: {words}") | |
| print(f" Chars: {chars}") | |
| else: | |
| print("❌ No result generated") | |
| except Exception as e: | |
| print(f"⚠️ T5 model not loaded or error: {e}") | |
| print(" (This is expected if running without the model)") | |
| print() | |
| print("=" * 60) | |
| print("All tests completed!") | |
| print("=" * 60) | |