Public
Edited
Nov 25, 2022
2 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function normalizeScopusData(sd) {
let res = {
pub: { Source: { SourceSerial:{} } },
org: Object.assign({}, sd)
}

res.pub.Source.SourceSerial.Title = res.org.publicationMetadata["prism:publicationName"] ?
res.org.publicationMetadata["prism:publicationName"] : undefined
res.sourceId = res.org.publicationMetadata["source-id"] ?
res.org.publicationMetadata["source-id"].trim() : undefined
res.issn = res.org.publicationMetadata["prism:issn"] ?
res.org.publicationMetadata["prism:issn"].replace(/-/g,"").trim().toLowerCase() : undefined
res.eIssn = res.org.publicationMetadata["prism:eIssn"] ?
res.org.publicationMetadata["prism:eIssn"].replace(/-/g,"").trim().toLowerCase() : undefined
res.pub.Year = res.org.publicationMetadata["prism:coverDate"] ?
parseInt(res.org.publicationMetadata["prism:coverDate"].trim()) : undefined
res.pub.Title = res.org.publicationMetadata["dc:title"] ?
res.org.publicationMetadata["dc:title"].trim() : undefined
res.pub.Source.Volume = res.org.publicationMetadata["prism:volume"] ?
res.org.publicationMetadata["prism:volume"].trim() : undefined
res.pub.Source.Issue = res.org.publicationMetadata["prism:issueIdentifier"] ?
res.org.publicationMetadata["prism:issueIdentifier"].trim() : undefined
res.pub.Source.ArticleNo = res.org.publicationMetadata["article-number"] ?
res.org.publicationMetadata["article-number"].trim() : undefined

if (sd.publicationMetadata.eid && sd.publicationMetadata.eid.trim()) {
res.pub.IdentifierScopusId = [ sd.publicationMetadata.eid.trim().replace("2-s2.0-","") ]
} else {
res.pub.IdentifierScopusId = []
}

if (sd.publicationMetadata["prism:doi"] && sd.publicationMetadata["prism:doi"].trim()) {
res.pub.IdentifierDoi = [ sd.publicationMetadata["prism:doi"].trim() ]
} else {
res.pub.IdentifierDoi = []
}

// We see publication as open access if the following is true
// + openaccessFlag got truthy value
// + freetoread is not "publisherfree2read"
let freetoreadArr = []
if (!sd.publicationMetadata.freetoread) {
freetoreadArr = []
} else if (Array.isArray(sd.publicationMetadata.freetoread.value)) {
freetoreadArr = sd.publicationMetadata.freetoread.value.map(x => x["$"])
} else if (typeof sd.publicationMetadata.freetoread.value === "object") {
freetoreadArr = [ sd.publicationMetadata.freetoread.value.concreteValue ]
}
res.pub.DataObjects = [
{
IsOpenAccess: sd.publicationMetadata.openaccessFlag &&
!freetoreadArr.some(ftr => ftr === "publisherfree2read")
}
]
res.freetoread = freetoreadArr

// Simplify freetoreadLabel also
let freetoreadLabelArr = []
if (!sd.publicationMetadata.freetoreadLabel) {
freetoreadLabelArr = []
} else if (Array.isArray(sd.publicationMetadata.freetoreadLabel.value)) {
freetoreadLabelArr = sd.publicationMetadata.freetoreadLabel.value.map(x => x["$"])
} else if (typeof sd.publicationMetadata.freetoreadLabel.value === "object") {
freetoreadLabelArr = [ sd.publicationMetadata.freetoreadLabel.value.concreteValue ]
}
res.freetoreadLabel = freetoreadLabelArr

res.pub.Keywords = sd.publicationMetadata.authkeywords ?
sd.publicationMetadata.authkeywords.split("|").map(kw => {
return {
Value: kw.trim()
}
}) : []

let pageRange = res.org.publicationMetadata["prism:pageRange"]
if (pageRange && pageRange.trim()) {
let pageRangeParts = pageRange.trim().split(/[-–]/g).map(v => v.trim())
if (pageRangeParts.length === 2) {
res.pub.Source.PageStart = pageRangeParts[0]
res.pub.Source.PageEnd = pageRangeParts[1]
} else {
res.pub.Source.PageStart = pageRange
res.pub.Source.PageEnd = pageRange
}
}
return res
}
Insert cell
function normalizeResearchData(rd) {
let res = {
pub: { Source: { SourceSerial: {} } },
org: Object.assign({}, rd)
}

// Scopus identifier - strip away "2-s2.0-"
res.pub.IdentifierScopusId = res.org.IdentifierScopusId.map(id => id.replace("2-s2.0-", ""))

if (res.org.Source && res.org.Source.SourceSerial) {
// Scopus source ID
let researchScopusSourceIds = res.org.Source.SourceSerial.Identifiers
.filter(ssId => ssId.Type.Value === "SCOPUS_SOURCE_ID")
if (researchScopusSourceIds.length > 1) {
throw new Error(`${res.org.Id} got multiple Scopus Source IDs from Research.`)
}
res.scopusSourceId = researchScopusSourceIds.length === 1 ?
researchScopusSourceIds[0].Value.replace(/-/g,"").trim() : undefined
// ISSN
let researchIssns = res.org.Source.SourceSerial.Identifiers
.filter(ssId => ssId.Type.Value === "ISSN")
if (researchIssns.length > 1) {
throw new Error(`${res.org.Id} got multiple ISSN from Research.`)
}
res.issn = researchIssns.length === 1 ?
researchIssns[0].Value.replace(/-/g,"").trim().toLowerCase() : undefined
// eISSN
let researchEissns = res.org.Source.SourceSerial.Identifiers
.filter(ssId => ssId.Type.Value === "EISSN")
if (researchEissns.length > 1) {
throw new Error(`${res.org.Id} got multiple EISSN from Research.`)
}
res.eIssn = researchEissns.length === 1 ?
researchEissns[0].Value.replace(/-/g,"").trim().toLowerCase() : undefined
}

// Other
res.pub.Id = res.org.Id
res.pub.Title = res.org.Title
res.pub.Year = res.org.Year
res.pub.Source.SourceSerial.Title = res.org.Source && res.org.Source.SourceSerial ?
res.org.Source.SourceSerial.Title : undefined
res.pub.Source.Volume = res.org.Source && res.org.Source.Volume ? res.org.Source.Volume.trim() : undefined
res.pub.Source.Issue = res.org.Source && res.org.Source.Issue ? res.org.Source.Issue.trim() : undefined
res.pub.Source.ArticleNo = res.org.Source && res.org.Source.ArticleNo ?
res.org.Source.ArticleNo.trim() : undefined
res.pub.Source.PageStart = res.org.Source && res.org.Source.PageStart ?
res.org.Source.PageStart.trim() : undefined
res.pub.Source.PageEnd = res.org.Source && res.org.Source.PageEnd ? res.org.Source.PageEnd.trim() : undefined
res.pub.IdentifierDoi = res.org.IdentifierDoi.slice()
res.pub.DataObjects = res.org.DataObjects ? res.org.DataObjects.slice() : []
res.pub.Keywords = res.org.Keywords ? res.org.Keywords.slice() : []
res.pub.Identifiers = res.org.Identifiers ? res.org.Identifiers.slice() : []
return res
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more