File size: 2,321 Bytes
58c21ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to verify the paper loading and matching functionality.
"""

import os
import sys

# Add the current directory to the path so we can import from app.py
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

# Import the functions from app.py
from app import load_paper_texts, find_matching_paper_file, normalize_filename

def test_paper_loading():
    """Test that papers are loaded correctly."""
    print("Testing paper loading...")
    
    papers = load_paper_texts()
    print(f"Loaded {len(papers)} papers")
    
    if papers:
        print("Sample paper filenames:")
        for i, filename in enumerate(list(papers.keys())[:5]):
            print(f"  {i+1}. {filename}")
    
    return papers

def test_filename_matching():
    """Test the filename matching functionality."""
    print("\nTesting filename matching...")
    
    papers = load_paper_texts()
    if not papers:
        print("No papers loaded, skipping test")
        return
    
    # Test cases
    test_queries = [
        "pigs",
        "AI companions",
        "labor market",
        "generative AI",
        "chatgpt",
        "large language models"
    ]
    
    for query in test_queries:
        print(f"\nQuery: '{query}'")
        matching_file = find_matching_paper_file(query.split(), papers)
        if matching_file:
            print(f"  Matched: {matching_file}")
        else:
            print("  No match found")

def test_normalize_filename():
    """Test the filename normalization function."""
    print("\nTesting filename normalization...")
    
    test_filenames = [
        "The Labor Market Effects of Generativ.txt",
        "AI Companions Reduce Loneliness.txt",
        "WHEN PIGS GET SICK MULTI-AGENT AI.txt",
        "Your Brain on ChatGPT Accumulation o.txt"
    ]
    
    for filename in test_filenames:
        normalized = normalize_filename(filename)
        print(f"  '{filename}' -> '{normalized}'")

if __name__ == "__main__":
    print("Testing Paperbot functionality...")
    print("=" * 50)
    
    # Test paper loading
    papers = test_paper_loading()
    
    # Test filename normalization
    test_normalize_filename()
    
    # Test filename matching
    test_filename_matching()
    
    print("\n" + "=" * 50)
    print("Testing completed!")