diff options
| author | Kenichi Handa | 2001-03-31 02:22:17 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2001-03-31 02:22:17 +0000 |
| commit | c063e38165bbdc844743c85ca1e754e19c86634d (patch) | |
| tree | f76e7fff63d23dcc60692eb52255d7ab60648275 | |
| parent | 18287ec190596ff2b0627ca57153a72a341ebdd5 (diff) | |
| download | emacs-c063e38165bbdc844743c85ca1e754e19c86634d.tar.gz emacs-c063e38165bbdc844743c85ca1e754e19c86634d.zip | |
(quail-cxterm-package-ext-info):
Delete entries for "chinese-py" and "chinese-ziranma".
(quail-misc-package-ext-info): New variable.
(tsang-quick-converter): New function.
(tsang-b5-converter, quick-b5-converter, tsang-cns-converter)
(quick-cns-converter, py-converter, ziranma-converter)
(miscdic-convert, batch-miscdic-convert): New functions.
| -rw-r--r-- | lisp/international/titdic-cnv.el | 564 |
1 files changed, 479 insertions, 85 deletions
diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el index c03425318de..e9d65f0271f 100644 --- a/lisp/international/titdic-cnv.el +++ b/lisp/international/titdic-cnv.el | |||
| @@ -51,6 +51,9 @@ | |||
| 51 | ;; | 51 | ;; |
| 52 | ;; See the manual page of `tit2cit' of cxterm distribution for more | 52 | ;; See the manual page of `tit2cit' of cxterm distribution for more |
| 53 | ;; detail. | 53 | ;; detail. |
| 54 | ;; | ||
| 55 | ;; At the tail of this file, we also have another tools to convert | ||
| 56 | ;; miscellaneous dictionaries. | ||
| 54 | 57 | ||
| 55 | ;;; Code: | 58 | ;;; Code: |
| 56 | 59 | ||
| @@ -150,47 +153,6 @@ method `chinese-qj-b5'. | |||
| 150 | The input method `chinese-py' and `chinese-tonepy' are also Pinyin | 153 | The input method `chinese-py' and `chinese-tonepy' are also Pinyin |
| 151 | based, but for the character set GB2312 (`chinese-gb2312').") | 154 | based, but for the character set GB2312 (`chinese-gb2312').") |
| 152 | 155 | ||
| 153 | ("chinese-py" "$AF4(BG" | ||
| 154 | "Pinyin base input method for Chinese charset GB2312 | ||
| 155 | \(`chinese-gb2312'). | ||
| 156 | |||
| 157 | Pinyin is the standared roman transliteration method for Chinese. | ||
| 158 | Pinyin uses a sequence of Latin alphabetic characters for each Chinese | ||
| 159 | character. The sequence is made by the combination of the initials | ||
| 160 | \(the beginning sounds) and finals \(the ending sounds). | ||
| 161 | |||
| 162 | initials: b p m f d t n l z c s zh ch sh r j q x g k h | ||
| 163 | finals: a o e i er ai ei oa ou an en ang eng ong i ia iao ie iu ian in | ||
| 164 | iang ing iong u ua uo uai ui uan un uan ueng yu yue yuan yun | ||
| 165 | |||
| 166 | (Note: In the correct Pinyin writing, the sequence \"yu\" in the last | ||
| 167 | four finals should be written by the character u-umlaut `$A(9(B'.) | ||
| 168 | |||
| 169 | With this input method, you enter a Chinese character by first | ||
| 170 | entering its pinyin spelling. | ||
| 171 | |||
| 172 | \\<quail-translation-docstring> | ||
| 173 | |||
| 174 | For instance, to input $ADc(B, you type \"n i C-n 3\". The first \"n i\" | ||
| 175 | is a Pinyin, \"C-n\" selects the next group of candidates (each group | ||
| 176 | contains at most 10 characters), \"3\" select the third character in | ||
| 177 | that group. | ||
| 178 | |||
| 179 | This input method supports only Han characters. The related input | ||
| 180 | method `chinese-py-punct' is the combination of this method and | ||
| 181 | `chinese-punct'; it supports both Han characters and punctuation | ||
| 182 | characters. | ||
| 183 | |||
| 184 | For double-width GB2312 characters corresponding to ASCII, use the | ||
| 185 | input method `chinese-qj'. | ||
| 186 | |||
| 187 | The correct Pinyin system specifies tones by diacritical marks, but | ||
| 188 | this input method doesn't use them, which results in easy (you don't | ||
| 189 | have to know the exact tones), but verbose (many characters are assigned | ||
| 190 | to the same key sequence) input. You may also want to try the input | ||
| 191 | method `chinese-tonepy' with which you must specify tones by digits | ||
| 192 | \(1..5).") | ||
| 193 | |||
| 194 | ("chinese-qj-b5" "$(0)A(BB") | 156 | ("chinese-qj-b5" "$(0)A(BB") |
| 195 | 157 | ||
| 196 | ("chinese-qj" "$AH+(BG") | 158 | ("chinese-qj" "$AH+(BG") |
| @@ -232,50 +194,6 @@ the third character from the candidate list. | |||
| 232 | For double-width GB2312 characters correponding to ASCII, use the | 194 | For double-width GB2312 characters correponding to ASCII, use the |
| 233 | input method `chinese-qj'.") | 195 | input method `chinese-qj'.") |
| 234 | 196 | ||
| 235 | ("chinese-ziranma" "$AK+F4(B" | ||
| 236 | "Pinyin base input method for Chinese GB2312 characters (`chinese-gb2312'). | ||
| 237 | |||
| 238 | Pinyin is the standard roman transliteration method for Chinese. | ||
| 239 | For the details of Pinyin system, see the documentation of the input | ||
| 240 | method `chinese-py'. | ||
| 241 | |||
| 242 | unlike the standard spelling of Pinyin, in this input method all | ||
| 243 | initials and finals are assigned to single keys (see the above table). | ||
| 244 | For instance, the initial \"ch\" is assigned to the key `i', the final | ||
| 245 | \"iu\" is assigned to the key `q', and tones 1, 2, 3, 4, and $AGaIy(B are | ||
| 246 | assigned to the keys `q', `w', `e', `r', `t' respectively. | ||
| 247 | |||
| 248 | \\<quail-translation-docstring> | ||
| 249 | |||
| 250 | To input one-letter words, you type 4 keys, the first two for the | ||
| 251 | Pinyin of the letter, next one for tone, and the last one is always a | ||
| 252 | quote ('). For instance, \"vsq'1\" input $AVP(B. Exceptions are these | ||
| 253 | letters. You can input them just by typing a single key. | ||
| 254 | |||
| 255 | Character: $A04(B $A2;(B $A4N(B $A5D(B $A6~(B $A7"(B $A8v(B $A:M(B $A3v(B $A<0(B $A?I(B $AAK(B $AC;(B | ||
| 256 | Key: a b c d e f g h i j k l m | ||
| 257 | Character: $ADc(B $AE7(B $AF,(B $AF_(B $AHK(B $AH}(B $AK{(B $AJG(B $AWE(B $ANR(B $AP!(B $AR;(B $ATZ(B | ||
| 258 | Key: n o p q r s t u v w x y z | ||
| 259 | |||
| 260 | To input two-letter words, you have two ways. One way is to type 4 | ||
| 261 | keys, two for the first Pinyin, two for the second Pinyin. For | ||
| 262 | instance, \"vsgo\" inputs $AVP9z(B. Another way is to type 3 keys: 2 | ||
| 263 | initials of two letters, and quote ('). For instance, \"vg'\" also | ||
| 264 | inputs $AVP9z(B. | ||
| 265 | |||
| 266 | To input three-letter words, you type 4 keys: initials of three | ||
| 267 | letters, and the last is quote ('). For instance, \"bjy'2\" inputs $A11(B | ||
| 268 | $A>)Q<(B (the last `2' is to select one of the candidates). | ||
| 269 | |||
| 270 | To input words of more than three letters, you type 4 keys, initials | ||
| 271 | of the first three letters and the last letter. For instance, | ||
| 272 | \"bjdt\" inputs $A11>)5gJSL((B. | ||
| 273 | |||
| 274 | To input symbols and punctuations, type `/' followed by one of `a' to | ||
| 275 | `z', then select one of the candidates. | ||
| 276 | |||
| 277 | ") | ||
| 278 | |||
| 279 | ("chinese-zozy" "$(0I\0D(B" | 197 | ("chinese-zozy" "$(0I\0D(B" |
| 280 | "Zhuyin base input method for Chinese Big5 characters (`chinese-big5-1', | 198 | "Zhuyin base input method for Chinese Big5 characters (`chinese-big5-1', |
| 281 | `chinese-big5-2'). | 199 | `chinese-big5-2'). |
| @@ -639,6 +557,482 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"." | |||
| 639 | (message " %% emacs -batch -f batch-byte-compile XXX.el"))) | 557 | (message " %% emacs -batch -f batch-byte-compile XXX.el"))) |
| 640 | (kill-emacs 0)) | 558 | (kill-emacs 0)) |
| 641 | 559 | ||
| 560 | |||
| 561 | ;;; Converter of miscellaneous dictionaries other than TIT format. | ||
| 562 | |||
| 563 | ;; Alist of input method names and the corresponding information. | ||
| 564 | ;; Each element has this form: | ||
| 565 | ;; (INPUT-METHOD-NAME ;; Name of the input method. | ||
| 566 | ;; INPUT-METHOD-TITLE ;; Title string of the input method | ||
| 567 | ;; DICFILE ;; Name of the source dictionary file. | ||
| 568 | ;; CODING ;; Coding system of the dictionary file. | ||
| 569 | ;; QUAILFILE ;; Name of the Quail package file. | ||
| 570 | ;; CONVERTER ;; Function to generate the Quail package. | ||
| 571 | ;; COPYRIGHT-NOTICE ;; Copyright notice of the source dictionary. | ||
| 572 | ;; ) | ||
| 573 | |||
| 574 | (defvar quail-misc-package-ext-info | ||
| 575 | '(("chinese-b5-tsangchi" "$(06A(BB" | ||
| 576 | "cangjie-table.b5" big5 "tsang-b5.el" | ||
| 577 | tsang-b5-converter | ||
| 578 | "\ | ||
| 579 | ;; # Copyright 2001 Christian Wittern <wittern@iis.sinica.edu.tw> | ||
| 580 | ;; # | ||
| 581 | ;; # Permission to copy and distribute both modified and | ||
| 582 | ;; # unmodified versions is granted without royalty provided | ||
| 583 | ;; # this notice is preserved.") | ||
| 584 | |||
| 585 | ("chinese-b5-quick" "$(0X|(BB" | ||
| 586 | "cangjie-table.b5" big5 "quick-b5.el" | ||
| 587 | quick-b5-converter | ||
| 588 | "\ | ||
| 589 | ;; # Copyright 2001 Christian Wittern <wittern@iis.sinica.edu.tw> | ||
| 590 | ;; # | ||
| 591 | ;; # Permission to copy and distribute both modified and | ||
| 592 | ;; # unmodified versions is granted without royalty provided | ||
| 593 | ;; # this notice is preserved.") | ||
| 594 | |||
| 595 | ("chinese-cns-tsangchi" "$(GT?(BC" | ||
| 596 | "cangjie-table.cns" iso-2022-cn-ext "tsang-cns.el" | ||
| 597 | tsang-cns-converter | ||
| 598 | "\ | ||
| 599 | ;; # Copyright 2001 Christian Wittern <wittern@iis.sinica.edu.tw> | ||
| 600 | ;; # | ||
| 601 | ;; # Permission to copy and distribute both modified and | ||
| 602 | ;; # unmodified versions is granted without royalty provided | ||
| 603 | ;; # this notice is preserved.") | ||
| 604 | |||
| 605 | ("chinese-cns-quick" "$(Gv|(BC" | ||
| 606 | "cangjie-table.cns" iso-2022-cn-ext "quick-cns.el" | ||
| 607 | quick-cns-converter | ||
| 608 | "\ | ||
| 609 | ;; # Copyright 2001 Christian Wittern <wittern@iis.sinica.edu.tw> | ||
| 610 | ;; # | ||
| 611 | ;; # Permission to copy and distribute both modified and | ||
| 612 | ;; # unmodified versions is granted without royalty provided | ||
| 613 | ;; # this notice is preserved.") | ||
| 614 | |||
| 615 | ("chinese-py" "$AF4(BG" | ||
| 616 | "pinyin.map" cn-gb-2312 "PY.el" | ||
| 617 | py-converter | ||
| 618 | "\ | ||
| 619 | ;; \"pinyin.map\" is included in a free package called CCE. It is | ||
| 620 | ;; available at: | ||
| 621 | ;; http://ftp.debian.org/debian/dists/potato/main | ||
| 622 | ;; /source/utils/cce_0.36.orig.tar.gz | ||
| 623 | ;; This package contains the following copyright notice. | ||
| 624 | ;; | ||
| 625 | ;; | ||
| 626 | ;; Copyright (C) 1999, Rui He, herui@cs.duke.edu | ||
| 627 | ;; | ||
| 628 | ;; | ||
| 629 | ;; CCE(Console Chinese Environment) 0.32 | ||
| 630 | ;; | ||
| 631 | ;; CCE is free software; you can redistribute it and/or modify it under the | ||
| 632 | ;; terms of the GNU General Public License as published by the Free Software | ||
| 633 | ;; Foundation; either version 1, or (at your option) any later version. | ||
| 634 | ;; | ||
| 635 | ;; CCE is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 636 | ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 637 | ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 638 | ;; details. | ||
| 639 | ;; | ||
| 640 | ;; You should have received a copy of the GNU General Public License along with | ||
| 641 | ;; CCE; see the file COPYING. If not, write to the Free Software Foundation, | ||
| 642 | ;; 675 Mass Ave, Cambridge, MA 02139, USA.") | ||
| 643 | |||
| 644 | ("chinese-ziranma" "$AWTH;(B" | ||
| 645 | "ziranma.cin" cn-gb-2312 "ZIRANMA.el" | ||
| 646 | ziranma-converter | ||
| 647 | "\ | ||
| 648 | ;; \"ziranma.cin\" is included in a free package called CCE. It is | ||
| 649 | ;; available at: | ||
| 650 | ;; http://ftp.debian.org/debian/dists/potato/main | ||
| 651 | ;; /source/utils/cce_0.36.orig.tar.gz | ||
| 652 | ;; This package contains the following copyright notice. | ||
| 653 | ;; | ||
| 654 | ;; | ||
| 655 | ;; Copyright (C) 1999, Rui He, herui@cs.duke.edu | ||
| 656 | ;; | ||
| 657 | ;; | ||
| 658 | ;; CCE(Console Chinese Environment) 0.32 | ||
| 659 | ;; | ||
| 660 | ;; CCE is free software; you can redistribute it and/or modify it under the | ||
| 661 | ;; terms of the GNU General Public License as published by the Free Software | ||
| 662 | ;; Foundation; either version 1, or (at your option) any later version. | ||
| 663 | ;; | ||
| 664 | ;; CCE is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 665 | ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 666 | ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 667 | ;; details. | ||
| 668 | ;; | ||
| 669 | ;; You should have received a copy of the GNU General Public License along with | ||
| 670 | ;; CCE; see the file COPYING. If not, write to the Free Software Foundation, | ||
| 671 | ;; 675 Mass Ave, Cambridge, MA 02139, USA.") | ||
| 672 | )) | ||
| 673 | |||
| 674 | ;; Generate a code of a Quail package in the current buffer from Tsang | ||
| 675 | ;; dictionary in the buffer DICBUF. The input method name of the | ||
| 676 | ;; Quail package is NAME, and the title string is TITLE. | ||
| 677 | |||
| 678 | ;; TSANG-P is non-nil, genereate $(06AQo(B input method. Otherwise | ||
| 679 | ;; generate $(0X|/y(B (simple version of $(06AQo(B). If BIG5-P is non-nil, the | ||
| 680 | ;; input method is for inputting Big5 characters. Otherwise the input | ||
| 681 | ;; method is for inputting CNS characters. | ||
| 682 | |||
| 683 | (defun tsang-quick-converter (dicbuf name title tsang-p big5-p) | ||
| 684 | (let ((fulltitle (if tsang-p (if big5-p "$(06AQo(B" "$(GT?on(B") | ||
| 685 | (if big5-p "$(0X|/y(B" "$(Gv|Mx(B"))) | ||
| 686 | dic) | ||
| 687 | (goto-char (point-max)) | ||
| 688 | (if big5-p | ||
| 689 | (insert (format "\"$(0&d'GTT&,!J(B%s$(0!K(BBIG5 | ||
| 690 | |||
| 691 | $(0KHM$(B%s$(0TT&,WoOu(B | ||
| 692 | |||
| 693 | [Q $(0'D(B] [W $(0(q(B] [E $(0'V(B] [R $(0&H(B] [T $(0'>(B] [Y $(0&4(B] [U $(0&U(B] [I $(0'B(B] [O $(0&*(B] [P $(0'A(B] | ||
| 694 | |||
| 695 | [A $(0'K(B] [S $(0&T(B] [D $(0'N(B] [F $(0'W(B] [G $(0&I(B] [H $(0*M(B] [J $(0&3(B] [L $(0&d(B] | ||
| 696 | |||
| 697 | [Z ] [X $(0[E(B] [C $(01[(B] [V $(0&M(B] [B $(0'M(B] [N $(0&_(B] [M $(0&"(B] | ||
| 698 | |||
| 699 | \\\\<quail-translation-docstring>\"\n" | ||
| 700 | fulltitle fulltitle)) | ||
| 701 | (insert (format "\"$(GDcEFrSD+!J(B%s$(G!K(BCNS | ||
| 702 | |||
| 703 | $(GiGk#(B%s$(GrSD+uomu(B | ||
| 704 | |||
| 705 | [Q $(GEC(B] [W $(GFp(B] [E $(GEU(B] [R $(GDG(B] [T $(GE=(B] [Y $(GD3(B] [U $(GDT(B] [I $(GEA(B] [O $(GD)(B] [P $(GE@(B] | ||
| 706 | |||
| 707 | [A $(GEJ(B] [S $(GDS(B] [D $(GEM(B] [F $(GEV(B] [G $(GDH(B] [H $(GHL(B] [J $(GD2(B] [L $(GDc(B] | ||
| 708 | |||
| 709 | [Z ] [X $(GyE(B] [C $(GOZ(B] [V $(GDL(B] [B $(GEL(B] [N $(GD^(B] [M $(GD!(B] | ||
| 710 | |||
| 711 | \\\\<quail-translation-docstring>\"\n" | ||
| 712 | fulltitle fulltitle))) | ||
| 713 | (insert " '((\".\" . quail-next-translation-block) | ||
| 714 | (\",\" . quail-prev-translation-block)) | ||
| 715 | nil nil)\n\n") | ||
| 716 | (insert "(quail-define-rules\n") | ||
| 717 | (save-excursion | ||
| 718 | (set-buffer dicbuf) | ||
| 719 | (goto-char (point-min)) | ||
| 720 | (search-forward "A440") | ||
| 721 | (beginning-of-line) | ||
| 722 | (let ((table (make-hash-table :test 'equal)) | ||
| 723 | val) | ||
| 724 | (while (not (eobp)) | ||
| 725 | (forward-char 5) | ||
| 726 | (let ((trans (char-to-string (following-char))) | ||
| 727 | key slot) | ||
| 728 | (re-search-forward "[A-Z]+$" nil t) | ||
| 729 | (setq key (downcase | ||
| 730 | (if (or tsang-p | ||
| 731 | (<= (- (match-end 0) (match-beginning 0)) 1)) | ||
| 732 | (match-string 0) | ||
| 733 | (string (char-after (match-beginning 0)) | ||
| 734 | (char-after (1- (match-end 0))))))) | ||
| 735 | (setq val (gethash key table)) | ||
| 736 | (if val (setq trans (concat val trans))) | ||
| 737 | (puthash key trans table) | ||
| 738 | (forward-line 1))) | ||
| 739 | (maphash #'(lambda (key val) (setq dic (cons (cons key val) dic))) | ||
| 740 | table))) | ||
| 741 | (setq dic (sort dic (function (lambda (x y) (string< (car x ) (car y)))))) | ||
| 742 | (dolist (elt dic) | ||
| 743 | (insert (format "(%S\t%S)\n" (car elt) (cdr elt)))) | ||
| 744 | (let ((punctuations '((";" "$(0!'!2!"!#!.!/(B" "$(G!'!2!"!#!.!/(B") | ||
| 745 | (":" "$(0!(!+!3!%!$!&!0!1(B" "$(G!(!+!3!%!$!&!0!1(B") | ||
| 746 | ("'" "$(0!e!d(B" "$(G!e!d(B") | ||
| 747 | ("\"" "$(0!g!f!h!i!q(B" "$(G!g!f!h!i!q(B") | ||
| 748 | ("\\" "$(0"`"b#M(B" "$(G"`"b#M(B") | ||
| 749 | ("|" "$(0!6!8!:"^(B" "$(G!6!8!:"^(B") | ||
| 750 | ("/" "$(0"_"a#L(B" "$(G"_"a#L(B") | ||
| 751 | ("?" "$(0!)!4(B" "$(G!)!4(B") | ||
| 752 | ("<" "$(0!R"6"A!T"H(B" "$(G!R"6"A!T"H(B") | ||
| 753 | (">" "$(0!S"7"B!U(B" "$(G!S"7"B!U(B") | ||
| 754 | ("[" "$(0!F!J!b!H!L!V!Z!X!\(B" "$(G!F!J!b!H!L!V!Z!X!\(B") | ||
| 755 | ("]" "$(0!G!K!c!I!M!W | ||
| 756 | ("{" "$(0!B!`!D(B " "$(G!B!`!D(B ") | ||
| 757 | ("}" "$(0!C!a!E(B" "$(G!C!a!E(B") | ||
| 758 | ("`" "$(0!j!k(B" "$(G!j!k(B") | ||
| 759 | ("~" "$(0"D"+",!<!=(B" "$(G"D"+",!<!=(B") | ||
| 760 | ("!" "$(0!*!5(B" "$(G!*!5(B") | ||
| 761 | ("@" "$(0"i"n(B" "$(G"i"n(B") | ||
| 762 | ("#" "$(0!l"-(B" "$(G!l"-(B") | ||
| 763 | ("$" "$(0"c"l(B" "$(G"c"l(B") | ||
| 764 | ("%" "$(0"h"m(B" "$(G"h"m(B") | ||
| 765 | ("&" "$(0!m".(B" "$(G!m".(B") | ||
| 766 | ("*" "$(0!n"/!o!w!x(B" "$(G!n"/!o!w!x(B") | ||
| 767 | ("(" "$(0!>!^!@(B" "$(G!>!^!@(B") | ||
| 768 | (")" "$(0!?!_!A(B" "$(G!?!_!A(B") | ||
| 769 | ("-" "$(0!7!9"#"$"1"@(B" "$(G!7!9"#"$"1"@(B") | ||
| 770 | ("_" "$(0"%"&(B" "$(G"%"&(B") | ||
| 771 | ("=" "$(0"8"C(B" "$(G"8"C(B") | ||
| 772 | ("+" "$(0"0"?(B" "$(G"0"?(B")))) | ||
| 773 | (dolist (elt punctuations) | ||
| 774 | (insert (format "(%S %S)\n" (concat "z" (car elt)) | ||
| 775 | (if big5-p (nth 1 elt) (nth 2 elt)))))) | ||
| 776 | (insert ")\n"))) | ||
| 777 | |||
| 778 | (defun tsang-b5-converter (dicbuf name title) | ||
| 779 | (tsang-quick-converter dicbuf name title t t)) | ||
| 780 | |||
| 781 | (defun quick-b5-converter (dicbuf name title) | ||
| 782 | (tsang-quick-converter dicbuf name title nil t)) | ||
| 783 | |||
| 784 | (defun tsang-cns-converter (dicbuf name title) | ||
| 785 | (tsang-quick-converter dicbuf name title t nil)) | ||
| 786 | |||
| 787 | (defun quick-cns-converter (dicbuf name title) | ||
| 788 | (tsang-quick-converter dicbuf name title nil nil)) | ||
| 789 | |||
| 790 | ;; Generate a code of a Quail package in the current buffer from | ||
| 791 | ;; Pinyin dictionary in the buffer DICBUF. The input method name of | ||
| 792 | ;; the Quail package is NAME, and the title string is TITLE. | ||
| 793 | |||
| 794 | (defun py-converter (dicbuf name title) | ||
| 795 | (goto-char (point-max)) | ||
| 796 | (insert (format "%S\n" "$A::WVJdHk!KF4Rt!K(B | ||
| 797 | |||
| 798 | $AF4Rt7=08(B | ||
| 799 | |||
| 800 | $AP!P4S"NDWVD84z1m!8F4Rt!97{:E#,(B \"u(yu) $ATrSC(B u: $A1mJ>!C(B | ||
| 801 | |||
| 802 | Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312'). | ||
| 803 | |||
| 804 | Pinyin is the standared roman transliteration method for Chinese. | ||
| 805 | Pinyin uses a sequence of Latin alphabetic characters for each Chinese | ||
| 806 | character. The sequence is made by the combination of the initials | ||
| 807 | \(the beginning sounds) and finals (the ending sounds). | ||
| 808 | |||
| 809 | initials: b p m f d t n l z c s zh ch sh r j q x g k h | ||
| 810 | finals: a o e i er ai ei oa ou an en ang eng ong i ia iao ie iu ian in | ||
| 811 | iang ing iong u ua uo uai ui uan un uan ueng yu yue yuan yun | ||
| 812 | |||
| 813 | (Note: In the correct Pinyin writing, the sequence \"yu\" in the last | ||
| 814 | four finals should be written by the character u-umlaut `$A(9(B'.) | ||
| 815 | |||
| 816 | With this input method, you enter a Chinese character by first | ||
| 817 | entering its pinyin spelling. | ||
| 818 | |||
| 819 | \\<quail-translation-docstring> | ||
| 820 | |||
| 821 | For instance, to input $ADc(B, you type \"n i C-n 3\". The first \"n i\" | ||
| 822 | is a Pinyin, \"C-n\" selects the next group of candidates (each group | ||
| 823 | contains at most 10 characters), \"3\" select the third character in | ||
| 824 | that group. | ||
| 825 | |||
| 826 | This input method supports only Han characters. The related input | ||
| 827 | method `chinese-py-punct' is the combination of this method and | ||
| 828 | `chinese-punct'; it supports both Han characters and punctuation | ||
| 829 | characters. | ||
| 830 | |||
| 831 | For double-width GB2312 characters corresponding to ASCII, use the | ||
| 832 | input method `chinese-qj'. | ||
| 833 | |||
| 834 | The correct Pinyin system specifies tones by diacritical marks, but | ||
| 835 | this input method doesn't use them, which results in easy (you don't | ||
| 836 | have to know the exact tones), but verbose (many characters are assigned | ||
| 837 | to the same key sequence) input. You may also want to try the input | ||
| 838 | method `chinese-tonepy' with which you must specify tones by digits | ||
| 839 | \(1..5).")) | ||
| 840 | (insert " '((\"\C-?\" . quail-delete-last-char) | ||
| 841 | (\".\" . quail-next-translation) | ||
| 842 | (\">\" . quail-next-translation) | ||
| 843 | (\",\" . quail-prev-translation) | ||
| 844 | (\"<\" . quail-prev-translation)) | ||
| 845 | nil nil nil nil)\n\n") | ||
| 846 | (insert "(quail-define-rules\n") | ||
| 847 | (let ((pos (point))) | ||
| 848 | (insert-buffer-substring dicbuf) | ||
| 849 | (goto-char pos) | ||
| 850 | (while (not (eobp)) | ||
| 851 | (insert "(\"") | ||
| 852 | (skip-chars-forward "a-z") | ||
| 853 | (insert "\" \"") | ||
| 854 | (delete-char 1) | ||
| 855 | (end-of-line) | ||
| 856 | (insert "\")") | ||
| 857 | (forward-line 1))) | ||
| 858 | (insert ")\n")) | ||
| 859 | |||
| 860 | ;; Generate a code of a Quail package in the current buffer from | ||
| 861 | ;; Ziranma dictionary in the buffer DICBUF. The input method name of | ||
| 862 | ;; the Quail package is NAME, and the title string is TITLE. | ||
| 863 | |||
| 864 | (defun ziranma-converter (dicbuf name title) | ||
| 865 | (let (dic) | ||
| 866 | (save-excursion | ||
| 867 | (set-buffer dicbuf) | ||
| 868 | (goto-char (point-min)) | ||
| 869 | (search-forward "%keyname end\n") | ||
| 870 | (let ((table (make-hash-table :test 'equal)) | ||
| 871 | elt pos key trans val) | ||
| 872 | (while (not (eobp)) | ||
| 873 | (setq pos (point)) | ||
| 874 | (skip-chars-forward "^ \t") | ||
| 875 | (setq key (buffer-substring pos (point))) | ||
| 876 | (skip-chars-forward " \t") | ||
| 877 | (setq trans (vector (buffer-substring (point) (line-end-position)))) | ||
| 878 | (setq val (gethash key table)) | ||
| 879 | (if val (setq trans (vconcat val trans))) | ||
| 880 | (puthash key trans table) | ||
| 881 | (forward-line 1)) | ||
| 882 | (maphash #'(lambda (key trans) | ||
| 883 | (let ((len (length trans)) | ||
| 884 | i) | ||
| 885 | (if (and (= len 1) (= (length (aref trans 0)) 1)) | ||
| 886 | (setq trans (aref trans 0)) | ||
| 887 | (setq i 0) | ||
| 888 | (while (and (< i len) | ||
| 889 | (= (length (aref trans i)) 1)) | ||
| 890 | (setq i (1+ i))) | ||
| 891 | (if (= i len) | ||
| 892 | (setq trans (mapconcat 'identity trans ""))))) | ||
| 893 | (setq dic (cons (cons key trans) dic))) | ||
| 894 | table))) | ||
| 895 | (setq dic (sort dic (function (lambda (x y) (string< (car x) (car y)))))) | ||
| 896 | (goto-char (point-max)) | ||
| 897 | (insert (format "%S\n" "$A::WVJdHk!K!>WTH;!?!K(B | ||
| 898 | |||
| 899 | $A<|EL6TUU1m(B: | ||
| 900 | $A)3)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)7(B | ||
| 901 | $A)'#Q(B $A)'#W(B $A)'#E(B $A)'#R(B $A)'#T(B $A)'#Y(B $A)'#U(Bsh$A)'#I(Bch$A)'#O(B $A)'#P(B $A)'(B | ||
| 902 | $A)'(B iu$A)'(B ua$A)'(B e$A)'(B uan$A)'(B ue$A)'(B uai$A)'(B u$A)'(B i$A)'(B o$A)'(B un$A)'(B | ||
| 903 | $A)'(B $A)'(B ia$A)'(B $A)'(B van$A)'(B ve$A)'(B ing$A)'(B $A)'(B $A)'(B uo$A)'(B vn$A)'(B | ||
| 904 | $A);)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)?(B | ||
| 905 | $A)'#A(B $A)'#S(B $A)'#D(B $A)'#F(B $A)'#G(B $A)'#H(B $A)'#J(B $A)'#K(B $A)'#L(B $A)'(B | ||
| 906 | $A)'(B a$A)'(Biong$A)'(Buang$A)'(B en$A)'(B eng$A)'(B ang$A)'(B an$A)'(B ao$A)'(B ai$A)'(B | ||
| 907 | $A)'(B $A)'(B ong$A)'(Biang$A)'(B $A)'(B ng$A)'(B $A)'(B $A)'(B $A)'(B $A)'(B | ||
| 908 | $A);)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)%)7(B | ||
| 909 | $A)'#Z(B $A)'#X(B $A)'#C(B $A)'#V(Bzh$A)'#B(B $A)'#N(B $A)'#M(B $A)'#,(B $A)'#.(B $A)'(B $A#/(B $A)'(B | ||
| 910 | $A)'(B ei$A)'(B ie$A)'(B iao$A)'(B ui$A)'(B ou$A)'(B in$A)'(B ian$A)'G0R3)':sR3)'7{:E)'(B | ||
| 911 | $A)'(B $A)'(B $A)'(B $A)'(B v$A)'(B $A)'(B $A)'(B $A)'(B $A)'(B $A)'(B $A)'(B | ||
| 912 | $A);)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)?(B | ||
| 913 | |||
| 914 | |||
| 915 | Pinyin base input method for Chinese GB2312 characters (`chinese-gb2312'). | ||
| 916 | |||
| 917 | Pinyin is the standard roman transliteration method for Chinese. | ||
| 918 | For the details of Pinyin system, see the documentation of the input | ||
| 919 | method `chinese-py'. | ||
| 920 | |||
| 921 | Unlike the standard spelling of Pinyin, in this input method all | ||
| 922 | initials and finals are assigned to single keys (see the above table). | ||
| 923 | For instance, the initial \"ch\" is assigned to the key `i', the final | ||
| 924 | \"iu\" is assigned to the key `q', and tones 1, 2, 3, 4, and $AGaIy(B are | ||
| 925 | assigned to the keys `q', `w', `e', `r', `t' respectively. | ||
| 926 | |||
| 927 | \\<quail-translation-docstring> | ||
| 928 | |||
| 929 | To input one-letter words, you type 4 keys, the first two for the | ||
| 930 | Pinyin of the letter, next one for tone, and the last one is always a | ||
| 931 | quote ('). For instance, \"vsq'\" input $AVP(B. Exceptions are these | ||
| 932 | letters. You can input them just by typing a single key. | ||
| 933 | |||
| 934 | Character: $A04(B $A2;(B $A4N(B $A5D(B $A6~(B $A7"(B $A8v(B $A:M(B $A3v(B $A<0(B $A?I(B $AAK(B $AC;(B | ||
| 935 | Key: a b c d e f g h i j k l m | ||
| 936 | Character: $ADc(B $AE7(B $AF,(B $AF_(B $AHK(B $AH}(B $AK{(B $AJG(B $AWE(B $ANR(B $AP!(B $AR;(B $ATZ(B | ||
| 937 | Key: n o p q r s t u v w x y z | ||
| 938 | |||
| 939 | To input two-letter words, you have two ways. One way is to type 4 | ||
| 940 | keys, two for the first Pinyin, two for the second Pinyin. For | ||
| 941 | instance, \"vsgo\" inputs $AVP9z(B. Another way is to type 3 keys: 2 | ||
| 942 | initials of two letters, and quote ('). For instance, \"vg'\" also | ||
| 943 | inputs $AVP9z(B. | ||
| 944 | |||
| 945 | To input three-letter words, you type 4 keys: initials of three | ||
| 946 | letters, and the last is quote ('). For instance, \"bjy'2\" inputs $A11(B | ||
| 947 | $A>)Q<(B (the last `2' is to select one of the candidates). | ||
| 948 | |||
| 949 | To input words of more than three letters, you type 4 keys, initials | ||
| 950 | of the first three letters and the last letter. For instance, | ||
| 951 | \"bjdt\" inputs $A11>)5gJSL((B. | ||
| 952 | |||
| 953 | To input symbols and punctuations, type `/' followed by one of `a' to | ||
| 954 | `z', then select one of the candidates.")) | ||
| 955 | (insert " '((\"\C-?\" . quail-delete-last-char) | ||
| 956 | (\".\" . quail-next-translation) | ||
| 957 | (\"[\" . quail-next-translation) | ||
| 958 | (\",\" . quail-prev-translation) | ||
| 959 | (\"]\" . quail-prev-translation)) | ||
| 960 | nil nil nil nil)\n\n") | ||
| 961 | (insert "(quail-define-rules\n") | ||
| 962 | (dolist (elt dic) | ||
| 963 | (insert (format "(%S %S)\n" (car elt) (cdr elt)))) | ||
| 964 | (insert ")\n"))) | ||
| 965 | |||
| 966 | (defun miscdic-convert (filename &optional dirname) | ||
| 967 | "Convert a dictionary file FILENAME into a Quail package. | ||
| 968 | Optional argument DIRNAME if specified is the directory name under which | ||
| 969 | the generated Quail package is saved." | ||
| 970 | (interactive "FInput method dictionary file: ") | ||
| 971 | (or (file-readable-p filename) | ||
| 972 | (error "%s does not exist" filename)) | ||
| 973 | (let ((tail quail-misc-package-ext-info) | ||
| 974 | (default-buffer-file-coding-system 'iso-2022-7bit) | ||
| 975 | slot | ||
| 976 | name title dicfile coding quailfile converter copyright | ||
| 977 | dicbuf) | ||
| 978 | (while tail | ||
| 979 | (when (string-match (nth 2 (car tail)) filename) | ||
| 980 | (setq slot (car tail) | ||
| 981 | name (car slot) | ||
| 982 | title (nth 1 slot) | ||
| 983 | dicfile (nth 2 slot) | ||
| 984 | coding (nth 3 slot) | ||
| 985 | quailfile (nth 4 slot) | ||
| 986 | converter (nth 5 slot) | ||
| 987 | copyright (nth 6 slot)) | ||
| 988 | (message "Converting %s to %s..." dicfile quailfile) | ||
| 989 | (with-temp-file (expand-file-name quailfile dirname) | ||
| 990 | (set-buffer-file-coding-system 'iso-2022-7bit) | ||
| 991 | (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; -*-\n") | ||
| 992 | (insert ";; Generated by the command `miscdic-convert'\n") | ||
| 993 | (insert ";; Date: " (current-time-string) "\n") | ||
| 994 | (insert ";; Source dictionary file: " dicfile "\n") | ||
| 995 | (insert ";; Copyright notice of the source file\n") | ||
| 996 | (insert ";;------------------------------------------------------\n") | ||
| 997 | (insert copyright "\n") | ||
| 998 | (insert ";;------------------------------------------------------\n") | ||
| 999 | (insert "\n") | ||
| 1000 | (insert ";;; Code:\n\n") | ||
| 1001 | (insert "(require 'quail)\n") | ||
| 1002 | (insert "(quail-define-package \"" name "\" \"" | ||
| 1003 | (if (eq coding 'big5) "Chiense-BIG5" "Chienge-CNS") | ||
| 1004 | "\" \"" title "\" t\n") | ||
| 1005 | (let* ((coding-system-for-read coding) | ||
| 1006 | (dicbuf (find-file-noselect filename))) | ||
| 1007 | (funcall converter dicbuf name title) | ||
| 1008 | (kill-buffer dicbuf))) | ||
| 1009 | (message "Converting %s to %s...done" dicfile quailfile)) | ||
| 1010 | (setq tail (cdr tail))))) | ||
| 1011 | |||
| 1012 | (defun batch-miscdic-convert () | ||
| 1013 | "Run `miscdic-convert' on the files remaing on the command line. | ||
| 1014 | Use this from the command line, with `-batch'; | ||
| 1015 | it won't work in an interactive Emacs. | ||
| 1016 | If there's an argument \"-dir\", the next argument specifies a directory | ||
| 1017 | to store generated Quail packages." | ||
| 1018 | (defvar command-line-args-left) ; Avoid compiler warning. | ||
| 1019 | (if (not noninteractive) | ||
| 1020 | (error "`batch-miscdic-convert' should be used only with -batch")) | ||
| 1021 | (let ((dir default-directory) | ||
| 1022 | filename) | ||
| 1023 | (while command-line-args-left | ||
| 1024 | (if (string= (car command-line-args-left) "-dir") | ||
| 1025 | (progn | ||
| 1026 | (setq command-line-args-left (cdr command-line-args-left)) | ||
| 1027 | (setq dir (car command-line-args-left)))) | ||
| 1028 | (setq filename (car command-line-args-left) | ||
| 1029 | command-line-args-left (cdr command-line-args-left)) | ||
| 1030 | (if (file-directory-p filename) | ||
| 1031 | (dolist (file (directory-files filename t nil t)) | ||
| 1032 | (miscdic-convert file dir)) | ||
| 1033 | (miscdic-convert filename dir)))) | ||
| 1034 | (kill-emacs 0)) | ||
| 1035 | |||
| 642 | ;;; titdic-cnv.el ends here | 1036 | ;;; titdic-cnv.el ends here |
| 643 | 1037 | ||
| 644 | ;; Local Variables: | 1038 | ;; Local Variables: |