Coder Social home page Coder Social logo

zh-cangjie's Introduction

zh-cangjie

Build Status coverage report npm version

  • Convert strings to/from cangjie chars (人弓火 -> ONF || ONF -> 人弓火)
  • Convert chinese characters to/from cangjie (雨 -> 一中月卜 || MLBY -> 雨).

Created for zhdict.net

Usage

var cangjie = require('zh-cangjie');

// Convert alpha string into cangjie characters
cangjie.toCangjie("MGILG")
// "一土戈中土"

// Convert cangjie string into alpha
cangjie.fromCangjie("一土戈中土")
// "MGILG"

/*
 * From v0.2.0
 */
// Get the cangjie equivalent of a given character
let found = await cangjie.forCharacter('雨');
// - OR -
cangjie.forCharacter('雨').exec(function(err, found){
  console.log(found.alpha); // MLBY
  console.log(found.cangjie); // 一中月卜
});

// Search for characters based on cangjie string
// Sometimes this will return multiple characters
let found = await cangjie.findCharacters("MLBY");
// - OR -
cangjie.findCharacters("MLBY", function(err, found) {
  console.log(found);  // ['雨']
});

let found = await cangjie.findCharacters("一中月卜");
// - OR -
cangjie.findCharacters("一中月卜", function(err, found) {
  console.log(found);  // ['雨']
});

let found = await cangjie.findCharacter("YWLV");
// - OR -
cangjie.findCharacters("YWLV", function(err, found) {
  console.log(found);  // ['褱', '還']
});


// Search for characters whos cangjie equivalent begins with the given string
// This could be used, for example, in a character prediction widget for
// a soft cangjie keyboard
let found = await cangjie.findCharacters("一中");
cangjie.findCharacters("一中", function(err, found) {
  console.log(found);
  // [ '工', '更', '雨', '兩', '亞', '丌', '丏', '両', '丣', '帀', '㓚', '㧭', '厞', '覀' ]
});

Changes

4 December 2018 - 0.2.0

  • .findCharacters() replaces .search() and .findCharacter()
  • findCharacters() and fromCharacter() are await-able
  • Requires Node.js 8+ (async/await)

9 September 2016 - 0.1.0

  • Added ability to lookup cangjie for a given Chinese character (based on data from Unihan/Unicode Character Database
  • Added ability to search for characters based on a full or partial cangjie string (as either [A-Z]+ or cangjie 'radicals')

23 August 2015 - 0.0.2

Initial release

TODO

  • Potentially paginate results returned by search() findCharacters()

Notes

This is currently under development. API may/likely will grow and change.

Character <-> cangjie data was compiled from the Unicode Character Database.

Unicode Character Database
Copyright © 1991-2016 Unicode, Inc. All rights reserved.
Distributed under the Terms of Use in http://www.unicode.org/copyright.html.

zh-cangjie's People

Contributors

nahanil avatar

Watchers

 avatar

zh-cangjie's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.