Datasets:
Commit
•
df96b99
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +185 -0
- covid_qa_ucsd.py +273 -0
- dataset_infos.json +1 -0
- dummy/en/1.0.0/dummy_data.zip +3 -0
- dummy/zh/1.0.0/dummy_data.zip +3 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- found
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
- found
|
7 |
+
languages:
|
8 |
+
en:
|
9 |
+
- en
|
10 |
+
zh:
|
11 |
+
- zh
|
12 |
+
licenses:
|
13 |
+
- unknown
|
14 |
+
multilinguality:
|
15 |
+
- monolingual
|
16 |
+
size_categories:
|
17 |
+
en:
|
18 |
+
- n<1K
|
19 |
+
zh:
|
20 |
+
- 1K<n<10K
|
21 |
+
source_datasets:
|
22 |
+
- original
|
23 |
+
task_categories:
|
24 |
+
- question-answering
|
25 |
+
task_ids:
|
26 |
+
- closed-domain-qa
|
27 |
+
---
|
28 |
+
|
29 |
+
# Dataset Card for [Dataset Name]
|
30 |
+
|
31 |
+
## Table of Contents
|
32 |
+
- [Dataset Description](#dataset-description)
|
33 |
+
- [Dataset Summary](#dataset-summary)
|
34 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
35 |
+
- [Languages](#languages)
|
36 |
+
- [Dataset Structure](#dataset-structure)
|
37 |
+
- [Data Instances](#data-instances)
|
38 |
+
- [Data Fields](#data-fields)
|
39 |
+
- [Data Splits](#data-splits)
|
40 |
+
- [Dataset Creation](#dataset-creation)
|
41 |
+
- [Curation Rationale](#curation-rationale)
|
42 |
+
- [Source Data](#source-data)
|
43 |
+
- [Annotations](#annotations)
|
44 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
45 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
46 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
47 |
+
- [Discussion of Biases](#discussion-of-biases)
|
48 |
+
- [Other Known Limitations](#other-known-limitations)
|
49 |
+
- [Additional Information](#additional-information)
|
50 |
+
- [Dataset Curators](#dataset-curators)
|
51 |
+
- [Licensing Information](#licensing-information)
|
52 |
+
- [Citation Information](#citation-information)
|
53 |
+
|
54 |
+
## Dataset Description
|
55 |
+
|
56 |
+
- **Homepage:** https://github.com/UCSD-AI4H/COVID-Dialogue
|
57 |
+
- **Repository:** The data is also present in the same [GIT](https://github.com/UCSD-AI4H/COVID-Dialogue) repository
|
58 |
+
- **Paper:** https://pengtaoxie.github.io/coviddiag.pdf
|
59 |
+
- **Leaderboard:**
|
60 |
+
- **Point of Contact:**
|
61 |
+
|
62 |
+
### Dataset Summary
|
63 |
+
|
64 |
+
COVID-Dialogue-Dataset-English is an English medical dialogue dataset about COVID-19 and other types of pneumonia. Patients who are concerned that they may be infected by COVID-19 or other pneumonia consult doctors and doctors provide advice. There are 603 consultations.
|
65 |
+
|
66 |
+
COVID-Dialogue-Dataset-Chinese is a Chinese medical dialogue dataset about COVID-19 and other types of pneumonia. Patients who are concerned that they may be infected by COVID-19 or other pneumonia consult doctors and doctors provide advice. There are 1393 consultations.
|
67 |
+
|
68 |
+
The dataset is present as a single text file. COVID-Dialogue-Dataset-Chinese.txt for Chinese and COVID-Dialogue-Dataset-English.txt for English.
|
69 |
+
|
70 |
+
### Supported Tasks and Leaderboards
|
71 |
+
|
72 |
+
Used for QA tasks. There is also a COVID-19 dialogue generation model available for the Chinese Data. The pre-print and more information is available in [this arxiv pre-print](https://arxiv.org/abs/2005.05442).
|
73 |
+
|
74 |
+
### Languages
|
75 |
+
|
76 |
+
Monolingual. The datasets are in English (EN) and Chinese (ZH)
|
77 |
+
|
78 |
+
## Dataset Structure
|
79 |
+
|
80 |
+
### Data Instances
|
81 |
+
|
82 |
+
An example of dialogue is:
|
83 |
+
|
84 |
+
```
|
85 |
+
{
|
86 |
+
'dialogue_id': 602,
|
87 |
+
'dialogue_url': 'https://www.healthtap.com/member/fg?page=/search/covid',
|
88 |
+
'dialogue_turns': [{'speaker': 'Patient',
|
89 |
+
'utterance': 'Can coronavirus symptoms be mild for some people versus severe? For example, could it just involve being very fatigued, low grade fever for a few days and not the extreme symptoms? Or is it always a full blown cold and struggle to breathe?Can coronavirus symptoms be mild for some people versus severe? For example, could it just involve being very fatigued, low grade fever for a few days and not the extreme symptoms? Or is it always a full blown cold and struggle to breathe?'},
|
90 |
+
{'speaker': 'Doctor',
|
91 |
+
'utterance': 'In brief: Symptoms vary. Some may have no symptoms at all. Some can be life threatening. Would you like to video or text chat with me?'}]
|
92 |
+
}
|
93 |
+
```
|
94 |
+
|
95 |
+
The dataset is built from [icliniq.com](https://www.icliniq.com/), [healthcaremagic.com](https://www.healthcaremagic.com/), [healthtap.com](https://www.healthtap.com/) and all copyrights of the data belong to these websites. _(for English)_
|
96 |
+
|
97 |
+
The dataset is built from [Haodf.com](https://www.haodf.com/) and all copyrights of the data belong to [Haodf.com](https://www.haodf.com/). _(for Chinese)_
|
98 |
+
|
99 |
+
### Data Fields
|
100 |
+
|
101 |
+
Each consultation consists of the below:
|
102 |
+
- ID
|
103 |
+
- URL
|
104 |
+
- Description of patient’s medical condition
|
105 |
+
- Dialogue
|
106 |
+
- Diagnosis and suggestions (Optional, mostly for Chinese)
|
107 |
+
|
108 |
+
For generating the QA only the below fields have been considered:
|
109 |
+
- ID : Consultatation Identifier (restarts for each file)
|
110 |
+
- URL: The url link of the extracted conversation
|
111 |
+
- Dialogue : The conversation between the doctor and the patient.
|
112 |
+
|
113 |
+
These are arranged as below in the prepared dataset. Each item will be represented with these parameters.
|
114 |
+
|
115 |
+
- "file_name": string - signifies the file from which the conversation was extracted
|
116 |
+
- "dialogue_id": int32 - the dialogue id
|
117 |
+
- "dialogue_url": string - url of the conversation
|
118 |
+
- "dialogue_turns": datasets.Sequence - sequence of dialogues between patient and the doctor.Consists ClassLabel(names=["病人", "医生"]), and "utterance"(string) for each turn. (ClassLable(names=["Patient", "Doctor"]) for english)
|
119 |
+
|
120 |
+
### Data Splits
|
121 |
+
|
122 |
+
There are no data splits on the original data
|
123 |
+
|
124 |
+
## Dataset Creation
|
125 |
+
|
126 |
+
### Curation Rationale
|
127 |
+
|
128 |
+
[More Information Needed]
|
129 |
+
|
130 |
+
### Source Data
|
131 |
+
|
132 |
+
#### Initial Data Collection and Normalization
|
133 |
+
|
134 |
+
[More Information Needed]
|
135 |
+
|
136 |
+
#### Who are the source language producers?
|
137 |
+
|
138 |
+
[More Information Needed]
|
139 |
+
|
140 |
+
### Annotations
|
141 |
+
|
142 |
+
#### Annotation process
|
143 |
+
|
144 |
+
[More Information Needed]
|
145 |
+
|
146 |
+
#### Who are the annotators?
|
147 |
+
|
148 |
+
[More Information Needed]
|
149 |
+
|
150 |
+
### Personal and Sensitive Information
|
151 |
+
|
152 |
+
[More Information Needed]
|
153 |
+
|
154 |
+
## Considerations for Using the Data
|
155 |
+
|
156 |
+
### Social Impact of Dataset
|
157 |
+
|
158 |
+
[More Information Needed]
|
159 |
+
|
160 |
+
### Discussion of Biases
|
161 |
+
|
162 |
+
[More Information Needed]
|
163 |
+
|
164 |
+
### Other Known Limitations
|
165 |
+
|
166 |
+
[More Information Needed]
|
167 |
+
|
168 |
+
## Additional Information
|
169 |
+
|
170 |
+
### Dataset Curators
|
171 |
+
|
172 |
+
[More Information Needed]
|
173 |
+
|
174 |
+
### Licensing Information
|
175 |
+
|
176 |
+
[More Information Needed]
|
177 |
+
|
178 |
+
### Citation Information
|
179 |
+
|
180 |
+
@article{ju2020CovidDialog,
|
181 |
+
title={CovidDialog: Medical Dialogue Datasets about COVID-19},
|
182 |
+
author={Ju, Zeqian and Chakravorty, Subrato and He, Xuehai and Chen, Shu and Yang, Xingyi and Xie, Pengtao},
|
183 |
+
journal={ https://github.com/UCSD-AI4H/COVID-Dialogue},
|
184 |
+
year={2020}
|
185 |
+
}
|
covid_qa_ucsd.py
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Covid Dialog dataset in English and Chinese"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import copy
|
20 |
+
import os
|
21 |
+
import re
|
22 |
+
import textwrap
|
23 |
+
|
24 |
+
import datasets
|
25 |
+
|
26 |
+
|
27 |
+
# BibTeX citation
|
28 |
+
_CITATION = """\
|
29 |
+
@article{ju2020CovidDialog,
|
30 |
+
title={CovidDialog: Medical Dialogue Datasets about COVID-19},
|
31 |
+
author={Ju, Zeqian and Chakravorty, Subrato and He, Xuehai and Chen, Shu and Yang, Xingyi and Xie, Pengtao},
|
32 |
+
journal={ https://github.com/UCSD-AI4H/COVID-Dialogue},
|
33 |
+
year={2020}
|
34 |
+
}
|
35 |
+
"""
|
36 |
+
|
37 |
+
# Official description of the dataset
|
38 |
+
_DESCRIPTION = textwrap.dedent(
|
39 |
+
"""
|
40 |
+
COVID-Dialogue-Dataset is amedical dialogue dataset about COVID-19 and other types of pneumonia.
|
41 |
+
Patients who are concerned that they may be infected by COVID-19 or other pneumonia consult doctors and doctors provide advice.
|
42 |
+
There are 603 consultations in English and 1393 consultations in Chinese.
|
43 |
+
"""
|
44 |
+
)
|
45 |
+
|
46 |
+
# Link to an official homepage for the dataset here
|
47 |
+
_HOMEPAGE = "https://github.com/UCSD-AI4H/COVID-Dialogue"
|
48 |
+
|
49 |
+
_LICENSE = ""
|
50 |
+
_CHINESE_QA = "COVID-Dialogue-Dataset-Chinese.txt"
|
51 |
+
_ENGLISH_QA = "COVID-Dialogue-Dataset-English.txt"
|
52 |
+
|
53 |
+
|
54 |
+
class CovidQaUcsd(datasets.GeneratorBasedBuilder):
|
55 |
+
"""Dataset has one file having consulatations purely based on COVID queries"""
|
56 |
+
|
57 |
+
VERSION = datasets.Version("1.0.0")
|
58 |
+
|
59 |
+
BUILDER_CONFIGS = [
|
60 |
+
datasets.BuilderConfig(
|
61 |
+
name="en", version=VERSION, description="The dataset of medical dialogs related to Covid in English."
|
62 |
+
),
|
63 |
+
datasets.BuilderConfig(
|
64 |
+
name="zh", version=VERSION, description="The dataset of medical dialogs related to Covid in Chinese."
|
65 |
+
),
|
66 |
+
]
|
67 |
+
|
68 |
+
@property
|
69 |
+
def manual_download_instructions(self):
|
70 |
+
return """\
|
71 |
+
\nBoth the English and Chinese text files are present in https://github.com/UCSD-AI4H/COVID-Dialogue.
|
72 |
+
It is present as COVID-Dialogue-Dataset-English.txt (for the english dialogues) and COVID-Dialogue-Dataset-Chinese.txt
|
73 |
+
(for the Chinese Dialog).
|
74 |
+
|
75 |
+
To load the dataset, simple pass the folder where the file is saved to the 'data_dir' param in the datasets.load_dataset(...) option.
|
76 |
+
The data directory can e.g. be "/Downloads/".
|
77 |
+
The data can then be loaded using the below command:\n
|
78 |
+
`datasets.load_dataset("covid_qa_ucsd", name="en", data_dir="/Downloads/")`.
|
79 |
+
|
80 |
+
Just change the 'name' parameter to 'zh' for Chinese.
|
81 |
+
TAKE CARE NOT TO CHANGE THE NAME OF THE INPUT FILE
|
82 |
+
"""
|
83 |
+
|
84 |
+
def _info(self):
|
85 |
+
# This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
86 |
+
if self.config.name == "zh": # For english dialouge data
|
87 |
+
features = datasets.Features(
|
88 |
+
{
|
89 |
+
"dialogue_id": datasets.Value("int32"),
|
90 |
+
"dialogue_url": datasets.Value("string"),
|
91 |
+
"dialogue_turns": datasets.Sequence(
|
92 |
+
{
|
93 |
+
"speaker": datasets.ClassLabel(names=["病人", "医生"]),
|
94 |
+
"utterance": datasets.Value("string"),
|
95 |
+
}
|
96 |
+
),
|
97 |
+
}
|
98 |
+
)
|
99 |
+
|
100 |
+
if self.config.name == "en": # For english dialouge data
|
101 |
+
features = datasets.Features(
|
102 |
+
{
|
103 |
+
"dialogue_id": datasets.Value("int32"),
|
104 |
+
"dialogue_url": datasets.Value("string"),
|
105 |
+
"dialogue_turns": datasets.Sequence(
|
106 |
+
{
|
107 |
+
"speaker": datasets.ClassLabel(names=["Patient", "Doctor"]),
|
108 |
+
"utterance": datasets.Value("string"),
|
109 |
+
}
|
110 |
+
),
|
111 |
+
}
|
112 |
+
)
|
113 |
+
|
114 |
+
return datasets.DatasetInfo(
|
115 |
+
description=_DESCRIPTION,
|
116 |
+
features=features,
|
117 |
+
supervised_keys=None,
|
118 |
+
homepage=_HOMEPAGE,
|
119 |
+
license=_LICENSE,
|
120 |
+
citation=_CITATION,
|
121 |
+
)
|
122 |
+
|
123 |
+
def _split_generators(self, dl_manager):
|
124 |
+
"""Returns SplitGenerators."""
|
125 |
+
if self.config.name == "zh":
|
126 |
+
path_to_manual_file = os.path.join(os.path.abspath(os.path.expanduser(dl_manager.manual_dir)), _CHINESE_QA)
|
127 |
+
if self.config.name == "en":
|
128 |
+
path_to_manual_file = os.path.join(os.path.abspath(os.path.expanduser(dl_manager.manual_dir)), _ENGLISH_QA)
|
129 |
+
|
130 |
+
if not os.path.exists(path_to_manual_file):
|
131 |
+
raise FileNotFoundError(
|
132 |
+
"{} does not exist. Make sure the file is present in the directory specified in the data_dir specified in the input {} `datasets.load_dataset('covid_qa_ucsd', 'en', data_dir=...)`. Manual download instructions: {})".format(
|
133 |
+
path_to_manual_file, dl_manager.manual_dir, self.manual_download_instructions
|
134 |
+
)
|
135 |
+
)
|
136 |
+
|
137 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": path_to_manual_file})]
|
138 |
+
|
139 |
+
def _generate_examples(self, filepath):
|
140 |
+
"""Yields examples. Iterates over the file and creates appropriate dialogue data
|
141 |
+
|
142 |
+
NOTE:
|
143 |
+
- The code makes some assumption on the structure of the raw .txt file.
|
144 |
+
- There are some checks to separate different id's. Hopefully, should not cause further issues later when more txt files are added.
|
145 |
+
"""
|
146 |
+
data_lang = self.config.name
|
147 |
+
id_ = -1
|
148 |
+
with open(filepath, encoding="utf-8") as f_in:
|
149 |
+
# Parameters to just "sectionize" the raw data
|
150 |
+
last_part = ""
|
151 |
+
last_dialog = {}
|
152 |
+
last_list = []
|
153 |
+
last_user = ""
|
154 |
+
check_list = []
|
155 |
+
|
156 |
+
# These flags are present to have a single function address both chinese and english data
|
157 |
+
# English data is a little hahazard (i.e. the sentences spans multiple different lines),
|
158 |
+
# Chinese is compact with one line for doctor and patient.
|
159 |
+
conv_flag = False
|
160 |
+
des_flag = False
|
161 |
+
|
162 |
+
while True:
|
163 |
+
line = f_in.readline()
|
164 |
+
if not line:
|
165 |
+
break
|
166 |
+
|
167 |
+
# Extracting the dialog id
|
168 |
+
if line[:2] == "id": # Hardcode alert!
|
169 |
+
# Handling ID references that may come in the description
|
170 |
+
# These were observed in the Chinese dataset and were not
|
171 |
+
# followed by numbers
|
172 |
+
try:
|
173 |
+
dialogue_id = int(re.findall(r"\d+", line)[0])
|
174 |
+
except IndexError:
|
175 |
+
continue
|
176 |
+
|
177 |
+
# Extracting the url
|
178 |
+
if line[:4] == "http": # Hardcode alert!
|
179 |
+
dialogue_url = line.rstrip()
|
180 |
+
|
181 |
+
# Extracting the patient info from description.
|
182 |
+
if line[:11] == "Description": # Hardcode alert!
|
183 |
+
last_part = "description"
|
184 |
+
last_dialog = {}
|
185 |
+
last_list = []
|
186 |
+
last_user = ""
|
187 |
+
last_conv = {"speaker": "", "utterance": ""}
|
188 |
+
while True:
|
189 |
+
line = f_in.readline()
|
190 |
+
if (not line) or (line in ["\n", "\n\r"]):
|
191 |
+
break
|
192 |
+
else:
|
193 |
+
if data_lang == "zh": # Condition in chinese
|
194 |
+
if line[:5] == "病情描述:": # Hardcode alert!
|
195 |
+
last_user = "病人"
|
196 |
+
sen = line[6:].rstrip()
|
197 |
+
des_flag = True
|
198 |
+
|
199 |
+
if data_lang == "en":
|
200 |
+
last_user = "Patient"
|
201 |
+
sen = line.rstrip()
|
202 |
+
des_flag = True
|
203 |
+
|
204 |
+
if des_flag:
|
205 |
+
if sen == "":
|
206 |
+
continue
|
207 |
+
if sen in check_list:
|
208 |
+
last_conv["speaker"] = ""
|
209 |
+
last_conv["utterance"] = ""
|
210 |
+
else:
|
211 |
+
last_conv["speaker"] = last_user
|
212 |
+
last_conv["utterance"] = sen
|
213 |
+
check_list.append(sen)
|
214 |
+
des_flag = False
|
215 |
+
break
|
216 |
+
|
217 |
+
# Extracting the conversation info from dialogue.
|
218 |
+
elif line[:8] == "Dialogue": # Hardcode alert!
|
219 |
+
if last_part == "description" and len(last_conv["utterance"]) > 0:
|
220 |
+
last_part = "dialogue"
|
221 |
+
if data_lang == "zh":
|
222 |
+
last_user = "病人"
|
223 |
+
|
224 |
+
if data_lang == "en":
|
225 |
+
last_user = "Patient"
|
226 |
+
|
227 |
+
while True:
|
228 |
+
line = f_in.readline()
|
229 |
+
if (not line) or (line in ["\n", "\n\r"]):
|
230 |
+
conv_flag = False
|
231 |
+
last_user = ""
|
232 |
+
last_list.append(copy.deepcopy(last_conv))
|
233 |
+
# To ensure close of conversation, only even number of sentences
|
234 |
+
# are extracted
|
235 |
+
last_turn = len(last_list)
|
236 |
+
if int(last_turn / 2) > 0:
|
237 |
+
temp = int(last_turn / 2)
|
238 |
+
id_ += 1
|
239 |
+
last_dialog["dialogue_id"] = dialogue_id
|
240 |
+
last_dialog["dialogue_url"] = dialogue_url
|
241 |
+
last_dialog["dialogue_turns"] = last_list[: temp * 2]
|
242 |
+
yield id_, last_dialog
|
243 |
+
break
|
244 |
+
|
245 |
+
if data_lang == "zh":
|
246 |
+
if line[:3] == "病人:" or line[:3] == "医生:": # Hardcode alert!
|
247 |
+
user = line[:2] # Hardcode alert!
|
248 |
+
line = f_in.readline()
|
249 |
+
conv_flag = True
|
250 |
+
|
251 |
+
# The elif block is to ensure that multi-line sentences are captured.
|
252 |
+
# This has been observed only in english.
|
253 |
+
if data_lang == "en":
|
254 |
+
if line.strip() == "Patient:" or line.strip() == "Doctor:": # Hardcode alert!
|
255 |
+
user = line.replace(":", "").rstrip()
|
256 |
+
line = f_in.readline()
|
257 |
+
conv_flag = True
|
258 |
+
elif line[:2] != "id": # Hardcode alert!
|
259 |
+
conv_flag = True
|
260 |
+
|
261 |
+
# Continues till the next ID is parsed
|
262 |
+
if conv_flag:
|
263 |
+
sen = line.rstrip()
|
264 |
+
if sen == "":
|
265 |
+
continue
|
266 |
+
|
267 |
+
if user == last_user:
|
268 |
+
last_conv["utterance"] = last_conv["utterance"] + sen
|
269 |
+
else:
|
270 |
+
last_user = user
|
271 |
+
last_list.append(copy.deepcopy(last_conv))
|
272 |
+
last_conv["utterance"] = sen
|
273 |
+
last_conv["speaker"] = user
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"en": {"description": "\nCOVID-Dialogue-Dataset is amedical dialogue dataset about COVID-19 and other types of pneumonia.\nPatients who are concerned that they may be infected by COVID-19 or other pneumonia consult doctors and doctors provide advice.\nThere are 603 consultations in English and 1393 consultations in Chinese.\n", "citation": "@article{ju2020CovidDialog,\n title={CovidDialog: Medical Dialogue Datasets about COVID-19},\n author={Ju, Zeqian and Chakravorty, Subrato and He, Xuehai and Chen, Shu and Yang, Xingyi and Xie, Pengtao},\n journal={ https://github.com/UCSD-AI4H/COVID-Dialogue},\n year={2020}\n}\n", "homepage": "https://github.com/UCSD-AI4H/COVID-Dialogue", "license": "", "features": {"dialogue_id": {"dtype": "int32", "id": null, "_type": "Value"}, "dialogue_url": {"dtype": "string", "id": null, "_type": "Value"}, "dialogue_turns": {"feature": {"speaker": {"num_classes": 2, "names": ["Patient", "Doctor"], "names_file": null, "id": null, "_type": "ClassLabel"}, "utterance": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "covid_qa_ucsd", "config_name": "en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 484944, "num_examples": 572, "dataset_name": "covid_qa_ucsd"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 484944, "size_in_bytes": 484944}, "zh": {"description": "\nCOVID-Dialogue-Dataset is amedical dialogue dataset about COVID-19 and other types of pneumonia.\nPatients who are concerned that they may be infected by COVID-19 or other pneumonia consult doctors and doctors provide advice.\nThere are 603 consultations in English and 1393 consultations in Chinese.\n", "citation": "@article{ju2020CovidDialog,\n title={CovidDialog: Medical Dialogue Datasets about COVID-19},\n author={Ju, Zeqian and Chakravorty, Subrato and He, Xuehai and Chen, Shu and Yang, Xingyi and Xie, Pengtao},\n journal={ https://github.com/UCSD-AI4H/COVID-Dialogue},\n year={2020}\n}\n", "homepage": "https://github.com/UCSD-AI4H/COVID-Dialogue", "license": "", "features": {"dialogue_id": {"dtype": "int32", "id": null, "_type": "Value"}, "dialogue_url": {"dtype": "string", "id": null, "_type": "Value"}, "dialogue_turns": {"feature": {"speaker": {"num_classes": 2, "names": ["\u75c5\u4eba", "\u533b\u751f"], "names_file": null, "id": null, "_type": "ClassLabel"}, "utterance": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "covid_qa_ucsd", "config_name": "zh", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1352377, "num_examples": 1088, "dataset_name": "covid_qa_ucsd"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 1352377, "size_in_bytes": 1352377}}
|
dummy/en/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f3a399fe20ab31c7480f65fc49bdc1e7acda064fb742681228100398a0015d1
|
3 |
+
size 2923
|
dummy/zh/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff441187bd520d8e9b664f3e878ce82c426a2c83874e921f68e1abf05fcf9dd5
|
3 |
+
size 3263
|