Analyze a text file to detect rhymes between line-ending words, build a network from those relationships and visualize the resulting structure with D3.
This application analyzes a plain text document to identify rhyme relationships between the final words of each line. It uses the CMU Pronouncing Dictionary to compare phonetic rhyme endings, while also accounting for stress patterns, word frequency, repeated positions and fallback spelling-based similarity when pronunciation data is unavailable.
The resulting words are represented as nodes in a rhyme network, with connections weighted by rhyme strength. The application exports this structure as JSON, with optional GraphML and GEXF support, as well as visualizes it through an interactive D3 graph where users can explore rhyme families, clusters, repetitions and relationships across the source text.
Below are the required software programs and instructions for installing and using this application on a Linux machine.
-
Install the above programs
-
Open a terminal
-
Clone this repository:
git clone git@github.com:devbret/networked-rhyming-words.git -
Navigate to the repo's directory:
cd networked-rhyming-words -
Create a virtual environment:
python3 -m venv venv -
Activate your virtual environment:
source venv/bin/activate -
Install the required Python packages:
pip install -r requirements.txt -
Place your
.txtfile at the root of this repo -
Process the raw data:
python3 app.py -i my_file_name.txt -
Start an HTTP server:
python3 -m http.server -
Access the visualization in a browser:
http://localhost:8000 -
When finished, close the HTTP server:
CTRL + c -
Exit the virtual environment:
deactivate
Below you will find information not covered in the installation and use sections above. Including the abilities this repo is intended to demonstrate. As well as an overview of the license this code is made available with. And a way to contact the maintainer with questions, suggestions and collaboration opportunities.
This project repo is intended to demonstrate an ability to do the following:
-
Analyze song lyrics to identify rhyming words and convert them into an interactive network graph
-
Detect rhyme relationships between line-ending words using pronunciation data and stress patterns
-
Export rhyme data as JSON, with optional GraphML and GEXF formats
-
Visualize rhyme families with D3.js, allowing users to explore connected rhyme clusters
This repository is distributed under the MIT License. You are free to use, copy, modify, merge, publish, distribute, sublicense and sell copies of this software, including as part of proprietary or commercial work. The single condition is the copyright and permission notices contained in the LICENSE file must be included with any copy or substantial portion of the software that you redistribute. The software is provided "as is", without warranty of any kind, and the copyright holder is not liable for any claim or damages arising from its use.
If you have any questions or would like to collaborate, please reach out either on GitHub or via my website.
