Package: bib-lookup
bib_lookupA useful tool for looking up Bib entries using DOI, PubMed ID (URL), or arXiv ID (URL).:rocket:NEW:rocket:Streamlitsupport! Seeherefor an app deployed onStreamlit Community Cloud.It is an updated version ofhttps://github.com/wenh06/utils/blob/master/utils_universal/utils_bib.pyNOTEthat you should have internet connection to usebib_lookup.InstallationDependenciesBasic Usage ExamplesCommand-line UsageOutput (Append) to a.bibFilearXiv to DOIBib Items CheckingSimplify a.bibFileCitationMixinclassTODOWARNINGBiblatex CheetsheetCitationReferencesInstallationRunpython-mpipinstallbib-lookupor install the latest version inGitHubusingpython-mpipinstallgit+https://github.com/DeepPSP/bib_lookup.gitor git clone this repository and install locally viacdbib_lookup
python-mpipinstall.:point_right:Back to TOCDependenciesrequestsfeedparserpandas:point_right:Back to TOCBasic Usage ExamplesClick to expand!>>>frombib_lookupimportBibLookup>>>bl=BibLookup(align="middle")>>>print(bl("1707.07183"))@article{wen2017_1707.07183v2,author={HaoWenandChunhuiLiu},title={CountingMultiplicitiesinaHypersurfaceoveraNumberField},journal={arXivpreprintarXiv:1707.07183v2},year={2017},month={7},}>>>print(bl("10.1109/CVPR.2016.90"))@inproceedings{He_2016,author={KaimingHeandXiangyuZhangandShaoqingRenandJianSun},title={DeepResidualLearningforImageRecognition},booktitle={2016{IEEE}ConferenceonComputerVisionandPatternRecognition({CVPR})},doi={10.1109/cvpr.2016.90},year={2016},month={6},publisher={{IEEE}},}>>>print(bl("10.23919/cinc53138.2021.9662801",align="left-middle"))@inproceedings{Wen_2021,author={HaoWenandJingsuKang},title={HybridArrhythmiaDetectiononVarying-DimensionalElectrocardiography:CombiningDeepNeuralNetworksandClinicalRules},booktitle={2021ComputinginCardiology({CinC})},doi={10.23919/cinc53138.2021.9662801},year={2021},month={9},publisher={{IEEE}},}:point_right:Back to TOCCommand-line UsageClick to expand!After installation, one can usebib-lookupin the command line:bib-lookup10.1109/CVPR.2016.9010.23919/cinc53138.2021.9662801--ignore-fieldsurldoi-ipath/to/input.txt-opath/to/output.bibView current version:bib-lookup--versionView current configuration:bib-lookup--configshowRemove current configuration:bib-lookup--configresetSet specific configuration:bib-lookup--config"timeout=2.0;print_result=true;ignore_fields=['url','pdf']"or from ajsonfile oryamlfile:bib-lookup--config/path/to/config.json
bib-lookup--config/path/to/config.yamlNote that unrecognized fields will be ignored and warning messages will be printed. The following table lists all the available configuration options:OptionTypeDefaultDescriptionalignstrmiddleAlignment of the bib item.emailstrNoneEmail address to be used in the request.ignore_fieldslist['url', 'pdf']Fields to be ignored in the output.ignore_errorsboolFalseWhether to ignore errors.timeoutfloat6.0Timeout in seconds for each request.arxiv2doiboolTrueWhether to convert arXiv ID to DOI.formatstrbibtexOutput format.stylestrapaCitation style. Valid only whenformatistext.verboseint0Verbosity level.print_resultboolFalseWhether to print the result.orderinglist['title', 'author', 'journal', 'booktitle']Ordering of the fields.:point_right:Back to TOCOutput (Append) to a.bibFileClick to expand!Each time a bib item is successfully found, it will be cached. One can call thesavefunction to write the cached bib items to a.bibfile, in the append mode.>>>frombib_lookupimportBibLookup>>>bl=BibLookup()>>>bl(["10.1109/CVPR.2016.90","10.23919/cinc53138.2021.9662801","DOI: 10.1142/S1005386718000305"]);>>>len(bl)3>>>bl[0]'10.1109/CVPR.2016.90'>>>bl.save([0,2],"path/to/some/file.bib")# save bib item corr. to "10.1109/CVPR.2016.90" and "DOI: 10.1142/S1005386718000305">>>len(bl)1>>>bl.pop(0)# remove the bib item corr. "10.23919/cinc53138.2021.9662801", equivalent to `bl.pop("10.23919/cinc53138.2021.9662801")`>>>len(bl)0:point_right:Back to TOCarXiv to DOIClick to expand!From 2022.2.17, new arXiv articles are automatically assigned DOIs (old ones in progress). If one prefers DOI citation to arXiv citation then>>>frombib_lookupimportBibLookup>>>bl=BibLookup(arxiv2doi=True)# the default for `arxiv2doi` is False>>>print(bl("https://arxiv.org/abs/2204.04420"))@misc{https://doi.org/10.48550/arxiv.2204.04420,author={Hao,WenandJingsu,Kang},title={InvestigatingDeepLearningBenchmarksforElectrocardiographySignalProcessing},doi={10.48550/ARXIV.2204.04420},keywords={MachineLearning(cs.LG),FOS:Computerandinformationsciences,FOS:Computerandinformationsciences},publisher={arXiv},year={2022},copyright={CreativeCommonsAttribution4.0International}}while withbl = BibLookup(), one would get@article{hao2022_2204.04420v1,
   author ={Wen Hao and Kang Jingsu},
    title ={Investigating Deep Learning Benchmarks for Electrocardiography Signal Processing},
  journal ={arXiv preprint arXiv:2204.04420v1},
     year ={2022},
    month ={4}}:point_right:Back to TOCBib Items CheckingClick to expand!One can useBibLookupto check the validity (required fields, duplicate labels, etc) of bib items in a Bib file. The following is an example with aBib filewith incorrect and duplicate bib items.>>>frombib_lookupimportBibLookup>>>bl=BibLookup()>>>bl.check_bib_file("./test/invalid_items.bib")Bibitem"He_2016"startingfromline3isnotvalid.Bibitemofentrytype"inproceedings"shouldhavethefollowingfields:['author','title','booktitle','year']Bibitem"Wen_2018"startingfromline16isnotvalid.Bibitemofentrytype"article"shouldhavethefollowingfields:['author','title','journal','year']Bibitems"He_2016"startingfromline3and"He_2016"startingfromline45isduplicate.[3,16,45]or from command linebib-lookup-c./test/invalid_items.bib
