open-index/open-npm huggingface dataset:
npm package: @nahanil/bushou
Description: Work with Chinese radicals
Author: Jarrod Linahan
Latest version: 0.0.3

## @nahanil/bushou
[![pipeline status](https://git.carrotlabs.net/zhdict/bushou/badges/master/pipeline.svg)](https://git.carrotlabs.net/zhdict/bushou/pipelines)
[![coverage report](https://git.carrotlabs.net/zhdict/bushou/badges/master/coverage.svg)](http://zhdict.pages.carrotlabs.net/bushou/coverage/)
[![NPM version](https://badge.fury.io/js/@nahanil%2Fbushou.svg)](https://www.npmjs.com/package/@nahanil/bushou) &nbsp; &nbsp;

Work with Chinese radicals

```bash
npm install --save @nahanil/bushou
# or
yarn add @nahanil/bushou
```

### Find radical for a given character
nb. Returns '*' if the provided character is itself a radical
```js
let radical = rad.for('海')
// 水

let radical = rad.for('水')
// *
```

### Find radical for a given character (extended)
```js
let radical = rad.for('海', true)
/*
  {
    no: 85,
    radical: '水',
    variants: '氵',
    simplified: '',
    pinyin: 'shui3',
    english: 'water',
    strokes: 4
  }
*/
```

### Find radical by KangXi index
```js
let radical = rad.byIndex(85)
/*
  {
    no: 85,
    radical: '水',
    variants: '氵',
    simplified: '',
    pinyin: 'shui3',
    english: 'water',
    strokes: 4
  }
*/
```

### List all radicals
```js
let radicals = rad.list()
/*
  [
    // ...
    {
      no: 85,
      radical: '水',
      variants: '氵',
      simplified: '',
      pinyin: 'shui3',
      english: 'water',
      strokes: 4
    },
    // ...
  ]
*/
```
npm package: @nahanil/hsk-words
Description: HSK word list lookup
Author: Jarrod Linahan
Latest version: 0.2.2

[![pipeline status](https://git.carrotlabs.net/zhdict/hsk-words/badges/master/pipeline.svg)](https://git.carrotlabs.net/zhdict/hsk-words/pipelines)
[![coverage report](https://git.carrotlabs.net/zhdict/hsk-words/badges/master/coverage.svg)](http://zhdict.pages.carrotlabs.net/hsk-words/coverage/)
[![NPM version](https://badge.fury.io/js/@nahanil%2Fhsk-words.svg)](https://www.npmjs.com/package/@nahanil/hsk-words) &nbsp; &nbsp;

hsk-words is a "batteries-included" library for querying the Chinese Government's HSK (汉语水平考试) word list. This is a test used for university admission for foreigners in the PRC and includes 5,000 words in the list across all 6 levels.

Supports lookup by both traditional and simplified characters.

This is mostly based off John Heroy's [hsk-words](https://www.npmjs.com/package/hsk-words)

## Usage

```
var hsk = require('hsk-words');

let level = await hsk.findLevel('学习')
// -1 if not found, otherwise 1-6

// Get a list of the words at a given HSK level
let l3 = await hsk.getWordList(3)
// [ { level: 1, simplified: '学习', pinyin: 'xue2 xi2', definitions: 'to learn; to study' } ]

```

## License

MIT
npm package: @nahanil/sails-hook-api-log
Description: Terse Sails.js request logging middleware
Author: Jarrod Linahan
Latest version: 1.0.0

# @nahanil/sails-hook-api-log

Terse request logging for Sails.js applications.

Forked from Mike McNeil's pretty awesome [sails-hook-apianalytics](https://github.com/sailshq/sails-hook-apianalytics).

## Install
```
yarn add @nahanil/sails-hook-api-log
```
That's it! Next time you lift, and then send a request to the server, you should see stuff getting logged.

## Configuration
Optionally, you can customize this hook in a few different ways by configuring `sails.config['api-log]`.

For instance, you might create `config/api-log.js`:
```js
module.exports = {
  'api-log': {
    /**
     * An array of route addresses to monitor.
     *
     * (e.g. [ 'GET /foo/bar', 'POST /foo', 'all /admin/*' ])
     *
     * Defaults to logging all POST, PATCH, PUT, DELETE requests, and all
     * GET requests except for those that appear to be for assets
     * (i.e. using "GET r|^((?![^?]*\\/[^?\\/]+\\.[^?\\/]+(\\?.*)?).)*$|")
     */
    routesToLog: [
      // If you want to log everything- including requests for assets, use the following:
      '/*'
    ],

    /**
     * Custom log function
     * Uses `console.log` by default and recieves the text string that would be logged
     */
    logFn: (str) => {
      console.log(`APILOG: ${str}`)
    }
  }
}
```
npm package: @nahanil/shuo
Description: Turn things like ni3 into nǐ or ㄋㄧˇ or ni³
Author: Jarrod Linahan
Latest version: 0.0.2

## @nahanil/shuo
[![pipeline status](https://git.carrotlabs.net/zhdict/shuo/badges/master/pipeline.svg)](https://git.carrotlabs.net/zhdict/shuo/pipelines)
[![coverage report](https://git.carrotlabs.net/zhdict/shuo/badges/master/coverage.svg)](http://zhdict.pages.carrotlabs.net/shuo/coverage/)
[![NPM version](https://badge.fury.io/js/@nahanil%2Fshuo.svg)](https://www.npmjs.com/package/@nahanil/shuo) &nbsp; &nbsp;

Turn things like "ni3 hao3" into "nǐ hǎo" or "ㄋㄧˇ ㄏㄠˇ" or "ni³ hao³"

```bash
npm install --save @nahanil/shuo
# or
yarn add @nahanil/shuo
```

```js
const shuo = require('@nahanil/shuo')

shuo.convert('ni3 hao3')
// nǐ hǎo

shuo.convert('ni3 hao3', false, 'zhuyin')
// ㄋㄧˇ ㄏㄠˇ

shuo.convert('ni3 hao3', false, 'wg')
// ni³ hao³
```

```js
const shuo = require('@nahanil/shuo')

shuo.convert('ni3 hao3', true, 'pinyin')
/*
[
  {
    "tone": "3",
    "syllable": "nǐ",
    "originalSyllable": "ni3"
  },
  {
    "tone": "3",
    "syllable": "hǎo",
    "originalSyllable": "hao3"
  }
]
*/
```
npm package: @nahanil/zh-decomp
Description: Decompose Chinese characters
Author: Jarrod Linahan
Latest version: 0.2.4

## @nahanil/zh-decomp
[![pipeline status](https://git.carrotlabs.net/zhdict/zh-decomp/badges/master/pipeline.svg)](https://git.carrotlabs.net/zhdict/zh-decomp/pipelines)
[![coverage report](https://git.carrotlabs.net/zhdict/zh-decomp/badges/master/coverage.svg)](http://zhdict.pages.carrotlabs.net/zh-decomp/coverage/)
[![NPM version](https://badge.fury.io/js/@nahanil%2Fzh-decomp.png)](https://www.npmjs.com/package/@nahanil/zh-decomp)

Decompose Chinese characters

```bash
npm install --save @nahanil/zh-decomp
```

```
const decomp = require('@nahanil/zh-decomp')
```

### lookup(char)
```js
let res = decomp.lookup('蟆');
/*
{
  "label": "蟆",
  "children": [
    {
      "label": "虫"
    },
    {
      "label": "莫",
      "children": [
        {
          "label": "艹"
        },
        {
          "label": "旲",
          "children": [
            {
              "label": "日"
            },
            {
              "label": "大"
            }
          ]
        }
      ]
    }
  ]
}
*/
```

### radical(char)
This will likely be removed in future in favour of [@nahanil/bushou](https://www.npmjs.com/package/@nahanil/bushou)
```js
decomp.radical('蟆')
// '虫' <-- Found radical

decomp.radical('虫')
// '*' <-- 虫 is a radical

decomp.radical('U')
// null <-- 'U' not found
```

### Source
https://commons.wikimedia.org/wiki/Commons:Chinese_characters_decomposition
npm package: @nahanil/zh-tokenizer
Description: Tokenize Chinese texts into words.
Author: Jarrod Linahan
Latest version: 0.1.3

# @nahanil/zh-tokenizer
[![pipeline status](https://git.carrotlabs.net/zhdict/zh-tokenizer/badges/master/pipeline.svg)](https://git.carrotlabs.net/zhdict/zh-tokenizer/pipelines)
[![coverage report](https://git.carrotlabs.net/zhdict/zh-tokenizer/badges/master/coverage.svg)](http://zhdict.pages.carrotlabs.net/zh-tokenizer/coverage/)
[![NPM version](https://badge.fury.io/js/@nahanil%2Fzh-tokenizer.png)](https://www.npmjs.com/package/@nahanil/zh-tokenizer) &nbsp; &nbsp;

Tokenizes Chinese texts into words using [CC-CEDICT](https://cc-cedict.org/).

Extended from https://github.com/takumif/cedict-lookup

## Installation

Use npm to install:

~~~
npm install @nahanil/zh-tokenizer --save
~~~

## Updated Usage

Make sure to provide the [CC-CEDICT](https://cc-cedict.org/) data.
Will not work with simplified characters

~~~js
const tokenizer = require('@nahanil/zh-tokenizer')('./cedict.txt')
console.log(tokenizer.tokenize('我是中国人。'))
~~~


## Usage

Make sure to provide the [CC-CEDICT](https://cc-cedict.org/) data.

~~~js
const tokenizer = require('@nahanil/zh-tokenizer')('./cedict.txt')
console.log(tokenizer.tokenize('我是中国人。'))
~~~

~~~js
const tokenizer = require('@nahanil/zh-tokenizer')('./cedict.txt', 'traditional')
console.log(tokenizer.tokenize('我是中國人。'))
~~~

Output:

~~~
[ { traditional: '我',
    simplified: '我',
    pinyin: 'wo3',
    pinyinPretty: 'wǒ',
    english: 'I/me/my' },
  { traditional: '是',
    simplified: '是',
    pinyin: 'shi4',
    pinyinPretty: 'shì',
    english: 'is/are/am/yes/to be\nvariant of 是[shi4]/(used in given names)' },
  { traditional: '中國人',
    simplified: '中国人',
    pinyin: 'zhong1 guo2 ren2',
    pinyinPretty: 'zhōng guó rén',
    english: 'Chinese person' },
  { traditional: '。',
    simplified: '。',
    pinyin: null,
    pinyinPretty: null,
    english: null } ]
~~~
npm package: @nahanil/zhdict-lite
Description: Access extended CC-CEDICT dictionary data
Author: Jarrod Linahan
Latest version: 0.0.2

## @nahanil/zhdict-lite
[![pipeline status](https://git.carrotlabs.net/zhdict/zhdict-lite/badges/master/pipeline.svg)](https://git.carrotlabs.net/zhdict/zhdict-lite/pipelines)
[![coverage report](https://git.carrotlabs.net/zhdict/zhdict-lite/badges/master/coverage.svg)](http://zhdict.pages.carrotlabs.net/zhdict-lite/coverage/)
[![NPM version](https://badge.fury.io/js/@nahanil%2Fzhdict-lite.svg)](https://www.npmjs.com/package/@nahanil/zhdict-lite)

Fallback data source for [zhdict.net](https://zhdict.net/)

```bash
npm install --save @nahanil/zhdict-lite
# OR
yarn add @nahanil/zhdict-lite
```

```js
const dict = require('@nahanil/zhdict-lite')
```

### Search for a word or character
```js
let results = await dict.search('水')
/*
 * Always returns an array of results
  [
    {
      "id": "3f69904700c4fe2fb2caeb3f46501bc66ce245a4",
      "simplified": "水",
      "traditional": "水",
      "pinyin": "shui3",
      "hskLevel": 1,
      "english": "surname Shui/water/river/...",
      "radicalSimplified": "水",
      "radicalTraditional": "水",
      "strokesSimplified": 4,
      "strokesTraditional": 4,
      "strokesMinRadSimplified": 0,
      "strokesMinRadTraditional": 0,
      "variantsSimplified": null,
      "variantsTraditional": null,
      "variants": "氵"
    }
  ]
*/

let results = await dict.search('你好')
/*
  [
    {
      id: 'd3e4b9c5d696fe124825709a9a73aa3f01c61b2a',
      simplified: '你好',
      traditional: '你好',
      pinyin: 'ni3 hao3',
      english: 'hello/hi',
      hskLevel: null,
      radicalSimplified: null,
      radicalTraditional: null,
      strokesSimplified: null,
      strokesTraditional: null,
      strokesMinRadSimplified: null,
      strokesMinRadTraditional: null,
      variantsSimplified: null,
      variantsTraditional: null,
      variants: null
    }
  ]
*/
```

### Search for a word or character by radical
```js
let results = await dict.searchByRadical('水')
/*
 * Always returns an array of results
  [
    {
      "id": "3f69904700c4fe2fb2caeb3f46501bc66ce245a4",
      "simplified": "水",
      "traditional": "水",
      "pinyin": "shui3",
      "english": "surname Shui/water/river/liquid/beverage/...",
      "radicalSimplified": "水",
      "radicalTraditional": "水",
      "strokesSimplified": 4,
      "strokesTraditional": 4,
      "strokesMinRadSimplified": 0,
      "strokesMinRadTraditional": 0,
      "variantsSimplified": null,
      "variantsTraditional": null,
      "variants": "氵"
    },
    // ...
  ]
*/
```

### See also
- [parser.md](./parser.md)
- [CC-CEDICT download](https://www.mdbg.net/chinese/dictionary?page=cedict)