Package: givemebib
givemebibgivemebibis a bibliographic tool for scientific litterature that does two things:providesclean .bib filesdownloaded fromhttp://api.crossref.org/works/reformats .bib files by outputingabbreviated or full journal namesand bydeleting specified information fields(e.g. url, doi, abstract...)It can do so starting from severalinputtypes:.pdf file of articledirectory with .pdf files of articlesdoi of article (e.g. '10.1234/123blabla-(bla).7810')list of doi written in a file and separated by tabulations, new lines and white spaces (seethis sample)Google Scholar query (e.g. 'author:Smith 2020 graphene ~device -nanotube')list of Google Scholar queries written in a file on separate lines (seethis sample).bib file to be formatedIt does not work 100% of the time for .pdf files and Google Scholar queries.The sample files in thesamplesrepository are meant to also show some of the error messages, hence some input files would not yield all the bib information.How to install:Using pipRun in terminal:pip install givemebibManuallyDownload the directory (https://github.com/bgrosjea/givemebib.py_package/).In the downloaded directory, run in terminal:python setup.py installorpython3 setup.py installHow to run it:with Command lineRun in terminal:givemebib <target> <0 or 1>target is one of the input types described above0 will transform output .bib files to include full journal names1 will transform output .bib files to include abbreviated journal namesIf thegivemebibcommand is unknown, make sure python packages are added to your PATH system variable.single functions in python scriptSingle functions used in the main script can be run in a python script :importgivemebib.functionsasgmbpdf='./example.pdf'doi=gmb.pdf2doi(pdf)...Functions:scholarquery2doi(query)given a search query (string), returns the doi of the first Google Scholar result.pdfminer2doi(pdf)given the path to a .pdf file (string), tries to finds the doi in the .pdf using pdfminer.six and tries the figure captions as Google Scholar queries if not until a doi is found on the first search result link. This function is integrated in pdf2doi, which should be preferred.pdf2doi(pdf)given the path to a .pdf file (string), tries to finds the doi in the .pdf first using PyPDF2, then pdfminer2doidoi2bib(doi)given a doi (string starting with '10.'), returns bib as a string, as downloaded fromhttp://api.crossref.org/works/pdf2bib(pdf)given the path to a .pdf file (string), returns bib as a string. Interfaces pdf2doi and doi2bib.pdf2bibfile(pdf)given the path to a .pdf file (string), saves bib in file pdfname.bibbib2reformat(bib, abbrev, exclusion_list)given a bib (string), 0 (non abbreviated journal names in output) or 1 (abbreviated journal names in output), a list of information fields to delete (e.g. ['url', 'doi', 'month',...]), returns a reformated bib string without the fields listed and with abbreviated (abbrev=1) or not (abbrev=0) journal names.bibfile2reformat(bib, abbrev, exclusion_list)given a .bib file, abbrev (0 or 1) and exclusion_list (see above), writes a reformated bib file as bibname.reformat.bibsavenonamebib(bib, directory)given a bib string and the path to a directory, saves the bib in a .bib file in the directory, naming it after information from the bib. It tries several names until one is not an existing file: nameinbib.bib, journalInitials_nameinbib.bib, journalInitials_nameinbib_2.bib, ...biburl(doi)given a doi (string) returns the corresponding bib url on crossref.org:http://api.crossref.org/works/doi/transform/application/x-bibtexNecessary filesThose two files should be automatically installedinformation fields to delete are to be entered in filegivemebib.inijournal names and their abbreviations are stored injournal_abbreviations.dat, additional entries can be written with 'XXX<>XXX' as separator. Most abbreviations were found onhttp://guides.lib.berkeley.edu/bioscience-journal-abbreviations/Additional abbreviations can be found for instance on wikipedia or on:http://cassi.cas.org/search.jsphttp://www.journalabbr.com/https://journal-abbreviations.library.ubc.ca/Error outputIn the directory of execution, the filegivemebib.logstores errors encountered such as:inputs that gave no results (.pdf files from which nodoiwas extracted, incorrectdoietc.)inputs that gave possibly wrong results (.pdf from which thedoiextracted had to be modified to yield a result or required a Google Scholar search)journal names or abbreviations not detected or stored injournal_abbreviations.datHow it worksTo obtain a .bib, thedoiof the article is read either as provided, extracted from a .pdf or from the webpage of the first Google Scholar result of a provided search query. The .bib is then downloaded using this url:http://api.crossref.org/works/theDOI/transform/application/x-bibtexThe extraction of adoifrom an article does not always work right. Sometimes nodoiis found, sometimes adoiwith extra characters is found. In that latter case, the last characters of thedoiare progressively removed until a match is found on crossref.org. To limit errors, three methods are used in the following order: i) with the pdf read by PyPDF2; ii) with the pdf read by pdfminer.six; iii) by using figure captions of the article as Google Scholar queries until a doi is found on the webpage of the first search result. The last method does not work well as: i) figure captions as queries do not always give a result nor the right one; ii) the IP address can get blocked by Google Scholar after multiple queries; iii) sometimes the doi of another article is detected on the page. This might be subject to future improvements.All bib are then reformatted before being written into files.LicenseGNU General Public License v3 (GPLv3)CreditBenoit Grosjean :https://github.com/bgrosjea