Word::Rhymes - Takes a word and fetches rhyming matches from RhymeZone.com
This distribution has installed a pre-written binary application for ease of use. Please see the rhyme documentation for full details.
Provides the ability to fetch words that rhyme with a word, while allowing for context if desired (eg. find all words that rhyme with baseball that relate to breakfast).
Ability to change sort order, minimum rhyme match score, maximum number of words returned etc.
use Word::Rhymes; my $wr = Word::Rhymes->new; # Simply display the output $wr->print('disdain', 'farm'); # Print all matching rhyming words that have three syllables my $rhyming_words = $wr->fetch('disdain'); print "$_\n" for @{ $rhyming_words->{3} }; # With context (rhymes with 'disdain', but only words relating to 'farm') $rhyming_words = $wr->fetch('disdain', 'farm');
A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.
Instantiates and returns a new Word::Rhymes object.
Parameters
All parameters are passed in within a hash, and are every one of them optional.
The parameters have an associated setter/getter method, so to see details for each parameter, follow through to the relevant method documentation.
file => $filename
Used mainly for testing. Allows you to re-use existing, saved data. See "file".
max_results => $integer
Sets the maximum number of rhyming words that'll be fetched over the Internet. See "max_results".
min_score => $integer
We ignore rhyming words with a score less than what you set here. See "min_score".
min_syllables => $integer
Ignore rhyming words with less than the set number of syllables. See "min_syllables".
multi_word => $bool
By default, we ignore rhyming "words" that have more than one word (ie. a phrase). You can use this parameter to include them. See "multi_word".
return_raw => $bool
Set to true to get returned via "fetch" the data prior to all filtering and manipulation taking place. Used primarily for development and testing. See "return_raw".
sort_by => $string
Sort by score_desc (default), score_asc, alpha_asc or alpha_desc. See "sort_by".
score_desc
score_asc
alpha_asc
alpha_desc
Returns: Word::Rhymes object.
Performs the fetching of the rhyming words.
$word
Mandatory, String: The word that'll be used to find rhyming matches to.
$context
Optional, String: This word is used to surround the rhyming words with context. For example, if $word is animal and $context is zoo, we'll fetch words that rhyme with animal but that are only related to a zoo somehow.
animal
zoo
Returns: A hash reference where the keys are the number of syllables in the rhyming words, and the values are array reference with the ordered data structure containing the word, the number of syllables and the score.
This method will display to the screen instead of returning results which is what "fetch" is used for.
Returns: 0 upon success.
Used primarily for development and testing, allows you to skip fetching results from the Internet, and instead fetches the data from a pre-saved file.
$file
Optional, String: The name of a pre-existing file.
Default: Empty string.
Returns: The name of the file if set, empty string otherwise.
Sets the maximum number of rhyming words to fetch over the Internet.
$max
Optional, Integer: An integer in the range of 1-1000.
Default: 1000
Returns: Integer, the currently set value.
We will only return rhyming words with a score higher than the number set here.
$min
Optional, Integer: An integer in the range of 0-1000000.
Default: 0
We will only return rhyming words with a syllable count equal to or higher than the number set here.
Optional, Integer: An integer in the range of 1-100 (yeah, I haven't heard of a word with 100 syllables either, but I digress).
Default: 1
Some rhyming words are actually multi-word phrases. By default, we skip over these. Set this to a true value to have the multi worded rhyming words included in the results.
$bool
Optional, Bool: Set to true to include multi-words, and false to skip over them.
Default: 0 (false)
Returns: Bool, the currently set value.
Used primarily for development and testing. Set to true to have "fetch" return the results as they were received, prior to any other processing.
Optional, Bool: Set to true to have the results returned before any processing occurs.
This method allows you to modify the sorting of the rhyming words prior to them being returned.
$sort_order
Optional, String: The values for the parameter are as such:
The rhyming words will be sorted according to score, in a descending order (ie. highest to lowest). This is the default.
Return the rhyming words in ascending score order (ie. lowest to highest).
Return the rhyming words in alphabetical descending order (ie. a-z).
Return the rhyming words in alphabetical ascending order (ie. z-a).
Default: score_desc (0x00).
Returns: Integer, the currently set value:
score_desc: 0x00 score_asc: 0x01 ascii_desc: 0x02 ascii_asc: 0x03
Steve Bertrand, <steveb at cpan.org>
<steveb at cpan.org>
Copyright 2020 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
To install Word::Rhymes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Word::Rhymes
CPAN shell
perl -MCPAN -e shell install Word::Rhymes
For more information on module installation, please visit the detailed CPAN module installation guide.