Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -50,4 +50,60 @@ task_categories:
|
|
50 |
- text-classification
|
51 |
language:
|
52 |
- en
|
53 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
- text-classification
|
51 |
language:
|
52 |
- en
|
53 |
+
---
|
54 |
+
|
55 |
+
# dstc3
|
56 |
+
|
57 |
+
This is a text classification dataset. It is intended for machine learning research and experimentation.
|
58 |
+
|
59 |
+
This dataset is obtained via formatting another publicly available data to be compatible with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html).
|
60 |
+
|
61 |
+
## Usage
|
62 |
+
|
63 |
+
It is intended to be used with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
|
64 |
+
|
65 |
+
```python
|
66 |
+
from autointent import Dataset
|
67 |
+
|
68 |
+
dream = Dataset.from_datasets("AutoIntent/dstc3")
|
69 |
+
```
|
70 |
+
|
71 |
+
## Source
|
72 |
+
|
73 |
+
This dataset is taken from `marcel-gohsen/dstc3` and formatted with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
|
74 |
+
|
75 |
+
```python
|
76 |
+
from datasets import load_dataset
|
77 |
+
from autointent import Dataset
|
78 |
+
|
79 |
+
# load original data
|
80 |
+
dstc3 = load_dataset("marcel-gohsen/dstc3")
|
81 |
+
|
82 |
+
# extract intent names
|
83 |
+
dstc3["test"] = dstc3["test"].filter(lambda example: example["transcript"] != "")
|
84 |
+
intent_names = sorted(set(name for intents in dstc3["test"]["intent"] for name in intents))
|
85 |
+
intent_names.remove("reqmore")
|
86 |
+
dstc3["test"].filter(lambda example: "reqmore" in example["intent"])
|
87 |
+
name_to_id = {name: i for i, name in enumerate(intent_names)}
|
88 |
+
|
89 |
+
# parse complicated dstc format
|
90 |
+
def transform(example: dict):
|
91 |
+
return {
|
92 |
+
"utterance": example["transcript"],
|
93 |
+
"label": [name_to_id[intent_name] for intent_name in example["intent"] if intent_name != "reqmore"],
|
94 |
+
}
|
95 |
+
dstc_converted = dstc3["test"].map(transform, remove_columns=dstc3["test"].features.keys())
|
96 |
+
|
97 |
+
# format to autointent.Dataset
|
98 |
+
intents = [{"id": i, "name": name} for i, name in enumerate(intent_names)]
|
99 |
+
utterances = []
|
100 |
+
oos_utterances = []
|
101 |
+
for rec in dstc_converted.to_list():
|
102 |
+
if len(rec["label"]) == 0:
|
103 |
+
rec.pop("label")
|
104 |
+
oos_utterances.append(rec["utterance"])
|
105 |
+
else:
|
106 |
+
utterances.append(rec)
|
107 |
+
oos_records = [{"utterance": ut} for ut in set(oos_utterances)]
|
108 |
+
dstc_converted = Dataset.from_dict({"intents": intents, "train": utterances + oos_records})
|
109 |
+
```
|