-
Notifications
You must be signed in to change notification settings - Fork 35
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
e07d330
commit 0acb8e0
Showing
10 changed files
with
56 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Misc utils to download chemRxiv dump""" | ||
|
||
import json | ||
import logging | ||
import os | ||
|
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 |
---|---|---|
@@ -1,31 +1,34 @@ | ||
from paperscraper.pubmed import get_and_dump_pubmed_papers, get_pubmed_papers | ||
from paperscraper.pubmed.utils import get_query_from_keywords_and_date | ||
import os | ||
import pytest | ||
from unittest.mock import patch | ||
import tempfile | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from paperscraper.pubmed import get_and_dump_pubmed_papers, get_pubmed_papers | ||
from paperscraper.pubmed.utils import get_query_from_keywords_and_date | ||
|
||
KEYWORDS = [['machine learning', 'deep learning'], ['zoology']] | ||
KEYWORDS = [["machine learning", "deep learning"], ["zoology"]] | ||
|
||
|
||
class TestPubMed: | ||
|
||
def test_get_and_dump_pubmed(self): | ||
with tempfile.TemporaryDirectory() as temp_dir: | ||
output_filepath = os.path.join(temp_dir, 'tmp.jsonl') | ||
output_filepath = os.path.join(temp_dir, "tmp.jsonl") | ||
get_and_dump_pubmed_papers(KEYWORDS, output_filepath=output_filepath) | ||
assert os.path.exists(output_filepath), "File was not created" | ||
|
||
def test_email(self): | ||
query = get_query_from_keywords_and_date(KEYWORDS, start_date='2020/07/20') | ||
df = get_pubmed_papers(query, fields=['emails', 'title', 'authors']) | ||
assert 'emails' in df.columns | ||
|
||
query = get_query_from_keywords_and_date(KEYWORDS, end_date='2020/07/20') | ||
df = get_pubmed_papers(query, fields=['emails', 'title', 'authors']) | ||
assert 'emails' in df.columns | ||
def test_email(self): | ||
query = get_query_from_keywords_and_date(KEYWORDS, start_date="2020/07/20") | ||
df = get_pubmed_papers(query, fields=["emails", "title", "authors"]) | ||
assert "emails" in df.columns | ||
|
||
query = get_query_from_keywords_and_date(KEYWORDS, start_date='2020/07/10', end_date='2020/07/20') | ||
df = get_pubmed_papers(query, fields=['emails', 'title', 'authors']) | ||
assert 'emails' in df.columns | ||
query = get_query_from_keywords_and_date(KEYWORDS, end_date="2020/07/20") | ||
df = get_pubmed_papers(query, fields=["emails", "title", "authors"]) | ||
assert "emails" in df.columns | ||
|
||
query = get_query_from_keywords_and_date( | ||
KEYWORDS, start_date="2020/07/10", end_date="2020/07/20" | ||
) | ||
df = get_pubmed_papers(query, fields=["emails", "title", "authors"]) | ||
assert "emails" in df.columns |
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
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
from paperscraper.xrxiv.xrxiv_query import XRXivQuery | ||
from paperscraper.get_dumps import medrxiv | ||
import os | ||
|
||
from paperscraper.get_dumps import medrxiv | ||
from paperscraper.xrxiv.xrxiv_query import XRXivQuery | ||
|
||
|
||
|
||
covid19 = ['COVID-19', 'SARS-CoV-2'] | ||
ai = ['Artificial intelligence', 'Deep learning', 'Machine learning'] | ||
mi = ['Medical imaging'] | ||
covid19 = ["COVID-19", "SARS-CoV-2"] | ||
ai = ["Artificial intelligence", "Deep learning", "Machine learning"] | ||
mi = ["Medical imaging"] | ||
|
||
|
||
class TestXRXiv: | ||
|
||
def test_get_medrxiv(self): | ||
medrxiv(begin_date="2020-05-01", end_date="2020-05-10", save_path='medrix_tmp_dump.jsonl') | ||
|
||
medrxiv( | ||
begin_date="2020-05-01", | ||
end_date="2020-05-10", | ||
save_path="medrix_tmp_dump.jsonl", | ||
) | ||
|
||
def test_xriv_querier(self): | ||
querier = XRXivQuery('medrix_tmp_dump.jsonl') | ||
querier = XRXivQuery("medrix_tmp_dump.jsonl") | ||
query = [covid19, ai, mi] | ||
querier.search_keywords(query, output_filepath='covid19_ai_imaging.jsonl') | ||
assert os.path.exists('covid19_ai_imaging.jsonl') | ||
|
||
querier.search_keywords(query, output_filepath="covid19_ai_imaging.jsonl") | ||
assert os.path.exists("covid19_ai_imaging.jsonl") |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Query dumps from bioRxiv and medRXiv.""" | ||
|
||
import logging | ||
import sys | ||
from typing import List, Union | ||
|