emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Re: [ELPA] New package: pyim


From: tumashu
Subject: Re:Re: [ELPA] New package: pyim
Date: Mon, 22 Feb 2021 16:47:38 +0800 (CST)

At 2021-02-22 16:19:34, "Clément Pit-Claudel" <cpitclaudel@gmail.com> wrote:
>On 2/22/21 1:49 AM, tumashu wrote:
>> the real quesiton for me,  is that  is it acceptable for GNU elpa  by import 
>> and convert  libpinyin's table to  pyim.
>
>Libpinyin seems to be GPLv3; if that is correct, then there is no issue at all 
>and your use is completely acceptable.

sorry, I remeber wrong:

pyim-pymap.el is converted from pinyin_simp.dict.yaml of
[[https://github.com/rime/rime-pinyin-simp][rime-pinyin-simp]]

rime-pinyin-simp use LGPL-3.0 License, while pinyin_simp.dict.yaml
has the header like below:

# Rime dictionary
# encoding: utf-8
#
# A minimal Pinyin dictionary for simplified Chinese script
#
# Derived from android open source project:
# http://android.git.kernel.org/?p=platform/packages/inputmethods/PinyinIME.git
#

-----------------------------------------------------
the below is convert script.

(defun pyim-pymap-new nil)

(defun pyim-pymap-importer ()
  "将格式为:

你       ni
我       wo

的文件内容,转换为 pyim 的 pymap

注意: 这个文件中词条的词率由低到高排列。"
  (interactive)
  (let ((hashtable (make-hash-table :size 1000000 :test #'equal))
        alist)
    (while (not (eobp))
      (let* ((begin (line-beginning-position))
             (end (line-end-position))
             (items (split-string
                     (buffer-substring-no-properties begin end)
                     "  "))
             (word (nth 0 items))
             (pinyin (nth 1 items)))
        (when (and pinyin word)
          (puthash pinyin
                   (concat word
                           (replace-regexp-in-string
                            word ""
                            (or (gethash pinyin hashtable) "")))
                   hashtable)))
      (forward-line 1))
    (maphash
     #'(lambda (key value)
         (push (list key value) alist))
     hashtable)
    (setq pyim-pymap-new
          (seq-sort
           #'(lambda (a b)
               (string< (car a) (car b)))
           alist))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]