npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mandarin-rhymes

v1.0.2

Published

A rhyming dictionary tool for Mandarin Chinese

Downloads

10

Readme

Mandarin Rhymes

A rhyming dictionary tool for Mandarin Chinese

Background

Given a search phrase comprised of Chinese Characters, finds a list of rhyming words from entries in the CC-CEDICT. Rhyming is determined using the final vowel sound of each syllable in the word. Additionally, an option is provided to find only rhyming words which also match the tones of the search phrase.

Install

$ npm install --save mandarin-rhymes

Usage

const MandarinRhymes = require('mandarin-rhymes')
var rhyme = new MandarinRhymes('能力');

Without Tone Matching

rhyme.getRhymes().then(console.log);
/*
{
  "self": {
    "simplified": "能力",
    "traditional": "能力",
    "pinyin": "néng lì",
    "zhuyinArray": ["ㄋㄥˊ", "ㄌㄧ`"],
    "definitions": ["capability", "ability", "CL:個|个[ge4]"],
    "toneNumberArray": ["2", "4"],
    "averageFrequency": 70.5
  },
  "rhymes": [{
    "simplified": "争气",
    "traditional": "爭氣",
    "pinyin": "zhēng qì",
    "zhuyinArray": ["ㄓㄥ", "ㄑㄧ`"],
    "definitions": ["to work hard for sth", "to resolve on improvement", "determined not to fall short"],
    "toneNumberArray": ["1", "4"],
    "averageFrequency": 70.5
  }...]
}
*/

With Tone Matching

rhyme.withToneMatching().getRhymes().then(console.log);
/*
{
  "self": {
    "simplified": "能力",
    "traditional": "能力",
    "pinyin": "néng lì",
    "zhuyinArray": ["ㄋㄥˊ", "ㄌㄧ`"],
    "definitions": ["capability", "ability", "CL:個|个[ge4]"],
    "toneNumberArray": ["2", "4"],
    "averageFrequency": 70.5
  },
  "rhymes": [{
    "simplified": "乘隙",
    "traditional": "乘隙",
    "pinyin": "chéng xì",
    "zhuyinArray": ["ㄔㄥˊ", "ㄒㄧ`"],
    "definitions": ["to seize an opportunity", "to exploit (a loophole)"],
    "toneNumberArray": ["2", "4"],
    "averageFrequency": 70.5
  }...]
}
*/

API

const MandarinRhymes = require('mandarin-rhymes')

Constructor

MandarinRhymes(hanzi)

Constructs a MandarinRhymes object using the given hanzi as a search phrase. hanzi must consist only of Chinese characters.

Methods

getRhymes()

Returns an array of objects representing words that rhyme with the hanzi passed to the constructor, sorted by averageFrequency in ascending order Each object has the following fields:

  • simplified: The Simplified Chinese characters for the word
  • traditional: The Traditional Chinese characters for the word
  • pinyin: The pinyin for the word given with diacritic tone markings
  • zhuyinArray: An array of the zhuyin for each syllable of the word with tone markings
  • definitions: An array of definitions for the word
  • toneNumberArray: An array of Tone Numbers
  • averageFrequency: An average of the frequency rank of each of the characters in the word, where a lower rank corresponds to a more frequently used word
withMatchingTones()

Flags the next call to getRhymes() to only return words which match the tones of the hanzi passed to the constructor.