dictdb
dictionary database for language translation
example
First populate the database:
var parse = ;var through = ;var fs = ;var gunzip = createGunzip;var minimist = ;var db = '/tmp/dict.db';var ddb = db;var argv = ;var dstream = fs;var istream = fs;;{ return w }
$ node import.js --from en --to zh /usr/share/dictd/stardic.{dict.dz,index}
then you can query the dictionary database:
var minimist = ;var db = '/tmp/dict.db';var ddb = db;var argv = ;var q =word: argv_from: argvfromto: argvto;ddb;
$ node get.js --from en --to zh robot
机械人
机械般工作的人
自动机械
methods
var dictdb =
var ddb = dictdb(db)
Create a dictdb instance ddb
from a leveldb handle db
.
ddb.link(a, b, cb)
Link a.word
written in a.lang
to b.word
written in b.lang
and
vice-versa.
a.word
and b.word
can be strings or arrays of strings.
The optional callback cb(err)
fires with any errors.
var r = ddb.get(query, cb)
Return an object stream r
with the results of query
:
query.word
- word to search forquery.from
- language thatquery.word
is written inquery.to
- language to translatequery.word
into
r
pushes objects with lang
and word
properties.
install
With npm do:
npm install dictdb
license
MIT