PIME icon indicating copy to clipboard operation
PIME copied to clipboard

大量匯入或調整詞彙

Open daviking222 opened this issue 10 years ago • 13 comments

沒有匯入與調整詞彙功能

daviking222 avatar Feb 27 '16 16:02 daviking222

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

ottokang avatar Mar 01 '16 01:03 ottokang

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

PCMan avatar Mar 01 '16 01:03 PCMan

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

ottokang avatar Mar 01 '16 02:03 ottokang

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

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

Chinan avatar Mar 14 '16 05:03 Chinan

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

PCMan avatar Oct 22 '16 16:10 PCMan

@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 avatar Oct 22 '16 16:10 PCMan

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

PCMan avatar Oct 22 '16 16:10 PCMan

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

PCMan avatar Oct 22 '16 16:10 PCMan

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

czchen avatar Oct 23 '16 11:10 czchen

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

PCMan avatar Nov 03 '16 18:11 PCMan

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

ottokang avatar Nov 04 '16 00:11 ottokang

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

ottokang avatar Nov 09 '16 08:11 ottokang

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

PCMan avatar Nov 11 '16 13:11 PCMan