Commit
·
28cb51e
1
Parent(s):
8052e2b
Initial version
Browse files- README.md +111 -0
- articles.csv +0 -0
README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# PubMed H5N1 Articles
|
| 8 |
+
|
| 9 |
+
_Current as of January 5, 2025_
|
| 10 |
+
|
| 11 |
+
This dataset is metadata (id, publication date, title, link) from PubMed articles related to H5N1. It was created using [paperetl](https://github.com/neuml/paperetl) and the [PubMed Baseline](https://pubmed.ncbi.nlm.nih.gov/download/).
|
| 12 |
+
|
| 13 |
+
The 37 million articles were filtered to match either of the following criteria.
|
| 14 |
+
|
| 15 |
+
- MeSH code = [D053124](https://meshb-prev.nlm.nih.gov/record/ui?ui=D053124)
|
| 16 |
+
- Keyword of `H5N1` in either the `title` or `abstract`
|
| 17 |
+
|
| 18 |
+
## Retrieve article abstracts
|
| 19 |
+
|
| 20 |
+
The full article abstracts can be retrieved via the [PubMed API](https://www.nlm.nih.gov/dataguide/eutilities/utilities.html#efetch). This method accepts batches of PubMed IDs.
|
| 21 |
+
|
| 22 |
+
Alternatively, the dataset can be recreated using the following steps and loading the abstracts into the dataset (see step 5).
|
| 23 |
+
|
| 24 |
+
## Download and build
|
| 25 |
+
|
| 26 |
+
The following steps recreate this dataset.
|
| 27 |
+
|
| 28 |
+
1. Create the following directories and files
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
mkdir -p pubmed/config pubmed/data
|
| 32 |
+
|
| 33 |
+
echo "D053124" > pubmed/config/codes
|
| 34 |
+
echo "H5N1" > pubmed/config/keywords
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
2. Install `paperetl` and download `PubMed Baseline + Updates` into `pubmed/data`.
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install paperetl datasets
|
| 41 |
+
|
| 42 |
+
# Install paperetl from GitHub until v2.4.0 is released
|
| 43 |
+
pip install git+https://github.com/neuml/paperetl
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
3. Parse the PubMed dataset into article metadata
|
| 47 |
+
|
| 48 |
+
```bash
|
| 49 |
+
python -m paperetl.file pubmed/data pubmed/articles pubmed/config
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
4. Export to dataset
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from datasets import Dataset
|
| 56 |
+
|
| 57 |
+
ds = Dataset.from_sql(
|
| 58 |
+
("SELECT id id, published published, title title, reference reference FROM articles "
|
| 59 |
+
"ORDER BY published DESC"),
|
| 60 |
+
f"sqlite:///pubmed/articles/articles.sqlite"
|
| 61 |
+
)
|
| 62 |
+
ds.to_csv(f"pubmed-h5n1/articles.csv")
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
5. _Optional_ Export to dataset with all fields
|
| 66 |
+
|
| 67 |
+
paperetl parses all metadata and article abstracts. If you'd like to create a local dataset with the abstracts, run the following instead of step 4.
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
import sqlite3
|
| 71 |
+
import uuid
|
| 72 |
+
|
| 73 |
+
from datasets import Dataset
|
| 74 |
+
|
| 75 |
+
class Export:
|
| 76 |
+
def __init__(self, dbfile):
|
| 77 |
+
# Load database
|
| 78 |
+
self.connection = sqlite3.connect(dbfile)
|
| 79 |
+
self.connection.row_factory = sqlite3.Row
|
| 80 |
+
|
| 81 |
+
def __call__(self):
|
| 82 |
+
# Create cursors
|
| 83 |
+
cursor1 = self.connection.cursor()
|
| 84 |
+
cursor2 = self.connection.cursor()
|
| 85 |
+
|
| 86 |
+
# Get article metadata
|
| 87 |
+
cursor1.execute("SELECT * FROM articles ORDER BY id")
|
| 88 |
+
for row in cursor1:
|
| 89 |
+
# Get abstract text
|
| 90 |
+
cursor2.execute(
|
| 91 |
+
"SELECT text FROM sections WHERE article = ? and name != 'TITLE' ORDER BY id",
|
| 92 |
+
[row[0]]
|
| 93 |
+
)
|
| 94 |
+
abstract = " ".join(r["text"] for r in cursor2)
|
| 95 |
+
|
| 96 |
+
# Combine into single record and yield
|
| 97 |
+
row = {**row, **{"abstract": abstract}}
|
| 98 |
+
yield {k.lower(): v for k, v in row.items()}
|
| 99 |
+
|
| 100 |
+
def __reduce__(self):
|
| 101 |
+
return (pickle, (str(uuid.uuid4()),))
|
| 102 |
+
|
| 103 |
+
def pickle(self, *args, **kwargs):
|
| 104 |
+
raise AssertionError("Generator pickling workaround")
|
| 105 |
+
|
| 106 |
+
# Path to database
|
| 107 |
+
export = Export("pubmed/articles/articles.sqlite")
|
| 108 |
+
ds = Dataset.from_generator(export)
|
| 109 |
+
ds = ds.sort("published", reverse=True)
|
| 110 |
+
ds.to_csv("pubmed-h5n1-full/articles.csv")
|
| 111 |
+
```
|
articles.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|