Skip to content

Commit

Permalink
Various arXiv improvements (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored Apr 3, 2024
1 parent bdd6eb6 commit a75a961
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cmd/arxiv.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Thank you to arXiv for use of its open access interoperability.`,
"field_full_title",
"field_abstract",
"field_linked_agent",
"field_publisher",
"field_identifier",
"field_related_item",
"field_rights",
Expand Down Expand Up @@ -135,8 +136,10 @@ Thank you to arXiv for use of its open access interoperability.`,
log.Fatal(e.ID)
}

log.Println("Fetching", matches[1])
url := fmt.Sprintf("https://export.arxiv.org/oai2?verb=GetRecord&identifier=oai:arXiv.org:%s&metadataPrefix=arXiv", matches[1])
e.ID = matches[1]

log.Println("Fetching", e.ID)
url := fmt.Sprintf("https://export.arxiv.org/oai2?verb=GetRecord&identifier=oai:arXiv.org:%s&metadataPrefix=arXiv", e.ID)
oai := arxiv.GetOaiRecord(url)
if e.JournalRef != "" {
e.JournalRef = fmt.Sprintf(`{"title": "%s"}`, e.JournalRef)
Expand Down Expand Up @@ -186,6 +189,7 @@ Thank you to arXiv for use of its open access interoperability.`,
e.Title,
e.Summary,
oai["field_linked_agent"],
"arXiv",
strings.Join(identifiers, "|"),
e.JournalRef,
oai["field_rights"],
Expand Down
4 changes: 3 additions & 1 deletion cmd/doi.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ var (
for _, author := range doiObject.Authors {
linkedAgent = append(linkedAgent, fmt.Sprintf("relators:aut:person:%s, %s", author.Family, author.Given))
}
var publisher []string
if doiObject.Publisher != "" {
linkedAgent = append(linkedAgent, fmt.Sprintf("relators:pbl:corporate_body:%s", doiObject.Publisher))
publisher = append(publisher, fmt.Sprintf("relators:pbl:corporate_body:%s", doiObject.Publisher))
}
identifiers := []string{
fmt.Sprintf(`{"attr0":"doi","value":"%s"}`, doiObject.DOI),
Expand Down Expand Up @@ -119,6 +120,7 @@ var (
doiObject.Abstract,
"Digital Document",
strings.Join(linkedAgent, "|"),
strings.Join(publisher, "|"),
strings.Join(identifiers, "|"),
strings.Join(partDetail, "|"),
strings.Join(relatedItem, "|"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/arxiv/oai.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func ParseOaiResponse(body []byte) map[string]string {

var authors []string
for _, author := range oaiResponse.Record.Authors.Authors {
authors = append(authors, fmt.Sprintf("%s, %s", author.KeyName, author.ForeName))
authors = append(authors, fmt.Sprintf("relators:cre:person:%s, %s", author.KeyName, author.ForeName))
}
values["field_linked_agent"] = strings.Join(authors, "|")

Expand Down
2 changes: 1 addition & 1 deletion pkg/arxiv/oai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestGetOaiRecord(t *testing.T) {
// Verify the result
expected := map[string]string{
"field_rights": "https://test-license.com",
"field_linked_agent": "Author1LastName, Author1FirstName|Author2LastName, Author2FirstName",
"field_linked_agent": "relators:cre:person:Author1LastName, Author1FirstName|relators:cre:person:Author2LastName, Author2FirstName",
}
for key, value := range expected {
if result[key] != value {
Expand Down

0 comments on commit a75a961

Please sign in to comment.