Simple npm package that contains utilities for Chinese idioms or Chengyu. Functions available right now are for Chinese idioms solitaire or Chengyu Jielong. More functions will be added in the future versions!
Installation
npm install chinese-idioms-chengyu
Usage
Solitaire Functions
Name
Params
Description
Error handling
nextIdiomsWithMatchingCharacter
idiomWord - String of Chinese characters of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin
Returns a list of idiom word-pinyin-pairs, words, or pinyin that have idioms where the first character is the same as the last character of the parameter idiomWord.
Throw an error when idiomWord does not exist.
nextIdiomsWithMatchingTonePinyin
idiomWord - String of Chinese characters of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin
Returns a list of idiom word-pinyin-pairs, words, or pinyin that have idioms where the pinyin of the first character is the same as the pinyin of the last character of the parameter idiomWord.
Throw an error when idiomWord does not exist.
nextIdiomsWithMatchingNoTonePinyin
idiomWord - String of Chinese characters of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin
Returns a list of idiom word-pinyin-pairs, words, or pinyin that have idioms where the pinyin of the first character is the same as the pinyin of the last character of the parameter idiomWord disregarding the tone.
Throw an error when idiomWord does not exist.
Search Functions
Name
Params
Description
Error handling
startWithCharacter
character - String of first character of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin
Return a list of idiom word-pinyin-pairs, word, or pinyin that starts with the parameter character.
Throw an error when options is not valid.
startWithTonePinyin
pinyin - String of pinyin of first character of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin
Return a list of idiom word-pinyin-pairs, word, or pinyin that starts with the parameter pinyin.
Throw an error when options is not valid.
startWithNoTonePinyin
noTonePinyin - String of no tone pinyin of first character of the idiom options - return idioms as word-pinyin-pairs, words, or pinyin
Return a list of idiom word-pinyin-pairs, word, or pinyin that starts with the parameter noTonEpinyin.
Throw an error when options is not valid.
getDefinition
idiomWord - String of idiom word
Return the definition of the parameter idiomWord
Throw an error when idiomWord does not exist.
Options
Name
Type
Default value
Description
word
Boolean
true
Whether returned idioms include the string of words
pinyin
Boolean
true
Whether returned idioms include the string of pinyin