COVID-19 開放研究資料集

COVID-19 及冠狀病毒相關的學術性文章全文與中繼資料資料集,已經過優化而使機器能夠讀取,並開放給全球研究社群使用。

為了應對 COVID-19 疫情, 艾倫 AI 研究所已與領先的研究小組合作,準備及發佈 COVID-19 開放研究資料集(CORD-19)。 此資料集是超過 47,000 篇學術文章的免費資源,包括超過 36,000 篇全文、關於 COVID-19 和全球研究社群使用的病毒系列。

這個資料集動員研究人員應用最近在自然語言處理方面的進展,以產生新的見解,以支援這種傳染病的防治。

當新研究收錄於經過同儕審查的出版刊物,以及像是 bioRxivmedRxiv 等典藏服務時,語料庫可能會隨之更新。

注意

Microsoft 會以「如目前」為基礎提供 Azure 開放資料集。 Microsoft 不會就您使用資料集做出任何明示或默示擔保或條件。 根據當地法律所允許的範圍,Microsoft 會免除因使用資料集而產生的任何損害或損失的所有責任,包括直接、衍生、特殊、間接、附帶或懲罰性。

此資料集是根據 Microsoft 接收來源資料的原始條款所提供。 資料集可能包含源自 Microsoft 的資料。

授權條款

艾倫 AI 與 語意學者 研究所提供此資料集。 存取、下載或使用 CORD-19 資料集提供的任何內容,即代表您同意與本資料集使用上相關的資料集授權。 中繼資料檔案有提供資料集中個別文章的專屬授權資訊。 PMC 網站、 medRxiv 網站 bioRxiv 網站 提供 更多授權資訊。

磁片區和保留期

此資料集會以 JSON 格式儲存,而最新版本包含超過 36,000 篇全文檢索文章。 每篇論文各代表一個 JSON 物件。 檢視架構

儲存位置

此資料集儲存於美國東部 Azure 區域。 建議在美國東部尋找計算資源,以取得親和性。

引文

在發行集或轉散發中包含 CORD-19 資料時,請參考資料集,如下所示:

在參考書目中:

COVID-19 開放研究資料集 (COVID-19 Open Research Dataset,CORD-19)。 2020 年。 YYYY-MM-DD 版。 擷取自 COVID-19 開放研究資料集 (COVID-19 Open Research Dataset,CORD-19)。 存取日期 YYYY-MM-DD。 doi:10.5281/zenodo.3715505

文字: (CORD-19, 2020)

連絡人

對於此資料集如有任何問題,請連絡 partnerships@allenai.org。

資料存取

Azure Notebooks

CORD-19 資料集

CORD-19 是一系列超過 50,000 篇學術文章的集合,包括超過 40,000 篇全文,涉及 COVID-19、SARS-CoV-2 和相關日冕病毒。 此資料集已免費提供,目標是協助研究社群對抗 COVID-19 大流行。

此筆記本的目標是兩倍:

  1. 示範如何在 Azure 上存取 CORD-19 資料集:我們會連線到存放 CORD-19 資料集的 Azure Blob 儲存體帳戶。
  2. 逐步解說資料集的結構:資料集中的文章會儲存為 json 檔案。 我們提供顯示下列範例:
  • 如何尋找文章(流覽容器)
  • 如何閱讀文章(流覽 json 架構)

