Let's say I have a database that contains 200,000 lines of poetry, and I want to randomly combine those lines in ways that generate grammatically correct and legible 3-line poems.
Is there a way to do that? I'm currently experimenting with language_tool_python but it's only helping with general spelling and a few formatting suggestions. I'm looking for something that will ensure that every 3-line poem assembled reads properly and makes grammatical sense.
For example, here's a three line array containing a poem generated by my current code base:
['OVER THE SEA, THE SEA HIS ROD OBEYS', 'IS DEAD', 'BUT LET MY LAST DAYS BE MY BEST']
I'd like to find a solution that allows me to detect that this poem isn't acceptable because it doesn't make grammatical sense to have "IS DEAD" coming after "OVER THE SEA, THE SEA HIS ROD OBEYS".
Another example of a poem I'd like to automatically detect as invalid:
['THERE NEVER LACKS A BONE OF THE BEST', 'BUT CRUEL IS SHE', 'THEN MAY YOUR QUEEN']
I need to solve this problem client-side; I can't use any online API-as-a-service.
Thanks in advance for any suggestions!