File size: 1,945 Bytes
8371e5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## Overview

Original dataset available [here](https://github.com/sheng-z/JOCI/tree/master/data). 
This dataset is the "full" JOCI dataset, which is the file named `joci.csv.zip`.


# Dataset curation
The following processing is applied,

- `label` column renamed to `original_label`
- creation of the `label` column using the following mapping, using common practices ([1](https://github.com/rabeehk/robust-nli/blob/c32ff958d4df68ac2fad9bf990f70d30eab9f297/data/scripts/joci.py#L22-L27), [2](https://github.com/azpoliak/hypothesis-only-NLI/blob/b045230437b5ba74b9928ca2bac5e21ae57876b9/data/convert_joci.py#L7-L12))

```
{
    0: "contradiction", 
    1: "contradiction",  
    2: "neutral",
    3: "neutral",
    4: "neutral",
    5: "entailment",
}
```

- finally, converting this to the usual NLI classes, that is `{"entailment": 0, "neutral": 1, "contradiction": 2}`


## Code to create dataset
```python
import pandas as pd
from datasets import Features, Value, ClassLabel, Dataset


# read data
df = pd.read_csv("<path to folder>/joci.csv")

# column name to lower
df.columns = df.columns.str.lower()

# rename label column
df = df.rename(columns={"label": "original_label"})

# encode labels
df["label"] = df["original_label"].map({
    0: "contradiction", 
    1: "contradiction",  
    2: "neutral",
    3: "neutral",
    4: "neutral",
    5: "entailment",
})

# encode labels
df["label"] = df["label"].map({"entailment": 0, "neutral": 1, "contradiction": 2})

# cast to dataset
features = Features({
    "context": Value(dtype="string"),
    "hypothesis": Value(dtype="string"),
    "label": ClassLabel(num_classes=3, names=["entailment", "neutral", "contradiction"]),
    "original_label": Value(dtype="int32"),
    "context_from": Value(dtype="string"),
    "hypothesis_from": Value(dtype="string"),
    "subset": Value(dtype="string"),
})
ds = Dataset.from_pandas(df, features=features)
ds.push_to_hub("joci", token="<token>")
```