Home

Awesome

Chinese Lexicon

This repository is a lexicon of Chinese combining the following features:

It can be installed using npm:

npm install chinese-lexicon

This project was built for and is used by Dong Chinese.

Methods

getEntries(word)

Returns an array of dictionary entries for a Chinese word.

> getEntries("觉")
[
    {
        simp: '觉',
        trad: '覺',
        definitions: ['to feel', 'to find that', 'thinking', 'awake', 'aware'],
        pinyin: 'jué',
        searchablePinyin: 'jue',
        simpEtymology: {
            notes: 'Phonosemantic compound. 见 represents the meaning and 学 represents the sound. Simplified form of 學.  Only the top part of 学 is used, which prevents the character from being too crowded.',
            definition: 'think; perceive; sleep',
            components: [/* ... */]
        },
        tradEtymology: {
            notes: 'Phonosemantic compound. 見 represents the meaning and 學 represents the sound. Only the top part of 學 is used, which prevents the character from being too crowded.',
            definition: 'think; perceive; sleep',
            components: [/* ... */]
        },
        statistics: {
            hskLevel: 1,
            movieWordCount: 1125,
            movieWordCountPercent: 0.00003353552422552613,
            movieWordRank: 2200,
            movieWordContexts: 880,
            movieWordContextsPercent: 0.14095787281755567,
            bookWordCount: 1408448,
            bookWordCountPercent: 0.00008505090178761059,
            bookWordRank: 1714,
            movieCharCount: 81155,
            movieCharCountPercent: 0.001732559764772375,
            movieCharRank: 93,
            movieCharContexts: 6180,
            movieCharContextsPercent: 0.9899086977414705,
            bookCharCount: 132041,
            bookCharCountPercent: 0.0006823682596606341,
            bookCharRank: 327,
            pinyinFrequency: 1032
        }
    },
    {
        simp: '觉',
        trad: '覺',
        definitions: ['a nap', 'a sleep', 'CL:場|场[cháng]'],
        pinyin: 'jiào',
        searchablePinyin: 'jiao',
        simpEtymology: {
            // ...
        },
        tradEtymology: {
            // ...
        },
        statistics: {
            // ...
        }
    }
]

An entry object can have the following properties:

getEtymology(character)

Returns the etymology of a character.

> getEtymology("妈")
{
    notes: 'Phonosemantic compound. 女 represents the meaning and 马 represents the sound. ',
    definition: 'mother',
    components: [{
            type: 'meaning',
            char: '女',
            fragment: [0, 3]
        },
        {
            type: 'sound',
            char: '马',
            fragment: [3]
        }
    ]
}

The etymology object can have the following properties:

getGloss(word, pinyin?)

Returns a single, short definition for a word.

> getGloss("香蕉")
"banana"

The optional pinyin argument can be used to disambiguate characters with multiple pronunciations (多音字).

> getGloss("发", "fā")
"to issue"
> getGloss("发", "fà")
"hair"

search(term, limit?)

Does a text search to find dictionary entries matching the search term (such as an English word or pinyin). The search results will be sorted based on relevance and the frequency in books and movies.

> search("hello")
[
    {
        simp: '喂',
        trad: '喂',
        definitions: ['hello (when answering the phone)'],
        pinyin: 'wéi',
        // ...
    },
    {
        simp: '你好',
        trad: '你好',
        definitions: ['hello', 'hi'],
        pinyin: 'nǐ​hǎo',
        // ...
    },
    // ...
]

The optional limit argument can be used to limit the number of search results returned.

allEntries

List of all the dictionary entries in the lexicon.