#!/usr/bin/env python3 """ Simple test for WordNet clue generator functionality. Tests basic clue generation without heavy initialization. """ import sys from pathlib import Path # Add hack directory to path sys.path.insert(0, str(Path(__file__).parent)) def test_basic_wordnet(): """Test basic WordNet functionality.""" print("๐Ÿงช Basic WordNet Test") print("=" * 30) try: import nltk from nltk.corpus import wordnet as wn print("โœ… NLTK and WordNet imported") # Test basic synset lookup test_words = ['cat', 'computer', 'run'] for word in test_words: synsets = wn.synsets(word) print(f"\n๐Ÿ“ '{word}': {len(synsets)} synsets") if synsets: # Show first synset info first = synsets[0] print(f" Definition: {first.definition()}") print(f" Examples: {first.examples()[:1]}") # Show synonyms synonyms = [lemma.name().replace('_', ' ') for lemma in first.lemmas()[:3]] print(f" Synonyms: {synonyms}") # Show hypernyms (categories) hypernyms = [hyp.lemmas()[0].name().replace('_', ' ') for hyp in first.hypernyms()[:2]] print(f" Categories: {hypernyms}") return True except Exception as e: print(f"โŒ Error: {e}") return False def test_clue_generation_simple(): """Test simple clue generation logic.""" print("\n๐ŸŽฏ Simple Clue Generation Test") print("=" * 35) try: from nltk.corpus import wordnet as wn test_words = ["dog", "computer", "guitar"] for word in test_words: synsets = wn.synsets(word) if synsets: # Test definition-based clue definition = synsets[0].definition() print(f"\n{word.upper()}: {definition}") # Simple clue processing - avoid target word in definition clue = definition.lower() if word.lower() not in clue: clue = clue.capitalize() if len(clue) > 50: clue = clue[:47] + "..." print(f"Generated clue: {clue}") else: print(f"Skipped (contains target word)") return True except Exception as e: print(f"โŒ Clue generation error: {e}") return False def main(): """Run simple tests.""" print("๐Ÿš€ WordNet Simple Test Suite") print("=" * 40) # Test basic functionality basic_ok = test_basic_wordnet() if basic_ok: # Test clue generation clue_ok = test_clue_generation_simple() if clue_ok: print("\nโœ… Basic WordNet functionality working!") print("๐Ÿ’ก Ready to test full WordNet clue generator") else: print("\nโš ๏ธ Basic WordNet works, but clue generation needs work") else: print("\nโŒ WordNet not working properly") print("๐Ÿ’ก Try: pip install nltk, then python -c 'import nltk; nltk.download(\"wordnet\")'") return basic_ok and clue_ok if __name__ == "__main__": main()