EasyIME / PIME

Develop input methods for Windows easily with Python and node.js
Other
1.34k stars 223 forks source link

大量匯入或調整詞彙 #19

Open daviking222 opened 8 years ago

daviking222 commented 8 years ago

沒有匯入與調整詞彙功能

ottokang commented 8 years ago

目前已經有使用者詞庫編輯工具(Chewing-editor),只是還沒有 Windows 版本的編譯

PCMan commented 8 years ago

@ottokang 你願意幫忙編譯嗎? 那個還得先編譯 Qt,有點小繁瑣,一時沒有空可以弄

ottokang commented 8 years ago

正在研究,我再試試看,如果不行再到 Chewing-editor 那邊問

Chinan commented 8 years ago

Windows 版本是這個嘛? https://github.com/Chocobo1/chewing-editor-build 不過剛剛試了似乎與PIME的使用者詞庫不相容。

之前這位開發者也有做 TSF版新酷音 的非官方修正版?

PCMan commented 7 years ago

@Chinan Windows 版本可以請教原開發者 @czchen 看如何 build

PCMan commented 7 years ago

@ottokang 我剛抽空實驗了一下,其實挺簡單,以下 python code 可以列出所有使用者自訂辭

from libchewing import ChewingContext
from ctypes import *

def main():
    ctx = ChewingContext()
    phrase_len = c_uint(0)
    bopomofo_len = c_uint(0)
    ctx.userphrase_enumerate()
    while ctx.userphrase_has_next(byref(phrase_len), byref(bopomofo_len)):
        phrase_buf = create_string_buffer(phrase_len.value)
        bopomofo_buf = create_string_buffer(bopomofo_len.value)
        ctx.userphrase_get(phrase_buf, phrase_len, bopomofo_buf, bopomofo_len)
        phrase = phrase_buf.raw.decode("utf8")
        bopomofo = bopomofo_buf.raw.decode("utf8")
        print(phrase, " => ", bopomofo)

if __name__ == "__main__":
    main()

所有相關 API 可參考 libchewing 的 chewingio.h,大約就這些

CHEWING_API int chewing_userphrase_enumerate(ChewingContext *ctx);

CHEWING_API int chewing_userphrase_has_next(ChewingContext *ctx, unsigned int *phrase_len, unsigned int *bopomofo_len);

CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
                                       char *phrase_buf, unsigned int phrase_len,
                                       char *bopomofo_buf, unsigned int bopomofo_len);

CHEWING_API int chewing_userphrase_add(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);

CHEWING_API int chewing_userphrase_remove(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);

CHEWING_API int chewing_userphrase_lookup(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
PCMan commented 7 years ago

@ottokang 至於 UI 部分其實用 https://github.com/6pac/SlickGrid 來做效果很好 用 slick grid 的 dataview 來顯示表格,可以新增移除,分頁,還可以 search 請參考

PCMan commented 7 years ago

@czchen 其實用網頁前端 + python + ctypes 來寫,理論上應該比 Qt 簡單 XD

czchen commented 7 years ago

@ottokang Windows chewing-editor 很久以前有試著做過,Qt 那裡很難搞。如果要大量匯入,建議是直接使用 libchewing API。

PCMan commented 7 years ago

網頁 based 的辭庫編輯器,初版完成 https://github.com/EasyIME/PIME/commit/6aace349f42f42e9a7643141ab0718d4de66a021

ottokang commented 7 years ago

感謝!最近真的忙到沒空研究,我再看看有沒有可以測試修改的地方

ottokang commented 7 years ago

剛剛測試了一下 Python code,沒辦法列出所有的使用者詞庫,似乎是 ChewingContext() 初始化沒有讀取到詞庫資料。

PCMan commented 7 years ago

@ottokang 感謝,已經修正 0.16-dev branch