bib-lookup--ignore-fieldsurldoi-i./test/sample_input.txt-o./tmp/a.bib-ctrue:point_right:Back to TOCSimplify a.bibFileClick to expand!Sometimes one wants a clean bib without bib items that are not cited, then one can use the static methodsimplify_bib_fileto generate a new.bibFile that contains only the cited bib items from an old.bibFile.>>>frombib_lookupimportBibLookup>>>new_bib_file_path=BibLookup.simplify_bib_file("path/to/tex/source/file","path/to/old/bib/file")>>># or use the following if one has multiple source files>>>new_bib_file_path=BibLookup.simplify_bib_file(list_of_tex_source_files_or_folders,"path/to/old/bib/file"):point_right:Back to TOCCitationMixinclassClick to expand!One can inherit theCitationMixinclass to have the methodget_citationfor any class,
in which case one only needs to provide aself.doi. For example:frombib_lookupimportCitationMixinclassSomeClass(CitationMixin):doi="10.23919/cinc53138.2021.9662801"# can also be a listTODOClick to expand!(:heavy_check_mark:)add CLI support;use eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi for PubMed, as in [3];try using google scholar api described in [4] (unfortunately [4] is charged);useFlaskto write a simple browser-based UI;(:heavy_check_mark:)check if the bib item is already existed in the output file, and skip saving it if so;since arXiv articles are now automatically assigned DOIs (ref.this blog), consider converting arXiv identifiers to DOI indentifiers, and requesting from DOI. Currently, the request results are different, at least the entry type is change fromarticletomisc;make__call__method asynchronised usingasyncioandaiohttporhttpx.:point_right:Back to TOCWARNINGClick to expand!Many journals have specific requirements for the Bib entries,
for example, the title and/or journal (and/or booktitle), etc. should becapitalized,
which could not be done automatically sincesome abbreviations in title should have characters all in the upper case, for exampleALBERT: A Lite BERT for Self-supervised Learning of Language Representationssome should have characters all in in the lower case,mixup: Beyond Empirical Risk Minimizationand some others should have mixed cases,KeMRE: Knowledge-enhanced Medical Relation Extraction for Chinese Medicine InstructionsThis should be corrected by the user himselfif necessary(which although is rare),
and remember to enclose such fields withdouble curly braces.For example, the lookup result for theAlexNetpaper is>>>frombib_lookupimportBibLookup>>>bl=BibLookup()>>>print(bl("https://doi.org/10.1145/3065386"))@article{Krizhevsky_2017,author={AlexKrizhevskyandIlyaSutskeverandGeoffreyE.Hinton},title={{ImageNet}classificationwithdeepconvolutionalneuralnetworks},journal={Communicationsofthe{ACM}},doi={10.1145/3065386},year={2017},month={5},publisher={AssociationforComputingMachinery({ACM})},volume={60},number={6},pages={84--90}}This result (the title) should be adjusted to@article{Krizhevsky_2017,
     author ={Alex Krizhevsky and Ilya Sutskever and Geoffrey E. Hinton},
      title ={{ImageNet Classification with Deep Convolutional Neural Networks}},
    journal ={Communications of the{ACM}},
        doi ={10.1145/3065386},
       year ={2017},
      month ={5},
  publisher ={Association for Computing Machinery ({ACM})},
     volume ={60},
     number ={6},
      pages ={84--90}}A more severe example that need manual correction is as follows>>>frombib_lookupimportBibLookup>>>bl=BibLookup()>>>print(bl("10.1093/acprof:oso/9780195058239.001.0001"))@book{Malmivuo_1995,author={JaakkoMalmivuoandRobertPlonsey},title={{BioelectromagnetismPrinciples}andApplicationsofBioelectricandBiomagneticFields},doi={10.1093/acprof:oso/9780195058239.001.0001},year={1995},month={10},publisher={OxfordUniversityPress}}Adjust it to@book{Malmivuo_1995,
     author ={Jaakko Malmivuo and Robert Plonsey},
      title ={{Bioelectromagnetism: Principles and Applications of Bioelectric and Biomagnetic Fields}},
        doi ={10.1093/acprof:oso/9780195058239.001.0001},
       year ={1995},
      month ={10},
  publisher ={Oxford University Press}}This shows that the data in the DOI database isNOTalways correct.:point_right:Back to TOCBiblatex CheetsheetThis filedownloaded from [6] gives full knowledge aboutbibentries.:point_right:Back to TOCCitation@misc{https://doi.org/10.5281/zenodo.6435017,
     author ={WEN, Hao},
      title ={bib\_lookup: A Useful Tool for Uooking Up Bib Entries},
        doi ={10.5281/ZENODO.6435017},
        url ={https://zenodo.org/record/6435017},
  publisher ={Zenodo},
       year ={2022},
  copyright ={MIT License}}The above citation can be get via>>>frombib_lookupimportBibLookup>>>bl=BibLookup()>>>print(bl("DOI: 10.5281/zenodo.6435017")):point_right:Back to TOCReferenceshttps://github.com/davidagraf/doi2bib2https://arxiv.org/help/apihttps://github.com/mfcovington/pubmed-lookup/https://serpapi.com/google-scholar-cite-apihttps://www.bibtex.com/http://tug.ctan.org/info/biblatex-cheatsheet/biblatex-cheatsheet.pdf:point_right:Back to TOC