Skip to content

Rhyme.js is a small javascript library that can detect different rhyming styles between 2 words.

License

Notifications You must be signed in to change notification settings

foobar404/rhyme.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rhyme.js

small javascript library for testing if 2 words rhyme

Installation

CDN

<script src="https://cdn.jsdelivr.net/gh/foobar404/rhyme.js/js/rhyme.js"></script>

Local file

download /js/rhyme.js and include it in your project

Example

let r = new Rhyme();
let result = r.rhymesWith("can","man");

if(result.rhymes)
  alert("these words rhyme");

Docs

Functions

  • rhymesWith(word1, word2, options(optional))
    • word1 & word2 are the strings you want to compare
    • options is a object with optinal properties
      • mode
        • strict : only match rhyme schemes with obvious rhymes(default)
        • loose : match all known rhyming patterns
    • return value is a object with two properties
      • types : an array of the types of rhymes that matched
      • rhymes : a boolean value thats true if a rhyme was found
  • assonant(word1,word2)
    • this is the rhyming of vowels in words but with different consonants
    • return value is a boolean, retuns true if match was found
  • consonant(word1,word2)
    • this is the rhyming of consonants but not vowels
    • return value is a boolean, retuns true if match was found
  • eye(word1,word2)
    • the rhyming in this type is based on spelling and not sound
    • return value is a boolean, retuns true if match was found
  • feminine(word1,word2)
    • also referred to as double, triple, multiple, extra-syllable, extended, this has different beginnings of the words, but rhymes latter syllables
    • return value is a boolean, retuns true if match was found
  • head(word1,word2)
    • also called alliteration or initial rhyme, this has the same initial consonant at the beginning of the words
    • return value is a boolean, retuns true if match was found
  • identical(word1,word2)
    • this is rhyming a word with itself, but often refers to a different meaning
    • return value is a boolean, retuns true if match was found
  • near(word1,word2)
    • also referred to as half, slant, approximate, off, and oblique, this rhymes the final consonants but not the vowels or initial consonants
    • return value is a boolean, retuns true if match was found
  • syllabic(word1,word2)
    • rhyming the last syllable, this is also called tail or end rhyme
    • return value is a boolean, retuns true if match was found
  • masculine(word1,word2)
    • in this rhyme, the stress in on the final syllable in both words
    • return value is a boolean, retuns true if match was found
  • perfect(word1,word2)
    • sometimes called exact, full or true, this rhyme is the typical rhyme where the ending sounds match
    • return value is a boolean, retuns true if match was found

Utility functions

  • getSyllables(word)
    • return value is an array of the word seperated into syllables (90% accuracy)

About

Rhyme.js is a small javascript library that can detect different rhyming styles between 2 words.

Topics

Resources

License

Stars

Watchers

Forks