Git Product home page Git Product logo

geobosh / rbibutils Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 1.0 2.43 MB

Convert bibliography files between various formats, including BibTeX, BibLaTeX, PubMed, RIS, and Bibentry. This is an R port of the bibutils utilities plus R manipulation of bibiliography objects.

Home Page: https://geobosh.github.io/rbibutils/

R 2.85% TeX 3.49% C 93.66%
biblatex bibliography bibtex bibutils conversion endnote pubmed r r-package ris-format

rbibutils's People

Contributors

geobosh avatar hsloot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

zagrosman

rbibutils's Issues

Version 1.4 implicitly depends on R>= 3.4

Your call to R_unif_index in

return floor + ( (int) R_unif_index((double) RAND_MAX) ) % len;

leads to undefined symbol: R_unif_index error since this function is only defined in R 3.4 and publicly introduced as API in R 3.5. In my case, this causes the CI of my package (which depend on Rdpack for creating the documentation) on R 3.3 to fail. This will also cause problems for all package developers that use the Github action workflow in https://github.com/r-lib/actions/blob/master/examples/check-full.yaml for their CI which tests on R 3.3.

You could use the following workaround:

#include <Rversion.h> 
// ...
#if defined(R_VERSION) && R_VERSION >= R_Version(3, 4, 0)
  return floor + ( (int) R_unif_index((double) RAND_MAX)) ) % len;
#else
  return  floor + ( (int) floor(RAND_MAX * unif_rand()) ) % len;
#endif

Note that your solution and my workaround will probably be biased (see section 3 in https://isocpp.org/files/papers/n3551.pdf). A better solution might be the following which should produce random integers in [floor, floor+len) and is consistent with R's way to sample a random integer on R< 3.4 and R >= 3.4:

#include <Rversion.h> 
// ...
#if defined(R_VERSION) && R_VERSION >= R_Version(3, 4, 0)
  return floor + ( (int) R_unif_index((double) len)) );
#else
  return  floor + ( (int) floor(len * unif_rand()) );
#endif

How to set nref_in and nref_out parameters?

I have an pubmed xml file with more than 500 references.
I tried to convert to bib file using this code:

bibConvert(infile = fn_med, #fn_med: route to my xml file
outfile = "export.bib",
informat = "med",
outformat = "bib")

But I got only 3 references:
$nref_in
[1] 3

$nref_out
[1] 3

How to set the number of references to read from the input file (nref_in) and number of references to write to the output file (nref_out)?

How to read and write all the references from the source file?

Thanks

Failing tests on non-x86 archs

Hi,

In the latest version 2.2.7, one test is failing on archs other than amd64 and i386 in debian, as can be seen here

It chokes on

expect_known_value(readLines(tmp_ads), "xampl_bib2ads.rds", update = FALSE)

more specifically, in the resultant bib file, the last U is missing on two lines:

readLines(tmp_ads) has changed from known value recorded in 'xampl_bib2ads.rds'.
2/313 mismatches
x[293]: "%R ..................."
y[293]: "%R ..................U"

x[300]: "%R 1988..............."
y[300]: "%R 1988..............U"

Could you please fix the problem?

====================================================================================================

CC: @GeoBosh

Inaccurate conversion of `\emph` in bibtex entries

In case of bibtex entries with italicized codes specified using \emph{}, rbibuitils is converting backslash in \emph to \backslash, resulting in \backslashemph leading to a unknown macro '\backslashemph' error.

bib1 <- "@article{burton_quantitative_1951,
	title = {Quantitative inheritance in pearl millet (\\emph{{Pennisetum} glaucum})},
	volume = {43},
	number = {9},
	journal = {Agronomy Journal},
	author = {Burton, Glenn W.},
	year = {1951},
	pages = {409--417}
}"


bib2 <- "@article{diwan_methods_1995,
  title = {Methods of developing a core collection of annual \\emph{{Medicago}} species},
  volume = {90},
  language = {en},
  number = {6},
  journal = {Theoretical and Applied Genetics},
  author = {Diwan, N. and McIntosh, M. S. and Bauchan, G. R.},
  month = may,
  year = {1995},
  keywords = {Annual Medicago species, Core collection, Germplasm collection, Relative Diversity method},
  pages = {755--761}
}"

rbibutils::charToBib(bib1)
#> Burton GW (1951). "Quantitative inheritance in pearl millet
#> (\backslashemph{{Pennisetum} glaucum})." _Agronomy Journal_, *43*(9),
#> 409-417.
rbibutils::charToBib(bib2)
#> Diwan N, McIntosh MS, Bauchan GR (1995). "Methods of developing a core
#> collection of annual \backslashemph{{Medicago}} species." _Theoretical
#> and Applied Genetics_, *90*(6), 755-761.

Incorrect parsing of braces

@misc{x,
author = "P{\i}{\'\i}{\'i}",
}
@misc{y,
  author = "L P{\i}{\'\i}{\'i}",
}

Save into bug.bib

rbibutils::readBib("test.bib", direct=TRUE, encoding = "UTF-8")

gives:

Pıí\'i (????).

P\i}'i\'i L (????).
Warning messages:
1: In parseLatex(x) : x:1: unexpected END_OF_INPUT 'i'
2: In parseLatex(x) : x:1: unexpected END_OF_INPUT 'i'
3: In withCallingHandlers(.External2(C_parseRd, tcon, srcfile, "UTF-8",  :
  <connection>:2: unexpected END_OF_INPUT ' L (????).
'

Something is removing one opening brace when the author has "firstname lastname".

Different conversion when first name is given

test.bib:

@misc{x,
author = "P{\'\i}{\'i}"
}
@misc{y,
  author = "L. P{\'\i}{\'i}"
}
@misc{z,
  author = "P{\'\i}{\'i}, L."
}
rbibutils::readBib("test.bib", direct=TRUE, encoding = "UTF-8")

gives:

Pí\'i (????).

P\'i\'i L (????).

P\'i\'i L (????).

that is, having firstname lastname fails to process "'\i" into "í".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.