- introduce `LyricFlow.Core.Backend` with shared DTOs, rhyme/spellcheck engines, and REST endpoints - wire Python GUI/core to run and call the backend via new bridge/client modules - add backend parity/integration tests and update packaging/ignore settings
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
import sys
|
|
import os
|
|
import time
|
|
import requests
|
|
|
|
# Add project root to sys.path
|
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
sys.path.insert(0, project_root)
|
|
|
|
from src.lyricflow_core.engine.rhyme_engine import RhymeEngine
|
|
|
|
def test_engine_direct():
|
|
engine = RhymeEngine()
|
|
|
|
print("Testing existing backend on port 5000...")
|
|
if not engine.bridge.is_alive():
|
|
print("Backend is NOT alive!")
|
|
return
|
|
|
|
# 2. Test Syllables
|
|
print("\nTesting syllable counting...")
|
|
words = ["rap", "lyrical", "gravitation", "sky"]
|
|
for w in words:
|
|
syl = engine.count_syllables(w)
|
|
print(f"'{w}': {syl} syllables")
|
|
|
|
# 3. Test Rhyme Suggestions
|
|
print("\nTesting rhyme suggestions...")
|
|
test_word = "flow"
|
|
rhymes = engine.find_suggestions(test_word)
|
|
print(f"Rhymes for '{test_word}': {len(rhymes['perfect'])} perfect, {len(rhymes['slant'])} slant")
|
|
if rhymes['perfect']:
|
|
print(f"Perfect example: {rhymes['perfect'][0]}")
|
|
|
|
# 4. Test Line Densities (Heavy processing)
|
|
print("\nTesting line density batch processing...")
|
|
test_text = """
|
|
I'm the lyrical miracle, spiritual individual
|
|
In the physical world, it's getting critical
|
|
My rhymes are mystical, highly statistical
|
|
You're just typical, completely satirical
|
|
"""
|
|
start_time = time.time()
|
|
densities = engine.get_line_densities(test_text)
|
|
end_time = time.time()
|
|
|
|
print(f"Line densities: {[round(d, 2) for d in densities]}")
|
|
print(f"Processing time (Batch C#): {end_time - start_time:.4f}s")
|
|
|
|
if __name__ == "__main__":
|
|
test_engine_direct()
|