simple-text-analyzer / test /test_actual_issue.py
egumasa's picture
initialize app
a543e33
#!/usr/bin/env python3
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), 'backend'))
from lexical_sophistication import LexicalSophisticationAnalyzer
def test_actual_issue():
"""Test the actual issue with multiple configurations."""
print("Testing the actual issue with multiple configurations...")
# Simulate what happens in the frontend
reference_lists = {
'test_freq': {
'token': {
'file_path': 'nonexistent.csv', # This might be the issue
'word_column': 'Type',
'freq_column': 'Freq',
'delimiter': ',',
'is_custom_config': True
}
},
'test_range': {
'token': {
'file_path': 'nonexistent.csv', # Same file path
'word_column': 'Type',
'freq_column': 'Range',
'delimiter': ',',
'is_custom_config': True
}
}
}
print(f"Reference lists: {list(reference_lists.keys())}")
analyzer = LexicalSophisticationAnalyzer()
try:
analyzer.load_reference_lists(reference_lists)
print("βœ“ Load succeeded")
loaded_indices = list(analyzer.reference_lists.keys())
print(f"Loaded indices: {loaded_indices}")
# Check if all indices were loaded
for index_name in reference_lists.keys():
if index_name in analyzer.reference_lists:
token_data = analyzer.reference_lists[index_name].get('token', {})
print(f"βœ“ {index_name}: {len(token_data)} entries")
else:
print(f"βœ— {index_name}: not loaded")
except Exception as e:
print(f"βœ— Error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_actual_issue()