projects/guix·blob python-team · refs

593 lines · 24.2 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020, 2021 Giacomo Leidi <[email protected]>
3;;; Copyright © 2023 Efraim Flashner <[email protected]>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages hunspell)
21 #:use-module (guix build-system gnu)
22 #:use-module (guix build-system trivial)
23 #:use-module (guix download)
24 #:use-module (guix gexp)
25 #:use-module (guix git-download)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (ice-9 match)
29 #:use-module (gnu packages aspell)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages m4)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages textutils))
36
37(define-public hunspell
38 (package
39 (name "hunspell")
40 (version "1.7.0")
41 (source
42 (origin
43 (method git-fetch)
44 (uri (git-reference
45 (url "https://github.com/hunspell/hunspell")
46 (commit (string-append "v" version))))
47 (file-name (git-file-name name version))
48 (sha256
49 (base32
50 "0qxlkd012r45ppd21kldbq9k5ac5nmxz290z6m2kch9l56v768k1"))))
51 (build-system gnu-build-system)
52 (native-inputs
53 (list autoconf automake libtool))
54 (inputs
55 (list perl))
56 (native-search-paths (list (search-path-specification
57 (variable "DICPATH")
58 (files '("share/hunspell")))))
59 (home-page "https://hunspell.github.io/")
60 (synopsis "Spell checker")
61 (description "Hunspell is a spell checker and morphological analyzer
62library and program designed for languages with rich morphology and complex
63word compounding or character encoding.")
64 ;; Triple license, including "mpl1.1 or later".
65 (license (list license:mpl1.1 license:gpl2+ license:lgpl2.1+))))
66
67(define (dicollecte-french-dictionary variant synopsis)
68 ;; Return a French dictionary package from dicollecte.org, for the given
69 ;; VARIANT.
70 (package
71 (name (match variant
72 ("classique" "hunspell-dict-fr")
73 (_ (string-append "hunspell-dict-fr-" variant))))
74 (version "6.2")
75 (source (origin
76 (uri (string-append
77 "http://www.dicollecte.org/download/fr/hunspell-french-dictionaries-v"
78 version ".zip"))
79 (method url-fetch)
80 (sha256
81 (base32
82 "139hfrn5p87sl8hqmgkf6sgvnxrk2mm8vd8xsm8sm98qjnwlg0f9"))))
83 (build-system trivial-build-system)
84 (native-inputs (list unzip))
85 (arguments
86 `(#:modules ((guix build utils))
87 #:builder (begin
88 (use-modules (guix build utils)
89 (srfi srfi-26))
90
91 (let* ((out (assoc-ref %outputs "out"))
92 (hunspell (string-append out "/share/hunspell"))
93 (myspell (string-append out "/share/myspell"))
94 (doc (string-append out "/share/doc/"
95 ,name))
96 (unzip (assoc-ref %build-inputs "unzip")))
97 (invoke (string-append unzip "/bin/unzip")
98 (assoc-ref %build-inputs "source"))
99 (for-each (cut install-file <> hunspell)
100 (find-files "."
101 ,(string-append variant
102 "\\.(dic|aff)$")))
103 (mkdir-p myspell)
104 (symlink hunspell (string-append myspell "/dicts"))
105 (for-each (cut install-file <> doc)
106 (find-files "." "\\.(txt|org|md)$"))
107 #t))))
108 (synopsis synopsis)
109 (description
110 "This package provides a dictionary for the Hunspell spell-checking
111library.")
112 (home-page "https://www.dicollecte.org/home.php?prj=fr")
113 (license license:mpl2.0)))
114
115(define-syntax define-french-dictionary
116 (syntax-rules (synopsis)
117 ((_ name variant (synopsis text))
118 (define-public name
119 (dicollecte-french-dictionary variant text)))))
120
121(define-french-dictionary hunspell-dict-fr-classique
122 "classique"
123 ;; TRANSLATORS: In French, this is "Français classique".
124 (synopsis "Hunspell dictionary for ``classic'' French (recommended)"))
125
126(define-french-dictionary hunspell-dict-fr-moderne
127 "moderne"
128 ;; TRANSLATORS: In French, this is "Français moderne".
129 (synopsis "Hunspell dictionary for ``modern'' French"))
130
131(define-french-dictionary hunspell-dict-fr-réforme-1990
132 "reforme1990"
133 (synopsis "Hunspell dictionary for the post @dfn{1990 réforme} French"))
134
135(define-french-dictionary hunspell-dict-fr-toutes-variantes
136 "toutesvariantes"
137 (synopsis "Hunspell dictionary for all variants of French"))
138
139(define-public hunspell-dict-pl
140 (package
141 (name "hunspell-dict-pl")
142 (version "20200327")
143 (source
144 (origin
145 (method url-fetch)
146 ;; Since creators of dictionary host only the latest daily release,
147 ;; we're using version mirrored by Arch Linux, which seems good
148 ;; enough. They're mirroring hunspell-pl releases since 2011.
149 (uri (string-append "https://sources.archlinux.org/other/community/"
150 "hunspell-pl/sjp-myspell-pl-"
151 version ".zip"))
152 (sha256 (base32
153 "14mzf8glxkp2775dcqisb1zv6r8ncm3bvzl46q352rwyl2dg1c59"))))
154
155 (build-system trivial-build-system)
156 (native-inputs (list unzip))
157 (arguments
158 `(#:modules ((guix build utils))
159 #:builder (begin
160 (use-modules (guix build utils)
161 (srfi srfi-26))
162
163 (let* ((out (assoc-ref %outputs "out"))
164 (hunspell (string-append out "/share/hunspell"))
165 (myspell (string-append out "/share/myspell"))
166 (doc (string-append out "/share/doc/"
167 ,name))
168 (unzip (search-input-file %build-inputs
169 "/bin/unzip")))
170 (invoke unzip "-j" "-o" (assoc-ref %build-inputs "source"))
171 (invoke unzip "-j" "-o" "pl_PL.zip")
172 (for-each (cut install-file <> hunspell)
173 (find-files "."
174 ,(string-append "pl_PL"
175 "\\.(dic|aff)$")))
176 (mkdir-p myspell)
177 (symlink hunspell (string-append myspell "/dicts"))
178 (for-each (cut install-file <> doc)
179 (find-files "." "\\.(txt|org|md)$"))
180 #t))))
181 (synopsis "Hunspell dictionary for Polish")
182 (description
183 "This package provides a dictionary for the Hunspell spell-checking
184library.")
185 (home-page "https://sjp.pl/slownik/ort/")
186 (license
187 (list license:gpl2 license:mpl1.1 license:cc-by4.0 license:lgpl2.1 license:asl2.0))))
188
189(define-public hunspell-dict-de
190 (package
191 (name "hunspell-dict-de")
192 (version "20161207")
193 (source
194 (origin
195 (method url-fetch)
196 (uri (string-append "https://www.j3e.de/ispell/igerman98/dict/"
197 "igerman98-" version ".tar.bz2"))
198 (sha256
199 (base32 "1a3055hp2bc4q4nlg3gmg0147p3a1zlfnc65xiv2v9pyql1nya8p"))))
200 (build-system gnu-build-system)
201 (arguments
202 `(#:make-flags '("hunspell/de_DE.dic")
203 #:phases
204 (modify-phases %standard-phases
205 (delete 'configure)
206 (replace 'install ;no install target
207 (lambda* (#:key outputs #:allow-other-keys)
208 (let* ((out (assoc-ref outputs "out"))
209 (share (string-append out "/share/hunspell/")))
210 (install-file "hunspell/de_DE.aff" share)
211 (install-file "hunspell/de_DE.dic" share)
212 #t))))
213 #:tests? #f)) ; no tests
214 (native-inputs
215 (list hunspell ispell perl))
216 (synopsis "Hunspell dictionary for German (de_DE)")
217 (description "This package provides a dictionary for the Hunspell
218spell-checking library.")
219 (home-page "https://www.j3e.de/ispell/igerman98/")
220 (license (list license:gpl2 license:gpl3))))
221
222(define-public hunspell-dict-de-at
223 (package
224 (name "hunspell-dict-de-at")
225 (version "20161207")
226 (source
227 (origin
228 (method url-fetch)
229 (uri (string-append "https://www.j3e.de/ispell/igerman98/dict/"
230 "igerman98-" version ".tar.bz2"))
231 (sha256
232 (base32 "1a3055hp2bc4q4nlg3gmg0147p3a1zlfnc65xiv2v9pyql1nya8p"))))
233 (build-system gnu-build-system)
234 (arguments
235 `(#:make-flags '("hunspell/de_AT.dic")
236 #:phases
237 (modify-phases %standard-phases
238 (delete 'configure)
239 (replace 'install ;no install target
240 (lambda* (#:key outputs #:allow-other-keys)
241 (let* ((out (assoc-ref outputs "out"))
242 (share (string-append out "/share/hunspell/")))
243 (install-file "hunspell/de_AT.aff" share)
244 (install-file "hunspell/de_AT.dic" share)
245 #t))))
246 #:tests? #f)) ; no tests
247 (native-inputs
248 (list hunspell ispell perl))
249 (synopsis "Hunspell dictionary for Austrian German (de_AT)")
250 (description "This package provides a dictionary for the Hunspell
251spell-checking library.")
252 (home-page "https://www.j3e.de/ispell/igerman98/")
253 (license (list license:gpl2 license:gpl3))))
254
255(define-public hunspell-dict-de-ch
256 (package
257 (name "hunspell-dict-de-ch")
258 (version "20161207")
259 (source
260 (origin
261 (method url-fetch)
262 (uri (string-append "https://www.j3e.de/ispell/igerman98/dict/"
263 "igerman98-" version ".tar.bz2"))
264 (sha256
265 (base32 "1a3055hp2bc4q4nlg3gmg0147p3a1zlfnc65xiv2v9pyql1nya8p"))))
266 (build-system gnu-build-system)
267 (arguments
268 `(#:make-flags '("hunspell/de_CH.dic")
269 #:phases
270 (modify-phases %standard-phases
271 (delete 'configure)
272 (replace 'install ;no install target
273 (lambda* (#:key outputs #:allow-other-keys)
274 (let* ((out (assoc-ref outputs "out"))
275 (share (string-append out "/share/hunspell/")))
276 (install-file "hunspell/de_CH.aff" share)
277 (install-file "hunspell/de_CH.dic" share)
278 #t))))
279 #:tests? #f)) ; no tests
280 (native-inputs
281 (list hunspell ispell perl))
282 (synopsis "Hunspell dictionary for Swiss German (de_CH)")
283 (description "This package provides a dictionary for the Hunspell
284spell-checking library.")
285 (home-page "https://www.j3e.de/ispell/igerman98/")
286 (license (list license:gpl2 license:gpl3))))
287
288(define-public hunspell-dict-hu
289 (let ((revision "2")
290 (major+minor "1.7"))
291 (package
292 (name "hunspell-dict-hu")
293 (version (string-append major+minor "-" revision))
294 (source
295 (origin
296 (method url-fetch)
297 (uri (string-append "mirror://sourceforge/magyarispell/Magyar Ispell/"
298 major+minor
299 "/magyarispell-" version ".tar.gz"))
300 (sha256
301 (base32 "0r22rvqrp5bzgr9sqyap82kibi5z9n6xy5b06si28idqijw7c772"))))
302 (build-system gnu-build-system)
303 (arguments
304 (list #:make-flags
305 #~(list "myspell"
306 "--jobs=1" ;the Makefile is not ready for parallelism
307 (string-append "SH="
308 (search-input-file %build-inputs
309 "/bin/bash"))
310 (string-append "AWK="
311 (search-input-file %build-inputs
312 "/bin/awk")))
313 #:phases
314 #~(modify-phases %standard-phases
315 (replace 'configure
316 (lambda* (#:key outputs #:allow-other-keys)
317 (substitute* "config"
318 (("/usr/bin/awk")
319 (which "awk")))))
320 (replace 'install ;no install target
321 (lambda* (#:key outputs #:allow-other-keys)
322 (let* ((out (assoc-ref outputs "out"))
323 (share (string-append out "/share/hunspell/")))
324 (install-file "hu_HU.aff" share)
325 (install-file "hu_HU.dic" share)))))
326 #:tests? #f)) ; no tests
327 (native-inputs
328 (list hunspell m4 recode))
329 (synopsis "Hunspell dictionary for Hungarian (hu_HU)")
330 (description "This package provides a dictionary for the Hunspell
331spell-checking library.")
332 (home-page "https://magyarispell.sourceforge.net/")
333 (license (list license:gpl2 license:gpl3)))))
334
335(define-public hunspell-dict-el
336 (let ((commit "8e799911aede4e2c340d1b5a67a07f8e22ab9c8e"))
337 (package
338 (name "hunspell-dict-el")
339 (version "0.1")
340 (source
341 (origin
342 (method git-fetch)
343 (uri (git-reference
344 (url "https://git.thanosapollo.org/hunspell-dict-el")
345 (commit commit)))
346 (file-name (git-file-name name version))
347 (sha256
348 (base32 "0z9nyfy50c0bjvvm42xwd3npjpp07a9slm3gfgvxanyqm7djrmb1"))))
349 (build-system gnu-build-system)
350 (arguments
351 `(#:phases (modify-phases %standard-phases
352 (delete 'build)
353 (delete 'configure)
354 (replace 'install
355 (lambda* (#:key outputs #:allow-other-keys)
356 (let* ((out (assoc-ref outputs "out"))
357 (share (string-append out "/share/hunspell/")))
358 (install-file "el_GR.aff" share)
359 (install-file "el_GR.dic" share) #t))))
360 #:tests? #f))
361 (native-inputs (list hunspell ispell perl))
362 (synopsis "Hunspell Greek/Hellenic dictionary")
363 (description "This package provides a dictionary for the Hunspell
364spell-checking library.")
365 (home-page "https://git.thanosapollo.org/hunspell-dict-el/")
366 (license (list license:gpl2 license:gpl3)))))
367
368(define-public hunspell-dict-el-polytonic
369 (let ((commit "ddb787b6a28767773ff2b6ed0092a6957e4825e3"))
370 (package
371 (name "hunspell-dict-el-polytonic")
372 (version "0.1")
373 (source
374 (origin
375 (method git-fetch)
376 (uri (git-reference
377 (url "https://git.thanosapollo.org/hunspell-dict-el-polytonic")
378 (commit commit)))
379 (file-name (git-file-name name version))
380 (sha256
381 (base32 "0ik14rcpxxmp35314rcip38nr0z8i3375l5k9ajf6ywx8r5i3zr9"))))
382 (build-system gnu-build-system)
383 (arguments
384 `(#:phases (modify-phases %standard-phases
385 (delete 'build)
386 (delete 'configure)
387 (replace 'install
388 (lambda* (#:key outputs #:allow-other-keys)
389 (let* ((out (assoc-ref outputs "out"))
390 (share (string-append out "/share/hunspell/")))
391 (install-file "el_GR.aff" share)
392 (install-file "el_GR.dic" share) #t))))
393 #:tests? #f))
394 (native-inputs (list hunspell ispell perl))
395 (synopsis "Hunspell Polytonic Greek/Hellenic dictionary")
396 (description "This package provides a dictionary for the Hunspell
397spell-checking library.")
398 (home-page "https://git.thanosapollo.org/hunspell-dict-el-polytonic")
399 (license (list license:gpl2 license:gpl3)))))
400
401(define* (hunspell-dictionary dict-name full-name #:key synopsis home-page license)
402 (package
403 (name (string-append
404 "hunspell-dict-"
405 ;; Downcase and replace underscore in package names
406 ;; to follow Guix naming conventions.
407 (string-map (match-lambda
408 (#\_ #\-)
409 (chr chr))
410 (string-downcase dict-name))))
411 (version "26.8.0.3")
412 (source
413 (origin
414 (method git-fetch)
415 (uri (git-reference
416 (url "https://github.com/LibreOffice/dictionaries")
417 (commit
418 (string-append "libreoffice-" version))))
419 (file-name (git-file-name "libreoffice-dictionaries" version))
420 (sha256
421 (base32 "1nfs0mv2n53xqi0h9ch61xdrj5bicfskv6w4yd8iq5db5dlpcqjk"))))
422 (build-system trivial-build-system)
423 (native-inputs
424 `(("source" ,source)))
425 (arguments
426 `(#:modules ((guix build utils))
427 #:builder (begin
428 (use-modules (guix build utils))
429 (let* ((dictionary
430 (string-append (assoc-ref %build-inputs "source")
431 "/" ,dict-name
432 "/" ,dict-name))
433 (hunspell (string-append %output "/share/hunspell/"))
434 (myspell (string-append %output "/share/myspell")))
435 (for-each
436 (lambda (ext)
437 (install-file (string-append dictionary ext)
438 hunspell))
439 '(".aff" ".dic"))
440 (symlink hunspell myspell)
441 #t))))
442 (synopsis synopsis)
443 (description "This package provides a dictionary for the Hunspell
444spell-checking library.")
445 (license license)
446 (home-page home-page)))
447
448(define-public hunspell-dict-he-il
449 (let ((synopsis identity))
450 (hunspell-dictionary "he_IL" "Hebrew"
451 #:synopsis (synopsis "Hunspell dictionary for Hebrew")
452 #:home-page "http://hspell.ivrix.org.il/"
453 #:license license:agpl3+)))
454
455(define-public hunspell-dict-it-it
456 (let ((synopsis identity))
457 (hunspell-dictionary "it_IT" "Italian"
458 #:synopsis (synopsis "Hunspell dictionary for Italian")
459 #:home-page "https://www.libreitalia.org/"
460 #:license license:gpl3)))
461
462(define-public hunspell-dict-pt-br
463 (let ((synopsis identity))
464 (hunspell-dictionary "pt_BR" "Portuguese (Brazil)"
465 #:synopsis (synopsis "Hunspell dictionary for Portuguese (Brazil)")
466 #:home-page "https://cgit.freedesktop.org/libreoffice/dictionaries/tree/pt_BR"
467 #:license (list license:lgpl3+))))
468
469
470(define-public hunspell-dict-pt-pt
471 (let ((synopsis identity))
472 (hunspell-dictionary "pt_PT" "Portuguese (Portugal)"
473 #:synopsis (synopsis "Hunspell dictionary for Portuguese (Portugal)")
474 #:home-page "https://cgit.freedesktop.org/libreoffice/dictionaries/tree/pt_PT"
475 #:license (list license:gpl2+))))
476
477;;;
478;;; Hunspell packages made from the Aspell word lists.
479;;;
480
481(define* (aspell-word-list language synopsis
482 #:optional
483 (nick (string-map (lambda (chr)
484 (if (char=? #\_ chr)
485 #\-
486 chr))
487 (string-downcase language))))
488 (package
489 (name (string-append "hunspell-dict-" nick))
490 (version "2018.04.16")
491 (source (origin
492 (method url-fetch)
493 (uri (string-append
494 "mirror://sourceforge/wordlist/SCOWL/"
495 version "/scowl-" version ".tar.gz"))
496 (sha256
497 (base32
498 "11lkrnhwrf5mvrrq45k4mads3n9aswgac8dc25ba61c75alxb5rs"))))
499 (native-inputs
500 (list tar gzip perl aspell))
501 (build-system gnu-build-system)
502 (arguments
503 `(#:phases
504 (modify-phases %standard-phases
505 (add-after 'unpack 'make-reproducible
506 (lambda _
507 (substitute* "speller/README_en.txt.sh"
508 (("\\bdate\\b") ""))))
509 (delete 'configure)
510 (delete 'check)
511 (replace 'build
512 (lambda _
513 (substitute* "speller/make-hunspell-dict"
514 (("zip -9 .*$")
515 "return\n"))
516 (mkdir "speller/hunspell")
517
518 ;; XXX: This actually builds all the dictionary variants.
519 (invoke "make" "-C" "speller" "hunspell")))
520 (replace 'install
521 (lambda* (#:key outputs #:allow-other-keys)
522 (let* ((out (assoc-ref %outputs "out"))
523 (hunspell (string-append out "/share/hunspell"))
524 (myspell (string-append out "/share/myspell"))
525 (doc (string-append out "/share/doc/"
526 ,name))
527 (dot-dic ,(string-append "speller/" language ".dic")))
528 (mkdir-p myspell)
529
530 ;; Usually there's only a 'LANGUAGE.dic' file, but for the "en"
531 ;; dictionary, there no 'en.dic'. Instead, there's a set of
532 ;; 'en*.dic' files, hence the 'find-files' call below.
533 (if (file-exists? dot-dic)
534 (install-file dot-dic hunspell)
535 (for-each (lambda (dic)
536 (install-file dic hunspell))
537 (find-files "speller"
538 ,(string-append language ".*\\.dic$"))))
539
540 ;; Install affix files corresponding to installed dictionaries
541 (for-each (lambda (dic)
542 (install-file (string-append
543 "speller/" (basename dic ".dic") ".aff")
544 hunspell))
545 (find-files hunspell ".*\\.dic$"))
546 (symlink hunspell (string-append myspell "/dicts"))
547 (for-each (lambda (file)
548 (install-file file doc))
549 (find-files "."
550 "^(Copyright|.*\\.(txt|org|md))$"))
551 #t))))))
552 (synopsis synopsis)
553 (description
554 "This package provides a dictionary for the Hunspell spell-checking
555library.")
556 (home-page "http://wordlist.aspell.net/")
557 (license (license:non-copyleft "file://Copyright"
558 "Word lists come from several sources, all
559under permissive licensing terms. See the 'Copyright' file."))))
560
561(define-syntax define-word-list-dictionary
562 (syntax-rules (synopsis)
563 ((_ name language (synopsis text))
564 (define-public name
565 (aspell-word-list language text)))
566 ((_ name language nick (synopsis text))
567 (define-public name
568 (aspell-word-list language text nick)))))
569
570(define-word-list-dictionary hunspell-dict-en
571 "en"
572 (synopsis "Hunspell dictionary for English"))
573
574(define-word-list-dictionary hunspell-dict-en-au
575 "en_AU"
576 (synopsis "Hunspell dictionary for Australian English"))
577
578(define-word-list-dictionary hunspell-dict-en-ca
579 "en_CA"
580 (synopsis "Hunspell dictionary for Canadian English"))
581
582(define-word-list-dictionary hunspell-dict-en-gb
583 "en_GB-ise" "en-gb"
584 (synopsis "Hunspell dictionary for British English, with -ise endings"))
585
586(define-word-list-dictionary hunspell-dict-en-gb-ize
587 "en_GB-ize"
588 (synopsis "Hunspell dictionary for British English, with -ize endings"))
589
590(define-word-list-dictionary hunspell-dict-en-us
591 "en_US"
592 (synopsis "Hunspell dictionary for United States English"))
593