Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Rhyming Assist

0.00/5 (No votes)
13 Feb 2015 1  
A library to help with finding rhyming words.

Image 1

Image 1. What rhymes with "list"? Ah yes, "missed". My new and totally original opera is coming along nicely...

Introduction

This is my entry into the Code Project Valentine's Day coding contest.

Wait, there's no contest? Well, there should be.

Anyway, if you're a frustrated lyricist who wants to write a Grammy award winning song, or you're going to write a poem to do some wooing for Valentine's Day, you probably do a lot of web lookups for rhymes. These projects can help you with that.

The Code

The solution is separated into two projects: RhymeLib.dll and PoetsFriend.exe.

Rhymelib interfaces with a rhyming web service at RhymeBrain.com to get the rhymes for a given word. Calling the static method RhymingWords.GetRhymes(string) for a novel word triggers an HTTP request to the web service which returns some JSON that contains a list of words that rhyme with your word (to varying degrees of fidelity). You can read about the web service here.

RhymedWord is a class to parse the JSON and contain the properties of the rhymed work returned from the web service. It parses out all of the properties returned, though the application currently only cares about the word and its score.

When the HTTP results are parsed the app caches the rhymed words to a local text file to prevent subsequent network trips. I think it's unlikely new words are going to be added to the dictionary that rhyme with words you've looked up so caching seems like a safe strategy. Calls to RhymingWords.GetRhymes(string) always check for local results before imposing on the web service.

Rhymelib also contains a control that extends a regular Textbox called RhymeAssistTextbox. This textbox causes itself to be multiline, with both scrollbars, and includes code to manage its context menu closely. When you right click after highlighting a word it creates a ContextMenu of rhyming words via RhymingWords.GetRhymes(string). If the user selects one of the menu items it's placed on the clipboard for pasting into your opus.

PoetsFriend.exe is a thin WinForm wrapper around RhymeAssistTextbox that adds the ability to open and save text files of your documents, fiddle with fonts and presents an About form to satisfy the licencing requirements of the web service.

Conclusion

If you want to make your poetry less Vogonish, these are the tools to use. If you actually win a Grammy with a song written with the help of this app you have to mention me in your acceptance speech.

History

  • <code>Feb 13 2015 - Initial revision

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here