node-unihan-etl
v0.1.1
Published
NPM/Node wrapper for unihan-etl
Downloads
32
Readme
node-unihan-etl
This is a Node port of unihan-etl.
Installation
- Make sure you have the latest 2.7 branch of Python.
npm install node-unihan-etl
- To install
unihan-etl
, execute one of the following:npm run install-unihan-etl
- - Installunihan-etl
viapip
npm run install-unihan-etl-plus-yml
- Installunihan-etl
andpyyaml
viapip
to support theyml
export formatnpm run install-unihan-etl-source
- Install from source (requireds recursive clone ofnode-unihan-etl
)
Example
const unihanETL = require('./src/index.js');
(async () => {
await unihanETL({fields: ['kFrequency'], destination: 'unihan.json'});
})();
API
<Promise -> stderr || stdout OR rejects> = unihanETL({[format=json], [fields], [destination], [fields], [inputFiles], [source], [zipPath], [logLevel], [noExpand], [noPrune], [version]})
We have mostly kept the same API as unihan-etl, except defaulting to JSON
given the JavaScript environment. And destination
also takes into account
the current working directory.
format ("json"|"csv"|"yml")
destination (string)
- Supply a path relative to the current working directoryfields (Array|string)
- e.g.,kTotalStrokes
; see https://unihan-etl.git-pull.com/en/latest/cli.html for choices.inputFiles (Array|string)
- All Unihan files used by default.source (string)
- Defaults to http://www.unicode.org/Public/UNIDATA/Unihan.zipzipPath (string)
- Defaults to/home/docs/.cache/unihan_etl/downloads/Unihan.zip
logLevel ("DEBUG"|"INFO"|"WARNING"|"ERROR"|"CRITICAL")
noExpand (boolean)
- Whether to expand values to lists in multi-value UNIHAN fields (excepting CSV)noPrune (boolean)
- Whether to prune fields with empty keys (excepting CSV).version (boolean)
- Just prints version and exits