-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76bfc6e
commit bd8911b
Showing
14 changed files
with
434 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
CREATE FUNCTION reference_papers_to_scrape() | ||
RETURNS TABLE ( | ||
id UUID, | ||
doi CITEXT, | ||
citations_scraped_at TIMESTAMPTZ | ||
) | ||
LANGUAGE sql STABLE AS | ||
$$ | ||
SELECT id, doi, citations_scraped_at | ||
FROM mention | ||
WHERE id IN ( | ||
SELECT mention FROM reference_paper_for_software | ||
) | ||
$$; |
14 changes: 14 additions & 0 deletions
14
scrapers/src/main/java/nl/esciencecenter/rsd/scraper/doi/CitationData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package nl.esciencecenter.rsd.scraper.doi; | ||
|
||
import java.util.UUID; | ||
|
||
public class CitationData { | ||
|
||
public UUID id; | ||
public String doi; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
scrapers/src/main/java/nl/esciencecenter/rsd/scraper/doi/MainCitations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package nl.esciencecenter.rsd.scraper.doi; | ||
|
||
import nl.esciencecenter.rsd.scraper.Config; | ||
import nl.esciencecenter.rsd.scraper.Utils; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
public class MainCitations { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Start scraping citations"); | ||
try { | ||
String backendUrl = Config.backendBaseUrl(); | ||
PostgrestCitationRepository localCitationRepository = new PostgrestCitationRepository(backendUrl); | ||
|
||
Collection<CitationData> doisToScrape = localCitationRepository.leastRecentlyScrapedCitations(5); | ||
OpenAlexCitations openAlexCitations = new OpenAlexCitations(); | ||
MentionRepository localMentionRepository = new PostgrestMentionRepository(backendUrl); | ||
String email = Config.crossrefContactEmail().orElse(null); | ||
ZonedDateTime now = ZonedDateTime.now(); | ||
|
||
for (CitationData citationData : doisToScrape) { | ||
Collection<MentionRecord> citingMentions = openAlexCitations.citations(citationData.doi, email); | ||
localMentionRepository.save(citingMentions); | ||
|
||
Collection<UUID> citingMentionIds = new ArrayList<>(); | ||
for (MentionRecord citingMention : citingMentions) { | ||
citingMentionIds.add(citingMention.id); | ||
} | ||
|
||
localCitationRepository.saveCitations(backendUrl, citationData.id, citingMentionIds, now); | ||
} | ||
} catch (RuntimeException e) { | ||
Utils.saveExceptionInDatabase("Citation scraper", null, null, e); | ||
} | ||
|
||
System.out.println("Done scraping citations"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.