File size: 3,429 Bytes
486eff6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/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()