Meiyo Peng wrote 6 years ago
(address . guix-patches@gnu.org)
Hi,
These patches add Rime Input Method Engine to guix.
Rime Input Method Engine is a lightweight, extensible input method
engine supporting various input schemas including glyph-based input
methods, romanization-based input methods as well as those for Chinese
dialects. It has the ability to compose phrases and sentences
intelligently and provide very accurate traditional Chinese output.
Rime is very popular among Chinese users. I prefer it over libpinyin.
But sadly, libpinyin (both in ibus and fcitx) is the only option for
pinyin in guix.
I have already tested these patches on my computer. It works fine.
Please inform me if there is any issue with the code.
--
Meiyo Peng
From 3395d2d7642eacfea05446d3bf47b9bf8e12c1bb Mon Sep 17 00:00:00 2001
From: Meiyo Peng <meiyo.peng@gmail.com>
Date: Mon, 29 Oct 2018 11:17:50 +0800
Subject: [PATCH 1/6] gnu: Add marisa.
* gnu/packages/datastructures.scm (marisa): New variable.
---
gnu/packages/datastructures.scm | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
Toggle diff (58 lines)
diff --git a/gnu/packages/datastructures.scm b/gnu/packages/datastructures.scm
index 8517654de..e021cc6a6 100644
--- a/gnu/packages/datastructures.scm
+++ b/gnu/packages/datastructures.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016, 2017 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,6 +21,7 @@
(define-module (gnu packages datastructures)
#:use-module (gnu packages)
#:use-module (gnu packages perl)
+ #:use-module (gnu packages autotools)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
@@ -48,6 +50,35 @@ binary trees, binary search trees, red-black trees, 2D arrays, permutations
and heaps.")
(license license:gpl2+)))
+(define-public marisa
+ (package
+ (name "marisa")
+ (version "0.2.5")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/s-yata/marisa-trie"
+ "/releases/download/v" version "/" name "-"
+ version ".tar.gz"))
+ (sha256
+ (base32 "19ifrcmnbr9whaaf4ly3s9ndyiq9sjqhnfkrxbz9zsb44w2n36hf"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'autoreconf
+ (lambda _
+ (invoke "autoreconf" "-i"))))))
+ (native-inputs
+ `(("autoconf" ,autoconf)
+ ("automake" ,automake)
+ ("libtool" ,libtool)))
+ (home-page "https://github.com/s-yata/marisa-trie")
+ (synopsis "Matching Algorithm with Recursively Implemented StorAge")
+ (description "Matching Algorithm with Recursively Implemented
+StorAge (MARISA) is a static and space-efficient trie data structure.")
+ (license (list license:bsd-2 license:lgpl2.1+))))
+
(define-public sparsehash
(package
(name "sparsehash")
--
2.19.1
From 957248cfe9e4b7d14a47e06e37a8dede625eab36 Mon Sep 17 00:00:00 2001
From: Meiyo Peng <meiyo.peng@gmail.com>
Date: Mon, 29 Oct 2018 11:22:55 +0800
Subject: [PATCH 2/6] gnu: Add opencc.
* gnu/packages/textutils.scm (opencc): New variable.
---
gnu/packages/textutils.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
Toggle diff (41 lines)
diff --git a/gnu/packages/textutils.scm b/gnu/packages/textutils.scm
index 8780bb282..852b5110e 100644
--- a/gnu/packages/textutils.scm
+++ b/gnu/packages/textutils.scm
@@ -15,6 +15,7 @@
;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
+;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -756,3 +757,26 @@ indentation.
@end itemize\n")
(home-page "http://docx2txt.sourceforge.net")
(license license:gpl3+)))
+
+(define-public opencc
+ (package
+ (name "opencc")
+ (version "1.0.5")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/BYVoid/OpenCC"
+ "/archive/ver." version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "01870gbkf711msirf3206k0ajaabypjhnx3fny5wikw0ladn9q8w"))))
+ (build-system cmake-build-system)
+ (native-inputs
+ `(("python" ,python-2)))
+ (home-page "https://github.com/BYVoid/OpenCC")
+ (synopsis "Open Chinese Convert")
+ (description "Open Chinese Convert (OpenCC) is an opensource project for
+conversion between Traditional Chinese and Simplified Chinese, supporting
+character-level conversion, phrase-level conversion, variant conversion and
+regional idioms among Mainland China, Taiwan and Hong kong.")
+ (license license:asl2.0)))
--
2.19.1
From 1bbc5928dd09caee09804cf7eb226b329e76c2bf Mon Sep 17 00:00:00 2001
From: Meiyo Peng <meiyo.peng@gmail.com>
Date: Mon, 29 Oct 2018 11:29:33 +0800
Subject: [PATCH 4/6] gnu: Add librime.
* gnu/packages/ibus.scm (librime): New variable.
---
gnu/packages/ibus.scm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
Toggle diff (76 lines)
diff --git a/gnu/packages/ibus.scm b/gnu/packages/ibus.scm
index 40fa93029..f689c02ba 100644
--- a/gnu/packages/ibus.scm
+++ b/gnu/packages/ibus.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -24,21 +25,27 @@
#:use-module (guix licenses)
#:use-module (guix packages)
#:use-module (guix download)
+ #:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
#:use-module (guix build-system glib-or-gtk)
#:use-module (gnu packages)
#:use-module (gnu packages anthy)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
+ #:use-module (gnu packages boost)
#:use-module (gnu packages databases)
+ #:use-module (gnu packages datastructures)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
#:use-module (gnu packages gtk)
#:use-module (gnu packages iso-codes)
+ #:use-module (gnu packages logging)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
+ #:use-module (gnu packages serialization)
+ #:use-module (gnu packages textutils)
#:use-module (gnu packages xorg))
(define-public ibus
@@ -279,3 +286,33 @@ applications allow text input via IBus, installing this package will enable
Japanese language input in most graphical applications.")
(home-page "https://github.com/fujiwarat/ibus-anthy")
(license gpl2+)))
+
+(define-public librime
+ (package
+ (name "librime")
+ (version "1.3.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/rime/" name
+ "/archive/" version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "0qh0hy8bvj17bnzaxk0bmv4gsnbsd6jx8csr84936xmhkrysdday"))))
+ (build-system cmake-build-system)
+ (inputs
+ `(("boost" ,boost)
+ ("glog" ,glog)
+ ("leveldb" ,leveldb)
+ ("marisa" ,marisa)
+ ("opencc" ,opencc)
+ ("yaml-cpp" ,yaml-cpp)))
+ (home-page "https://rime.im/")
+ (synopsis "The core library of Rime Input Method Engine")
+ (description "@dfn{librime} is the core library of Rime Input Method
+Engine, which is a lightweight, extensible input method engine supporting
+various input schemas including glyph-based input methods, romanization-based
+input methods as well as those for Chinese dialects. It has the ability to
+compose phrases and sentences intelligently and provide very accurate
+traditional Chinese output.")
+ (license bsd-3)))
--
2.19.1
From 80a75361b8c47e80495a068c810a5f5ff0a845b0 Mon Sep 17 00:00:00 2001
From: Meiyo Peng <meiyo.peng@gmail.com>
Date: Mon, 29 Oct 2018 11:46:03 +0800
Subject: [PATCH 6/6] gnu: Add ibus-rime.
* gnu/packages/ibus.scm (ibus-rime): New variable.
---
gnu/packages/ibus.scm | 59 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
Toggle diff (76 lines)
diff --git a/gnu/packages/ibus.scm b/gnu/packages/ibus.scm
index 870d28562..0a07b5190 100644
--- a/gnu/packages/ibus.scm
+++ b/gnu/packages/ibus.scm
@@ -34,6 +34,7 @@
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
#:use-module (gnu packages boost)
+ #:use-module (gnu packages cmake)
#:use-module (gnu packages databases)
#:use-module (gnu packages datastructures)
#:use-module (gnu packages freedesktop)
@@ -586,3 +587,61 @@ traditional Chinese output.")
(description "@dfn{rime-data} provides the schema data of Rime Input
Method Engine.")
(license lgpl3+)))
+
+(define-public ibus-rime
+ (package
+ (name "ibus-rime")
+ (version "1.3.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/rime/" name
+ "/archive/" version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "0mfbz0vwky7n4wvxrwabnn1i9n9adnql0dd1rx57w1anaslr5amj"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ; no tests
+ #:make-flags (list (string-append "PREFIX=" %output))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-source
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; Define RIME_DATA_DIR. It's required but not used by the code.
+ (substitute* "Makefile"
+ (("cmake")
+ (string-append "cmake -DRIME_DATA_DIR="
+ (assoc-ref inputs "rime-data")
+ "/share/rime-data")))
+ (substitute* "rime_config.h"
+ (("#define IBUS_RIME_INSTALL_PREFIX .*")
+ (string-append "#define IBUS_RIME_INSTALL_PREFIX \""
+ (assoc-ref outputs "out")
+ "\"\n")))
+ ;; rime_config.h defines the actual data directory.
+ (substitute* "rime_config.h"
+ (("#define IBUS_RIME_SHARED_DATA_DIR .*")
+ (string-append "#define IBUS_RIME_SHARED_DATA_DIR \""
+ (assoc-ref inputs "rime-data")
+ "/share/rime-data\"\n")))
+ #t))
+ (delete 'configure))))
+ (inputs
+ `(("gdk-pixbuf" ,gdk-pixbuf)
+ ("glib" ,glib)
+ ("ibus" ,ibus)
+ ("libnotify" ,libnotify)
+ ("librime" ,librime)
+ ("rime-data" ,rime-data)))
+ (native-inputs
+ `(("cmake" ,cmake)
+ ("pkg-config" ,pkg-config)))
+ (home-page "https://rime.im/")
+ (synopsis "Rime Input Method Engine for IBus")
+ (description "@dfn{Rime} Input Method Engine is a lightweight, extensible
+input method engine supporting various input schemas including glyph-based
+input methods, romanization-based input methods as well as those for Chinese
+dialects. It has the ability to compose phrases and sentences intelligently
+and provide very accurate traditional Chinese output.")
+ (license gpl3+)))
--
2.19.1