All Projects → timdream → Jszhuyin

timdream / Jszhuyin

Licence: mit
JS 注音:JavaScript 自動選字注音輸入法;"Smart" Chinese Zhuyin Input Method in JavaScript.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jszhuyin

Rasa chatbot cn
building a chinese dialogue system based on the newest version of rasa(基于最新版本rasa搭建的对话系统)
Stars: ✭ 723 (+292.93%)
Mutual labels:  chinese, demo
rime-wugniu zaonhe
上海吳語拼音輸入方案 · 上海吴语拼音输入方案 · Rime input schemas for Shanghai Dialects
Stars: ✭ 20 (-89.13%)
Mutual labels:  input-method, chinese
Somiao Pinyin
Somiao Pinyin: Train your own Chinese Input Method with Seq2seq Model 搜喵拼音输入法
Stars: ✭ 209 (+13.59%)
Mutual labels:  chinese, input-method
Chinese rime
收集現代漢語方言和古漢語的中州韻輸入法拼音方案 Collection of phonetic spelling schemas for Sinitic languages and dialects
Stars: ✭ 118 (-35.87%)
Mutual labels:  chinese, input-method
Demo
A framework for performing live pre-recorded command line demos in the wild 📼
Stars: ✭ 179 (-2.72%)
Mutual labels:  demo
Weapp demos
持续更新中的微信小程序和小游戏的源码案例库。目前涵盖了120多个微信小程序或小游戏。
Stars: ✭ 2,466 (+1240.22%)
Mutual labels:  demo
Colab
Continual Learning tutorials and demo running on Google Colaboratory.
Stars: ✭ 168 (-8.7%)
Mutual labels:  demo
Demo
Symfony Demo Application
Stars: ✭ 2,102 (+1042.39%)
Mutual labels:  demo
Prisma Auth0 Example
Boilerplate Prisma Startup
Stars: ✭ 184 (+0%)
Mutual labels:  demo
Fluttergames
Flutter app for purchasing and renting games.
Stars: ✭ 182 (-1.09%)
Mutual labels:  demo
Qml
Introductions to key concepts in quantum machine learning, as well as tutorials and implementations from cutting-edge QML research.
Stars: ✭ 174 (-5.43%)
Mutual labels:  demo
Confetti.js
A simple confetti animation for your website :)
Stars: ✭ 170 (-7.61%)
Mutual labels:  demo
Blog
a blog demo on github pages
Stars: ✭ 179 (-2.72%)
Mutual labels:  demo
Springboot Elasticsearch
基于springboot的web项目,通过elasticsearch提供的Java API 进行查询操作.
Stars: ✭ 169 (-8.15%)
Mutual labels:  demo
Helpdesk Guide
📖《桌维网管实典》主机与程控终端信息安全运维,IT方向速成就业入职
Stars: ✭ 183 (-0.54%)
Mutual labels:  chinese
Docker Compose Demo
A short demo on how to use Docker Compose to create a Web Service connected to a load balancer and a Redis Database.
Stars: ✭ 168 (-8.7%)
Mutual labels:  demo
Rime Cantonese
Rime Cantonese input schema | 粵語拼音輸入方案
Stars: ✭ 173 (-5.98%)
Mutual labels:  input-method
Go Workwx
a sensible Work Weixin(企业微信, Wechat Work) SDK for Go
Stars: ✭ 181 (-1.63%)
Mutual labels:  chinese
Posse gallery
Posse's fancy new gallery for Flutter.
Stars: ✭ 174 (-5.43%)
Mutual labels:  demo
Vue2 Demo
Vue 基于 Genesis + TS + Vuex 实现的 SSR demo
Stars: ✭ 2,072 (+1026.09%)
Mutual labels:  demo

JSZhuyin - JS 注音 npm version

"Smart" Chinese Zhuyin Input Method in Javascript. Javascript 自動選字注音輸入法。示範網頁

已知的線上自動選字注音輸入法都是將輸入送至伺服器,這是已知的第一個完全使用前端技術完成的實作,故可支援離線使用。

This library was intially developed as part of Mozilla Firefox OS - Gaia. Desktop front-end demo was initially developed in Gaia keyboard demo.

軟體授權

MIT License

CLI 介面

$ npm install --global jszhuyin
...
$ jszhuyin ㄐㄊㄌㄞˊㄒㄧㄝˇㄓㄨˋㄧㄣㄕㄖㄈ
今天來寫注音輸入法
今天
家庭
交通
具體
檢討
...

從 NodeJS 呼叫

const { JSZhuyin } = require('jszhuyin');
var jszhuyin = new JSZhuyin();
jszhuyin.load();

var candidates = [];
jszhuyin.oncandidateschange = function(c) {
  candidates = c;
};
jszhuyin.handleKey('ㄐㄊㄌㄞˊㄒㄧㄝˇㄓㄨˋㄧㄣㄕㄖㄈ');

console.log(candidates[0][0]); // '今天來寫注音輸入法'

在 RunKit 試用此範例

安裝至網站

您可以直接連結 Github 上的檔案:

<script type="text/javascript" src="https://jszhuyin.timdream.org/lib/client.js"></script>
<script type="text/javascript" src="https://jszhuyin.timdream.org/lib/web.js"></script>

準備基本的 HTML 元素(分別為待選字的注音,以及候選字詞),請自行加上適合的 CSS 樣式或是浮動視窗等等:

<p id="composition"></p>
<ol id="candidates"></ol>

使用以下程式碼啟動輸入法:

JSZhuyinServerWorkerLoader.prototype.WORKER_URL =
  'https://jszhuyin.timdream.org/lib/worker.js';
JSZhuyinClient.prototype.DEFAULT_LOADER = JSZhuyinServerWorkerLoader;
var webIME = new JSZhuyinWebIME({
  composition: document.getElementById('composition'),
  candidatesList: document.getElementById('candidates')
});

啟動完成之後,JS 注音即會開始處理鍵盤輸入。

虛擬鍵盤

虛擬鍵盤可以將使用者點選的注音符號傳至 webIME.handleKey(code)。請確保虛擬鍵盤不會搶走 focus。

詞庫

使用 MIT License 授權的小麥注音詞庫,由 mjhsieh 維護,基於 libtabe

使用前請先執行 npm run grunt data 從 McBopomofo 產生適用於 JSZhuyin 的詞庫檔案。

斷詞演算法

會輸出的候選詞依序有四種:

  1. 資料庫中,完整符合輸入的注音組合的所有字詞
  2. 完整符合輸入的注音組合的一個組合結果
  3. 資料庫中,只符合輸入的前幾個注音組合的所有字詞
  4. 打錯的第一個音

其中,(2) 只有在 (1) 沒有找到的時候才會出現,(4) 只有在前面全部都沒有找到的情況才會出現。

(1) 與 (3) 是直接將注音組合切割成可能的單音組合送到資料庫查詢(資料庫存在另外設計的存在 Typed Array 的資料結構內)。

(2) 比較複雜,但也只是窮舉法與積分比較而已(笑)。窮舉是用很簡單的 Composition of a natural number,將單音組合切割成所有可能的單詞送到資料庫查詢與累加積分。積分是小麥注音詞庫提供的。因為組合的結果只會輸出一個,且輸入新的注音符號時新的最高分的組合候選詞一定會包含舊的組合候選詞,所以使用了一系列的快取來加快每個輸入的處理速度,而不是窮舉所有可能的單詞組合再重新排名。

因為是窮舉,如果有正確的詞庫應該可以做其他的 phonetic IME。

為何範例頁互動不像正常的桌機智慧注音?

因為 JS 注音是手機輸入法 :-/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].