guile-mecab/guix/mecab.scm

mecab.scm

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