muschellij2 / rscopus

Scopus Database API Interface to R
75 stars 16 forks source link

Minor issue with bibtext_core_data for punctuated titles #49

Closed mgirdwood7 closed 8 months ago

mgirdwood7 commented 8 months ago

Hi there, thanks for the very useful package.

I have encountered a small issue when generating a .bib file using bibtex_core_data. The problem occurs when article titles have punctuation with the first word:

e.g.:"Comprehensiveness, accuracy, quality, credibility and readability of online information about knee osteoarthritis"

Here split_title = strsplit(title, " ")[[1]] in the function brings the comma with the first word along with it. I.e. the value for split title in this example is "Comprehensiveness,"

this affects the bib key later, as there is a comma in it which produced a read-in error for me

I came across this while modifying your function slightly for my own use, and fixed it with: split_title = gsub("[[:punct:]]", "", strsplit(title, " ")[[1]])

thanks in advance

muschellij2 commented 8 months ago

Can you please submit a reprex: https://reprex.tidyverse.org/?

mgirdwood7 commented 8 months ago

Sorry, of course, see below.

I also discovered another issue where there is a problem with the bibkey if the lead author has multiple surnames or a space in their name, as it generates a space in the bibkey. Second example in my reprex shows it

library(rscopus)

# This is the doi of an example result that caused the issue
example <- abstract_retrieval(id = "10.1177/18333583221090579", identifier = "doi")
#> HTTP specified is:https://api.elsevier.com/content/abstract/doi/10.1177/18333583221090579

bib <- bibtex_core_data(example)

# first 100 characters shows the error
print(substr(bib, 1, 100))
#> [1] "@article{Goff2023Comprehensiveness,osteoarthritis,\nauthor = {Anthony J Goff and Christian J Barton a"

###
# Example of the author with multiple surnamesnames/spaces issue
example2 <- abstract_retrieval(id = "10.1136/bmjopen-2022-068040", identifier = "doi")
#> HTTP specified is:https://api.elsevier.com/content/abstract/doi/10.1136/bmjopen-2022-068040
bib <- bibtex_core_data(example2)
print(substr(bib, 1, 100))
#> [1] "@article{De Oliveira Silva2023Trajectoryprotocol,\nauthor = {Danilo De Oliveira Silva and Richard T. "

Created on 2024-01-29 with reprex v2.0.2

muschellij2 commented 8 months ago

Should be fixed - thanks.