From: Philip McGrath <philip@philipmcgrath.com>
To: 56759@debbugs.gnu.org
Cc: Philip McGrath <philip@philipmcgrath.com>
Subject: [bug#56759] [PATCH 16/20] gnu: Add anystyle.
Date: Mon, 25 Jul 2022 08:16:31 -0400 [thread overview]
Message-ID: <272fe1f23b2adaf54276b105268ca7179e00dcd5.1658750358.git.philip@philipmcgrath.com> (raw)
In-Reply-To: <cover.1658750358.git.philip@philipmcgrath.com>
* gnu/packages/ruby.scm (anystyle): New variable.
(ruby-anystyle)[description]: Mention it.
---
gnu/packages/ruby.scm | 125 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 124 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm
index 90f269e247..3feb07dcdc 100644
--- a/gnu/packages/ruby.scm
+++ b/gnu/packages/ruby.scm
@@ -66,6 +66,7 @@ (define-module (gnu packages ruby)
#:use-module (gnu packages libidn)
#:use-module (gnu packages linux)
#:use-module (gnu packages lsof)
+ #:use-module (gnu packages man)
#:use-module (gnu packages maths)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages networking)
@@ -13547,5 +13548,127 @@ (define-public ruby-anystyle
"AnyStyle is a very fast and smart parser for academic reference lists
and bibliographies. AnyStyle uses powerful machine learning heuristics based
on Conditional Random Fields and aims to make it easy to train the model with
-data that is relevant to your parsing needs.")
+data that is relevant to your parsing needs.
+
+This package provides the Ruby module @code{AnyStyle}. AnyStyle can also be
+used via the @command{anystyle} command-line utility or a web application,
+though the later has not yet been packaged for Guix.")
(license license:bsd-2))))
+
+(define-public anystyle
+ (package
+ (name "anystyle")
+ (version "1.3.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/inukshuk/anystyle-cli")
+ (commit version)))
+ (sha256
+ (base32
+ "1bazzms04cra8516q7vydmcm31yd0a7si1pxk4waffqy7lh0pksg"))
+ (file-name (git-file-name name version))))
+ (build-system ruby-build-system)
+ (propagated-inputs
+ (list ruby-anystyle
+ ruby-bibtex-ruby
+ ruby-gli))
+ (native-inputs
+ (list txt2man))
+ (arguments
+ (list
+ #:modules
+ `((guix build ruby-build-system)
+ (ice-9 popen)
+ (guix build utils))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'extract-gemspec 'less-strict-dependencies
+ (lambda args
+ (substitute* "anystyle-cli.gemspec"
+ (("'bibtex-ruby', '[^']*'")
+ "'bibtex-ruby'"))))
+ (delete 'check) ;; there are no upstream tests
+ (add-after 'wrap 'check-cli
+ (lambda* (#:key tests? outputs #:allow-other-keys)
+ (when tests?
+ (with-output-to-file "check-cli.in"
+ (lambda ()
+ (for-each
+ display
+ '("Derrida, J. (1967). L’écriture et la différence "
+ "(1 éd.). Paris: Éditions du Seuil.\n"))))
+ (invoke (search-input-file outputs "/bin/anystyle")
+ "parse"
+ "check-cli.in"))))
+ (add-after 'wrap 'generate-man-page
+ ;; generating a man page also tests that the command actually runs
+ (lambda args
+ (define (run-with-output-file file command . args)
+ (format (current-output-port)
+ "running: ~s\nwith output to: ~s\n"
+ (cons command args)
+ file)
+ (unless (zero?
+ (with-output-to-file file
+ (lambda ()
+ (status:exit-val
+ (close-pipe
+ (apply open-pipe* OPEN_WRITE command args))))))
+ (error "command failed")))
+ (let ((anystyle (string-append #$output "/bin/anystyle")))
+ (run-with-output-file "intro.txt"
+ anystyle "--help")
+ (for-each (lambda (cmd)
+ (let ((file (string-append cmd ".txt")))
+ (run-with-output-file file
+ anystyle cmd "--help")
+ ;; indent headings to create subsections
+ (substitute* file
+ (("^[A-Z]" orig)
+ (string-append " " orig)))
+ ;; generate a section heading
+ (call-with-output-file
+ (string-append "section-" file)
+ (lambda (out)
+ (format out "\n\n~a COMMAND\n\n"
+ (string-upcase cmd))))))
+ '("check" "find" "parse" "train"))
+ (substitute* `("intro.txt"
+ "check.txt" "find.txt" "parse.txt" "train.txt")
+ ;; format "tag list" for txt2man"
+ ((" - ")
+ " ")
+ ;; restore formatting of the "name" sections
+ (("(anystyle|check|find|parse|train) ([A-Z])" _ cmd post)
+ (string-append cmd " - " post)))
+ (run-with-output-file "anystyle.txt"
+ "cat"
+ "intro.txt"
+ "section-check.txt" "check.txt"
+ "section-find.txt" "find.txt"
+ "section-parse.txt" "parse.txt"
+ "section-train.txt" "train.txt")
+ (run-with-output-file
+ "anystyle.1"
+ "txt2man"
+ "-v" "General Commands Manual" "-t" "anystyle" "-s" "1"
+ "-r" #$(string-append "anystyle-cli "
+ (package-version this-package))
+ "-B" "check" "-B" "find" "-B" "parse" "-B" "train"
+ "anystyle.txt")
+ (install-file "anystyle.1"
+ (string-append #$output "/share/man/man1"))))))))
+ (home-page "https://anystyle.io")
+ (synopsis "Fast and smart citation reference parsing")
+ (description
+ "AnyStyle is a very fast and smart parser for academic reference lists
+and bibliographies. AnyStyle uses powerful machine learning heuristics based
+on Conditional Random Fields and aims to make it easy to train the model with
+data that is relevant to your parsing needs.
+
+This package provides the @command{anystyle} command-line utility. AnyStyle
+can also be used as a Ruby library or as a web application, though the later
+has not yet been packaged for Guix.")
+ (license license:bsd-2)
+ (properties `((upstream-name . "anystyle-cli")))))
--
2.32.0
next prev parent reply other threads:[~2022-07-25 12:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-25 12:13 [bug#56759] [PATCH 00/20] gnu: Add AnyStyle Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 01/20] gnu: Add ruby-wapiti Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 02/20] gnu: Add ruby-namae Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 03/20] gnu: Add itex2mml Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 04/20] gnu: Add ruby-ritex Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 05/20] gnu: Add ruby-latex-decode Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 06/20] gnu: Add ruby-link-header Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 07/20] gnu: Add ruby-rdf Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 08/20] gnu: Add ruby-rdf-vocab Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 09/20] gnu: Add ruby-bibtex-ruby Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 10/20] gnu: Add ruby-unicode-scripts Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 11/20] gnu: Add ruby-citeproc Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 12/20] gnu: Add ruby-edtf Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 13/20] gnu: Add ruby-gli Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 14/20] gnu: Add ruby-anystyle-data Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 15/20] gnu: Add ruby-anystyle Philip McGrath
2022-07-25 12:16 ` Philip McGrath [this message]
2022-07-25 12:16 ` [bug#56759] [PATCH 17/20] gnu: ruby-anystyle-data: Don't write to installed gem Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 18/20] gnu: ruby-anystyle: Initialize dictionary files Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 19/20] gnu: anystyle: Add tests for dictionary adapters Philip McGrath
2022-07-25 12:16 ` [bug#56759] [PATCH 20/20] gnu: anystyle: Use GDBM by default Philip McGrath
2022-07-25 15:10 ` [bug#56759] [PATCH v2 05/20] gnu: Add ruby-latex-decode Philip McGrath
2022-08-04 9:57 ` bug#56759: [PATCH 00/20] gnu: Add AnyStyle Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=272fe1f23b2adaf54276b105268ca7179e00dcd5.1658750358.git.philip@philipmcgrath.com \
--to=philip@philipmcgrath.com \
--cc=56759@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.