mecab.scm
| 1 | (define-module (packages mecab) |
| 2 | #:use-module (guix packages) |
| 3 | #:use-module (guix git-download) |
| 4 | #:use-module ((guix licenses) #:prefix license:) |
| 5 | #:use-module (guix build-system gnu) |
| 6 | #:use-module (gnu packages) |
| 7 | #:use-module (gnu packages autotools) |
| 8 | #:use-module (gnu packages base) |
| 9 | #:use-module (gnu packages guile) |
| 10 | #:use-module (gnu packages guile-xyz) |
| 11 | #:use-module (gnu packages pkg-config)) |
| 12 | |
| 13 | (define-public mecab |
| 14 | (package |
| 15 | (name "mecab") |
| 16 | (version "0.996") |
| 17 | (source (origin |
| 18 | (method git-fetch) |
| 19 | (uri (git-reference |
| 20 | (url "https://github.com/taku910/mecab") |
| 21 | ;; latest commit |
| 22 | (commit "046fa78b2ed56fbd4fac312040f6d62fc1bc31e3"))) |
| 23 | (file-name (git-file-name name version)) |
| 24 | (sha256 |
| 25 | (base32 |
| 26 | "1hdv7rgn8j0ym9gsbigydwrbxa8cx2fb0qngg1ya15vvbw0lk4aa")) |
| 27 | (patches |
| 28 | (search-patches |
| 29 | "mecab-variable-param.patch")))) |
| 30 | (build-system gnu-build-system) |
| 31 | (native-search-paths |
| 32 | (list (search-path-specification |
| 33 | (variable "MECAB_DICDIR") |
| 34 | (separator #f) |
| 35 | (files '("lib/mecab/dic"))))) |
| 36 | (arguments |
| 37 | `(#:phases |
| 38 | (modify-phases %standard-phases |
| 39 | (add-after 'unpack 'chdir |
| 40 | (lambda _ |
| 41 | (chdir "mecab"))) |
| 42 | (add-before 'build 'add-mecab-dicdir-variable |
| 43 | (lambda _ |
| 44 | (substitute* "mecabrc.in" |
| 45 | (("dicdir = .*") |
| 46 | "dicdir = $MECAB_DICDIR")) |
| 47 | (substitute* "mecab-config.in" |
| 48 | (("echo @libdir@/mecab/dic") |
| 49 | "if [ -z \"$MECAB_DICDIR\" ]; then |
| 50 | echo @libdir@/mecab/dic |
| 51 | else |
| 52 | echo \"$MECAB_DICDIR\" |
| 53 | fi"))))))) |
| 54 | (inputs (list libiconv)) |
| 55 | (home-page "https://taku910.github.io/mecab") |
| 56 | (synopsis "Morphological analysis engine for texts") |
| 57 | (description "Mecab is a morphological analysis engine developped as a |
| 58 | collaboration between the Kyoto university and Nippon Telegraph and Telephone |
| 59 | Corporation. The engine is independent of any language, dictionary or corpus.") |
| 60 | (license (list license:gpl2+ license:lgpl2.1+ license:bsd-3)))) |
| 61 | |
| 62 | (define-public mecab-ipadic |
| 63 | (package |
| 64 | (name "mecab-ipadic") |
| 65 | (version "2.7.0") |
| 66 | (source (package-source mecab)) |
| 67 | (build-system gnu-build-system) |
| 68 | (arguments |
| 69 | `(#:configure-flags |
| 70 | (list (string-append "--with-dicdir=" (assoc-ref %outputs "out") |
| 71 | "/lib/mecab/dic") |
| 72 | "--with-charset=utf8") |
| 73 | #:phases |
| 74 | (modify-phases %standard-phases |
| 75 | (add-after 'unpack 'chdir |
| 76 | (lambda _ |
| 77 | (chdir "mecab-ipadic"))) |
| 78 | (add-before 'configure 'set-mecab-dir |
| 79 | (lambda* (#:key outputs #:allow-other-keys) |
| 80 | (setenv "MECAB_DICDIR" (string-append (assoc-ref outputs "out") |
| 81 | "/lib/mecab/dic"))))))) |
| 82 | (native-inputs (list mecab)); for mecab-config |
| 83 | (home-page "https://taku910.github.io/mecab") |
| 84 | (synopsis "Dictionary data for MeCab") |
| 85 | (description "This package contains dictionnary data derived from |
| 86 | ipadic for use with MeCab.") |
| 87 | (license (license:non-copyleft "mecab-ipadic/COPYING")))) |
| 88 | |
| 89 | |
| 90 | (define-public guile-mecab |
| 91 | (package |
| 92 | (name "guile-mecab") |
| 93 | (version "0") |
| 94 | (source (origin |
| 95 | (method git-fetch) |
| 96 | (uri (git-reference |
| 97 | (url "https://git.lepiller.eu/git/guile-mecab") |
| 98 | (commit "a0cc754316ba84cb5fbf617795e7b28316442f82"))) |
| 99 | (file-name (git-file-name name version)) |
| 100 | (sha256 |
| 101 | (base32 |
| 102 | "0q9kb7yli7vvdd9y4xzaxdv654dr65f6gwjpc6qwb7q01npmjf5n")))) |
| 103 | (build-system gnu-build-system) |
| 104 | (arguments |
| 105 | `(#:phases |
| 106 | (modify-phases %standard-phases |
| 107 | (add-after 'unpack 'set-writable |
| 108 | (lambda _ |
| 109 | (for-each |
| 110 | (lambda (file) (chmod file #o644)) |
| 111 | (find-files "." ".")))) |
| 112 | (add-after 'set-writable 'clean |
| 113 | (lambda _ |
| 114 | (when (file-exists? "Makefile") |
| 115 | (invoke "make" "distclean"))))))) |
| 116 | (inputs |
| 117 | `(("mecab" ,mecab))) |
| 118 | (propagated-inputs |
| 119 | `(("guile-bytestructures" ,guile-bytestructures))) |
| 120 | (native-inputs |
| 121 | `(("autoconf" ,autoconf) |
| 122 | ("automake" ,automake) |
| 123 | ("guile" ,guile-3.0) |
| 124 | ("pkg-config" ,pkg-config))) |
| 125 | (home-page "") |
| 126 | (synopsis "") |
| 127 | (description "") |
| 128 | (license license:gpl3+))) |
| 129 |