Click here to Skip to main content
15,890,512 members
Articles / Programming Languages / C#

Rhyming Assist

Rate me:
Please Sign up or sign in to vote.
4.29/5 (4 votes)
13 Feb 2015CPOL2 min read 16.5K   279   3   2
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Canada Canada
I'm a graduate of the University of Toronto with a degree in zoology. I'm currently a software development manager with a large Canadian financial institution, and a passionate squash player.

I am a proud daddy to Alex and Sarah.

Comments and Discussions

 
GeneralMy vote of 4 Pin
Afzaal Ahmad Zeeshan4-May-15 22:48
professionalAfzaal Ahmad Zeeshan4-May-15 22:48 
QuestionNice Pin
lespauled17-Feb-15 5:03
lespauled17-Feb-15 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.