Spaces:
Sleeping
Sleeping
#!/usr/bin/env python3 | |
""" | |
Test script for the formatting tools. | |
This script demonstrates the usage of FormatAnalysisResultsTool with sample lyrics analysis. | |
""" | |
from tools.formatting_tools import FormatAnalysisResultsTool | |
# Sample lyrics analysis in JSON format | |
SAMPLE_ANALYSIS = { | |
"summary": "This song explores themes of isolation, introspection, and the search for meaning in a chaotic world. It combines melancholic imagery with moments of hope and resilience.", | |
"main_themes": ["Isolation", "Self-discovery", "Resilience", "Nature as metaphor"], | |
"mood": "Melancholic yet hopeful", | |
"sections_analysis": [ | |
{ | |
"section_type": "verse", | |
"section_number": 1, | |
"lines": [ | |
"Walking alone through empty streets", | |
"The silence echoes what my heart repeats", | |
"Shadows dance across the walls", | |
"As night descends and darkness calls" | |
], | |
"analysis": "The opening verse establishes the solitary mood through imagery of empty streets and silence. The speaker appears to be in a state of introspection, with external elements (shadows, darkness) reflecting their internal emotional state." | |
}, | |
{ | |
"section_type": "chorus", | |
"section_number": 1, | |
"lines": [ | |
"But I'll keep moving forward", | |
"Even when the path is unclear", | |
"There's strength in the journey", | |
"And meaning in the tears" | |
], | |
"analysis": "The chorus shifts to a more resilient tone, introducing the central theme of perseverance despite uncertainty. It suggests that the process of struggling itself has value, contrasting with the melancholy of the verse." | |
}, | |
{ | |
"section_type": "verse", | |
"section_number": 2, | |
"lines": [ | |
"The morning light breaks through the clouds", | |
"Illuminating what was hidden in shrouds", | |
"Each step I take leaves footprints behind", | |
"Marking the path for others to find" | |
], | |
"analysis": "The second verse introduces imagery of dawn and light, symbolizing hope and clarity emerging from darkness. There's a suggestion that the speaker's personal journey might serve as guidance for others, adding a layer of purpose to their struggles." | |
} | |
], | |
"significant_lines": [ | |
{ | |
"line": "There's strength in the journey, And meaning in the tears", | |
"significance": "This line encapsulates the central message of finding value in difficult experiences and emotional pain." | |
}, | |
{ | |
"line": "Each step I take leaves footprints behind, Marking the path for others to find", | |
"significance": "This suggests that personal struggles can have broader meaning by helping others navigate similar challenges." | |
} | |
], | |
"conclusion": "The song ultimately presents a nuanced view of personal struggle, suggesting that periods of isolation and difficulty are not merely obstacles to overcome but meaningful parts of human experience. Through its imagery of darkness giving way to light, it offers a message of hope without dismissing the reality of pain." | |
} | |
def test_rich_formatting(): | |
"""Test the rich formatting output.""" | |
formatter = FormatAnalysisResultsTool() | |
rich_output = formatter.forward(SAMPLE_ANALYSIS, pretty=True) | |
print("\n=== RICH FORMATTING OUTPUT ===\n") | |
print(rich_output) | |
return rich_output | |
def test_simple_formatting(): | |
"""Test the simple text formatting output.""" | |
formatter = FormatAnalysisResultsTool() | |
simple_output = formatter.forward(SAMPLE_ANALYSIS, pretty=False) | |
print("\n=== SIMPLE TEXT FORMATTING OUTPUT ===\n") | |
print(simple_output) | |
return simple_output | |
if __name__ == "__main__": | |
print("Testing FormatAnalysisResultsTool with sample lyrics analysis...") | |
# Test both formatting options | |
rich_result = test_rich_formatting() | |
simple_result = test_simple_formatting() | |
print("\nFormatting test completed successfully!") | |