相依性:此筆記本需要下列程式庫:

  • Azure 儲存體 (例如, pip install azure-storage
  • NLTK (
  • Pandas (例如, pip install pandas

從 Azure 取得 CORD-19 資料

CORD-19 資料已在此 上傳為 Azure 開放資料集 。 我們會建立連結至此 CORD-19 開放資料集的 Blob 服務。

from azure.storage.blob import BlockBlobService

# storage account details
azure_storage_account_name = "azureopendatastorage"
azure_storage_sas_token = "sv=2019-02-02&ss=bfqt&srt=sco&sp=rlcup&se=2025-04-14T00:21:16Z&st=2020-04-13T16:21:16Z&spr=https&sig=JgwLYbdGruHxRYTpr5dxfJqobKbhGap8WUtKFadcivQ%3D"

# create a blob service
blob_service = BlockBlobService(
    account_name=azure_storage_account_name,
    sas_token=azure_storage_sas_token,
)

我們可以使用此 Blob 服務作為資料的控制碼。 我們可以巡覽資料集,以使用 BlockBlobService API。 如需詳細資訊,請參閱這裡:

CORD-19 資料會儲存在容器中 covid19temp 。 這是容器內的檔案結構,以及範例檔案。

metadata.csv
custom_license/
    pdf_json/
        0001418189999fea7f7cbe3e82703d71c85a6fe5.json        # filename is sha-hash
        ...
    pmc_json/
        PMC1065028.xml.json                                  # filename is the PMC ID
        ...
noncomm_use_subset/
    pdf_json/
        0036b28fddf7e93da0970303672934ea2f9944e7.json
        ...
    pmc_json/
        PMC1616946.xml.json
        ...
comm_use_subset/
    pdf_json/
        000b7d1517ceebb34e1e3e817695b6de03e2fa78.json
        ...
    pmc_json/
        PMC1054884.xml.json
        ...
biorxiv_medrxiv/                                             # note: there is no pmc_json subdir
    pdf_json/
        0015023cc06b5362d332b3baf348d11567ca2fbb.json
        ...

每個 .json 檔案都會對應至資料集中的個別發行項。 這是標題、作者、抽象和(可用處)全文檢索資料的儲存位置。

使用 metadata.csv

CORD-19 資料集隨附 metadata.csv - 單一檔案,記錄 CORD-19 資料集中所有可用檔的基本資訊。 這是開始探索的好地方!

# container housing CORD-19 data
container_name = "covid19temp"

# download metadata.csv
metadata_filename = 'metadata.csv'
blob_service.get_blob_to_path(
    container_name=container_name,
    blob_name=metadata_filename,
    file_path=metadata_filename
)
import pandas as pd

# read metadata.csv into a dataframe
metadata_filename = 'metadata.csv'
metadata = pd.read_csv(metadata_filename)
metadata.head(3)

第一眼看,這要花很多,所以讓我們套用一點拋光。

simple_schema = ['cord_uid', 'source_x', 'title', 'abstract', 'authors', 'full_text_file', 'url']

def make_clickable(address):
    '''Make the url clickable'''
    return '<a href="{0}">{0}</a>'.format(address)

def preview(text):
    '''Show only a preview of the text data.'''
    return text[:30] + '...'

format_ = {'title': preview, 'abstract': preview, 'authors': preview, 'url': make_clickable}

metadata[simple_schema].head().style.format(format_)
# let's take a quick look around
num_entries = len(metadata)
print("There are {} many entries in this dataset:".format(num_entries))

metadata_with_text = metadata[metadata['full_text_file'].isna() == False]
with_full_text = len(metadata_with_text)
print("-- {} have full text entries".format(with_full_text))

with_doi = metadata['doi'].count()
print("-- {} have DOIs".format(with_doi))

with_pmcid = metadata['pmcid'].count()
print("-- {} have PubMed Central (PMC) ids".format(with_pmcid))

with_microsoft_id = metadata['Microsoft Academic Paper ID'].count()
print("-- {} have Microsoft Academic paper ids".format(with_microsoft_id))
There are 51078 many entries in this dataset:
-- 42511 have full text entries
-- 47741 have DOIs
-- 41082 have PubMed Central (PMC) ids
-- 964 have Microsoft Academic paper ids

範例:讀取全文檢索

metadata.csv 不包含全文檢索本身。 讓我們看看如何讀取該範例。 找出並解壓縮全文檢索 json,並將其轉換成句子清單。

# choose a random example with pdf parse available
metadata_with_pdf_parse = metadata[metadata['has_pdf_parse']]
example_entry = metadata_with_pdf_parse.iloc[42]

# construct path to blob containing full text
blob_name = '{0}/pdf_json/{1}.json'.format(example_entry['full_text_file'], example_entry['sha'])  # note the repetition in the path
print("Full text blob for this entry:")
print(blob_name)

我們現在可以讀取與此 Blob 相關聯的 JSON 內容,如下所示。

import json
blob_as_json_string = blob_service.get_blob_to_text(container_name=container_name, blob_name=blob_name)
data = json.loads(blob_as_json_string.content)

# in addition to the body text, the metadata is also stored within the individual json files
print("Keys within data:", ', '.join(data.keys()))

針對此範例的目的,我們對 儲存文字資料的 感興趣 body_text ,如下所示:

"body_text": [                      # list of paragraphs in full body
    {
        "text": <str>,
        "cite_spans": [             # list of character indices of inline citations
                                    # e.g. citation "[7]" occurs at positions 151-154 in "text"
                                    #      linked to bibliography entry BIBREF3
            {
                "start": 151,
                "end": 154,
                "text": "[7]",
                "ref_id": "BIBREF3"
            },
            ...
        ],
        "ref_spans": <list of dicts similar to cite_spans>,     # e.g. inline reference to "Table 1"
        "section": "Abstract"
    },
    ...
]

這裡提供 完整的 JSON 架構。

from nltk.tokenize import sent_tokenize

# the text itself lives under 'body_text'
text = data['body_text']

# many NLP tasks play nicely with a list of sentences
sentences = []
for paragraph in text:
    sentences.extend(sent_tokenize(paragraph['text']))

print("An example sentence:", sentences[0])

PDF 與 PMC XML 剖析

在上述範例中,我們查看了 使用 has_pdf_parse == True 的案例。 在此情況下,Blob 檔案路徑的格式如下:

'<full_text_file>/pdf_json/<sha>.json'

或者,針對使用 has_pmc_xml_parse == True 下列格式的案例:

'<full_text_file>/pmc_json/<pmcid>.xml.json'

例如:

# choose a random example with pmc parse available
metadata_with_pmc_parse = metadata[metadata['has_pmc_xml_parse']]
example_entry = metadata_with_pmc_parse.iloc[42]

# construct path to blob containing full text
blob_name = '{0}/pmc_json/{1}.xml.json'.format(example_entry['full_text_file'], example_entry['pmcid'])  # note the repetition in the path
print("Full text blob for this entry:")
print(blob_name)

blob_as_json_string = blob_service.get_blob_to_text(container_name=container_name, blob_name=blob_name)
data = json.loads(blob_as_json_string.content)

# the text itself lives under 'body_text'
text = data['body_text']

# many NLP tasks play nicely with a list of sentences
sentences = []
for paragraph in text:
    sentences.extend(sent_tokenize(paragraph['text']))

print("An example sentence:", sentences[0])
Full text blob for this entry:
custom_license/pmc_json/PMC546170.xml.json
An example sentence: Double-stranded small interfering RNA (siRNA) molecules have drawn much attention since it was unambiguously shown that they mediate potent gene knock-down in a variety of mammalian cells (1).

直接逐一查看 Blob

在上述範例中 metadata.csv ,我們使用 檔案來巡覽資料、建構 Blob 檔案路徑,以及從 Blob 讀取資料。 替代方式是逐一查看 Blob 本身。

# get and sort list of available blobs
blobs = blob_service.list_blobs(container_name)
sorted_blobs = sorted(list(blobs), key=lambda e: e.name, reverse=True)

現在我們可以直接逐一查看 Blob。 例如,讓我們計算可用的 json 檔案數目。

# we can now iterate directly though the blobs
count = 0
for blob in sorted_blobs:
    if blob.name[-5:] == ".json":
        count += 1
print("There are {} many json files".format(count))
There are 59784 many json files

附錄

資料品質問題

這是一個大型資料集,基於明顯原因,相當匆忙地拼湊在一起! 以下是我們觀察到的一些資料品質問題。

多個 shas

我們觀察到,在某些情況下,指定專案有多個 shas。

metadata_multiple_shas = metadata[metadata['sha'].str.len() > 40]

print("There are {} many entries with multiple shas".format(len(metadata_multiple_shas)))

metadata_multiple_shas.head(3)
There are 1999 many entries with multiple shas

容器的配置

在此,我們會使用簡單的 RegEx 來探索容器的檔案結構,以防日後更新。

container_name = "covid19temp"
blobs = blob_service.list_blobs(container_name)
sorted_blobs = sorted(list(blobs), key=lambda e: e.name, reverse=True)
import re
dirs = {}

pattern = '([\w]+)\/([\w]+)\/([\w.]+).json'
for blob in sorted_blobs:
    
    m = re.match(pattern, blob.name)
    
    if m:
        dir_ = m[1] + '/' + m[2]
        
        if dir_ in dirs:
            dirs[dir_] += 1
        else:
            dirs[dir_] = 1
        
dirs

下一步

檢視開放式資料集目錄中 的其餘資料集