Spaces:
Sleeping
Sleeping
Enhance paper loading and searching functionality by adding filename normalization, improved matching logic, and structured summaries. The system now prioritizes full paper content in responses and includes detailed sections like abstract, introduction, methodology, results, and conclusions in summaries. Updated user prompts to reflect new capabilities.
58c21ea
| #!/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!") |