Re: [PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
On 14/01/16 21:30, Ricardo Wurmus wrote: Ben Woodcroft writes: On 14/01/16 20:31, Ricardo Wurmus wrote: This breaks two of the cran importer tests: (test-equal "beautify-description: use double spacing" "This is a package. It is great. Trust me Mr. Hendrix." ((@@ (guix import cran) beautify-description) "This is a package. It is great. Trust me Mr. Hendrix.")) (test-equal "beautify-description: transform fragment into sentence" "This package provides a function to establish world peace" ((@@ (guix import cran) beautify-description) "A function to establish world peace")) I just tested these with "make check" and also by ./pre-inst-env guile tests/cran.scm, and they seem to pass. Am I doing something incorrectly? However, ironically tests/gem fails. How about moving these tests elsewhere? (Or should they be removed?) Ah, sorry. Should they be moved to a new file tests/import-utils? Why do you suggest that they should be removed? I don’t have any preference for a name. “tests/import-utils” sounds good to me. If we can keep (and later enhance) the tests it would obviously be better. (I just meant that I wouldn’t be too sad if they were removed for whatever reasons.) Would you like to submit a patch to add tests/import-utils (including adding it to SCM_TESTS in Makefile.am) and move these two test cases there? Happy to provide a patch fixing the gem test, and moving the (failing?) cran tests to this new file since even if they pass that is a more appropriate place for them. It'll be the weekend before I have time for this though, apologies for leaving master broken. ben
Re: [PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
Ben Woodcroft writes: > On 14/01/16 20:31, Ricardo Wurmus wrote: >> This breaks two of the cran importer tests: >> >> (test-equal "beautify-description: use double spacing" >>"This is a package. It is great. Trust me Mr. Hendrix." >>((@@ (guix import cran) beautify-description) >> "This is a package. It is great. Trust me Mr. Hendrix.")) >> >> (test-equal "beautify-description: transform fragment into sentence" >>"This package provides a function to establish world peace" >>((@@ (guix import cran) beautify-description) >> "A function to establish world peace")) >> >> How about moving these tests elsewhere? (Or should they be removed?) > > Ah, sorry. Should they be moved to a new file tests/import-utils? Why do > you suggest that they should be removed? I don’t have any preference for a name. “tests/import-utils” sounds good to me. If we can keep (and later enhance) the tests it would obviously be better. (I just meant that I wouldn’t be too sad if they were removed for whatever reasons.) Would you like to submit a patch to add tests/import-utils (including adding it to SCM_TESTS in Makefile.am) and move these two test cases there? ~~ Ricardo
Re: [PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
On 14/01/16 20:31, Ricardo Wurmus wrote: Ben Woodcroft writes: On 11/01/16 07:17, Ludovic Courtès wrote: Ben Woodcroft skribis: From e3bad19a07d6a9fdf3045619232a24b77a1a5d12 Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Wed, 6 Jan 2016 00:09:19 +1000 Subject: [PATCH 1/2] import: cran: Move beautify-description to utils module. * guix/import/cran.scm (beautify-description): Move from here... * guix/import/utils.scm: ... to here. [...] From eb65d0ef0140ac2828b608c31ae19893861fea3a Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Wed, 6 Jan 2016 00:17:36 +1000 Subject: [PATCH 2/2] import: gem: Beautify description field. * guix/import/gem.scm (gem->guix-package): Use 'beautify-description'. LGTM, thanks! Pushed, ta. This breaks two of the cran importer tests: (test-equal "beautify-description: use double spacing" "This is a package. It is great. Trust me Mr. Hendrix." ((@@ (guix import cran) beautify-description) "This is a package. It is great. Trust me Mr. Hendrix.")) (test-equal "beautify-description: transform fragment into sentence" "This package provides a function to establish world peace" ((@@ (guix import cran) beautify-description) "A function to establish world peace")) How about moving these tests elsewhere? (Or should they be removed?) Ah, sorry. Should they be moved to a new file tests/import-utils? Why do you suggest that they should be removed? ben
Re: [PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
Ben Woodcroft writes: > On 11/01/16 07:17, Ludovic Courtès wrote: >> Ben Woodcroft skribis: >> >>> From e3bad19a07d6a9fdf3045619232a24b77a1a5d12 Mon Sep 17 00:00:00 2001 >>> From: Ben Woodcroft >>> Date: Wed, 6 Jan 2016 00:09:19 +1000 >>> Subject: [PATCH 1/2] import: cran: Move beautify-description to utils >>> module. >>> >>> * guix/import/cran.scm (beautify-description): Move from here... >>> * guix/import/utils.scm: ... to here. >> [...] >> >>> From eb65d0ef0140ac2828b608c31ae19893861fea3a Mon Sep 17 00:00:00 2001 >>> From: Ben Woodcroft >>> Date: Wed, 6 Jan 2016 00:17:36 +1000 >>> Subject: [PATCH 2/2] import: gem: Beautify description field. >>> >>> * guix/import/gem.scm (gem->guix-package): Use 'beautify-description'. >> LGTM, thanks! > Pushed, ta. This breaks two of the cran importer tests: (test-equal "beautify-description: use double spacing" "This is a package. It is great. Trust me Mr. Hendrix." ((@@ (guix import cran) beautify-description) "This is a package. It is great. Trust me Mr. Hendrix.")) (test-equal "beautify-description: transform fragment into sentence" "This package provides a function to establish world peace" ((@@ (guix import cran) beautify-description) "A function to establish world peace")) How about moving these tests elsewhere? (Or should they be removed?) ~~ Ricardo
Re: [PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
On 11/01/16 07:17, Ludovic Courtès wrote: Ben Woodcroft skribis: From e3bad19a07d6a9fdf3045619232a24b77a1a5d12 Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Wed, 6 Jan 2016 00:09:19 +1000 Subject: [PATCH 1/2] import: cran: Move beautify-description to utils module. * guix/import/cran.scm (beautify-description): Move from here... * guix/import/utils.scm: ... to here. [...] From eb65d0ef0140ac2828b608c31ae19893861fea3a Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Wed, 6 Jan 2016 00:17:36 +1000 Subject: [PATCH 2/2] import: gem: Beautify description field. * guix/import/gem.scm (gem->guix-package): Use 'beautify-description'. LGTM, thanks! Pushed, ta. ben
Re: [PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
Ben Woodcroft skribis: > From e3bad19a07d6a9fdf3045619232a24b77a1a5d12 Mon Sep 17 00:00:00 2001 > From: Ben Woodcroft > Date: Wed, 6 Jan 2016 00:09:19 +1000 > Subject: [PATCH 1/2] import: cran: Move beautify-description to utils module. > > * guix/import/cran.scm (beautify-description): Move from here... > * guix/import/utils.scm: ... to here. [...] > From eb65d0ef0140ac2828b608c31ae19893861fea3a Mon Sep 17 00:00:00 2001 > From: Ben Woodcroft > Date: Wed, 6 Jan 2016 00:17:36 +1000 > Subject: [PATCH 2/2] import: gem: Beautify description field. > > * guix/import/gem.scm (gem->guix-package): Use 'beautify-description'. LGTM, thanks! Ludo'.
[PATCH] import: Move beautify description from cran to utils. (was Re: [PATCH 6/6] gnu: Add emacs-slime.)
On 02/01/16 01:04, Ricardo Wurmus wrote: Ben Woodcroft writes: On 01/01/16 18:25, Ricardo Wurmus wrote: Alex Kost writes: Ricardo Wurmus (2015-12-31 12:52 +0300) wrote: Ben Woodcroft writes: Do you know though, is there any way to get emacs to insert the extra space in description strings and comments automatically (without it messing things up of course). Perhaps we should modify the importers to insert this automatically in the description field. The CRAN and Bioconductor importers already do this. See “beautify-description” in “guix/import/cran.scm”. Hm, is it reliable? Not all dots specify an end of a sentence: there are things like "e.g.", "i.e.", "etc.". Also there may be abbreviations like "ATA S.M.A.R.T. reading and parsing library" (synopsis of 'libatasmart' package). Or even things like “ ... ” (description of 'perl-html-form') — it should probably be wrapped in @code{} by the way. It’s not supposed to be maintenance-free. Descriptions often start with sentence fragments, which cannot be detected easily. I found that “beautify-description” works well enough to make packaging R stuff much simpler for me. I'd like to add this to the Ruby importer. Do you think it is a good idea to make your beautify-description available in import/utils ? I think it could be generally useful to have something like that for all importers. Do you want to prepare a patch? Pretty straightforward stuff. The first patch moves beautify-description to import/utils and the second uses it in the rubygem importer. Any good? ta, ben >From e3bad19a07d6a9fdf3045619232a24b77a1a5d12 Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Wed, 6 Jan 2016 00:09:19 +1000 Subject: [PATCH 1/2] import: cran: Move beautify-description to utils module. * guix/import/cran.scm (beautify-description): Move from here... * guix/import/utils.scm: ... to here. --- guix/import/cran.scm | 11 --- guix/import/utils.scm | 14 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/guix/import/cran.scm b/guix/import/cran.scm index 45c679c..c66818c 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -136,17 +136,6 @@ empty list when the FIELD cannot be found." (string-any char-set:whitespace item))) (map string-trim-both items)) -(define (beautify-description description) - "Improve the package DESCRIPTION by turning a beginning sentence fragment -into a proper sentence and by using two spaces between sentences." - (let ((cleaned (if (string-prefix? "A " description) - (string-append "This package provides a" -(substring description 1)) - description))) -;; Use double spacing between sentences -(regexp-substitute/global #f "\\. \\b" - cleaned 'pre ". " 'post))) - (define (description->package meta) "Return the `package' s-expression for a CRAN package from the alist META, which was derived from the R package's DESCRIPTION file." diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 0734fa1..44e004b 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -37,7 +37,8 @@ string->license license->symbol -snake-case)) +snake-case +beautify-description)) (define (factorize-uri uri version) "Factorize URI, a package tarball URI as a string, such that any occurrences @@ -136,3 +137,14 @@ to in the (guix licenses) module, or #f if there is no such known license." "Return a downcased version of the string STR where underscores are replaced with dashes." (string-join (string-split (string-downcase str) #\_) "-")) + +(define (beautify-description description) + "Improve the package DESCRIPTION by turning a beginning sentence fragment +into a proper sentence and by using two spaces between sentences." + (let ((cleaned (if (string-prefix? "A " description) + (string-append "This package provides a" +(substring description 1)) + description))) +;; Use double spacing between sentences +(regexp-substitute/global #f "\\. \\b" + cleaned 'pre ". " 'post))) -- 2.6.3 >From eb65d0ef0140ac2828b608c31ae19893861fea3a Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Wed, 6 Jan 2016 00:17:36 +1000 Subject: [PATCH 2/2] import: gem: Beautify description field. * guix/import/gem.scm (gem->guix-package): Use 'beautify-description'. --- guix/import/gem.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guix/import/gem.scm b/guix/import/gem.scm index c64c4e9..3c42052 100644 --- a/guix/import/gem.scm +++ b/guix/import/gem.scm @@ -117,7 +117,8 @@ VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES." (let ((name (assoc-ref package "name")) (version (asso