Convert to parquet (loading scripts are no longer supported)

#4
by davanstrien HF Staff - opened
README.md CHANGED
@@ -26,6 +26,43 @@ task_categories:
26
  task_ids:
27
  - sentiment-scoring
28
  - multi-label-classification
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ---
30
 
31
  # Contentious Contexts Corpus (ConConCor)
@@ -99,7 +136,19 @@ def majority_vote(example):
99
 
100
  ## Loading
101
 
102
- This repo still ships a legacy loading script, so `load_dataset("biglam/contentious_contexts")` raises `RuntimeError: Dataset scripts are no longer supported` on `datasets` v4 and later. Until it is converted, read the CSVs directly from the source repo — `Extracts.csv` and `Annotations.csv` join on `extract_id`, and `Metadata.csv` adds newspaper title, date and place for 2,719 of the 2,720 extracts.
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  ## Licence
105
 
 
26
  task_ids:
27
  - sentiment-scoring
28
  - multi-label-classification
29
+ dataset_info:
30
+ features:
31
+ - name: extract_id
32
+ dtype: string
33
+ - name: text
34
+ dtype: string
35
+ - name: target
36
+ dtype: string
37
+ - name: annotator_responses_english
38
+ list:
39
+ - name: id
40
+ dtype: string
41
+ - name: response
42
+ dtype: string
43
+ - name: annotator_responses_dutch
44
+ list:
45
+ - name: id
46
+ dtype: string
47
+ - name: response
48
+ dtype: string
49
+ - name: annotator_suggestions
50
+ list:
51
+ - name: id
52
+ dtype: string
53
+ - name: suggestion
54
+ dtype: string
55
+ splits:
56
+ - name: train
57
+ num_bytes: 2199414
58
+ num_examples: 2720
59
+ download_size: 1940545
60
+ dataset_size: 2199414
61
+ configs:
62
+ - config_name: default
63
+ data_files:
64
+ - split: train
65
+ path: data/train-*
66
  ---
67
 
68
  # Contentious Contexts Corpus (ConConCor)
 
136
 
137
  ## Loading
138
 
139
+ ```python
140
+ from datasets import load_dataset
141
+
142
+ ds = load_dataset("biglam/contentious_contexts", split="train")
143
+ row = ds[0]
144
+ row["text"] # the newspaper extract
145
+ row["target"] # the flagged compound, bolded in `text`
146
+ row["annotator_responses_dutch"] # [{'id': ..., 'response': 'Niet omstreden'}, ...]
147
+ row["annotator_responses_english"] # the same responses, translated
148
+ ```
149
+
150
+ `Metadata.csv` in the [source repo](https://github.com/cultural-ai/ConConCor) adds newspaper
151
+ title, date and place for 2,719 of the 2,720 extracts; it is not carried here.
152
 
153
  ## Licence
154
 
contentious_contexts.py DELETED
@@ -1,133 +0,0 @@
1
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """This dataset contains extracts from historical Dutch newspapers which have been containing keywords of potentially contentious words (according to present-day sensibilities).
15
- The dataset contains multiple annotations per instance, given the option to quantify agreement scores for annotations."""
16
-
17
- import pandas as pd
18
- import datasets
19
-
20
-
21
- _CITATION = """@misc{ContentiousContextsCorpus2021,
22
- author = {Cultural AI},
23
- title = {Contentious Contexts Corpus},
24
- year = {2021},
25
- publisher = {GitHub},
26
- journal = {GitHub repository},
27
- howpublished = {\\url{https://github.com/cultural-ai/ConConCor}},
28
- }
29
- """
30
-
31
- _DESCRIPTION = """This dataset contains extracts from historical Dutch newspapers which have been containing keywords of potentially contentious words (according to present-day sensibilities).
32
- The dataset contains multiple annotations per instance, given the option to quantify agreement scores for annotations. This dataset can be used to track how words and their meanings have changed over time
33
- """
34
-
35
-
36
- _HOMEPAGE = "https://github.com/cultural-ai/ConConCor"
37
-
38
-
39
- _LICENSE = "CC-BY"
40
-
41
- _URLS = [
42
- "https://raw.githubusercontent.com/cultural-ai/ConConCor/main/Dataset/Annotations.csv",
43
- "https://raw.githubusercontent.com/cultural-ai/ConConCor/main/Dataset/Extracts.csv",
44
- ]
45
- response_mapping = {
46
- "Omstreden naar huidige maatstaven": "Contentious according to current standards",
47
- "Niet omstreden": "Not contentious",
48
- "Weet ik niet": "I don't know",
49
- "Onleesbare OCR": "Illegible OCR",
50
- }
51
-
52
- logger = datasets.utils.logging.get_logger(__name__)
53
-
54
-
55
- class ContentiousContexts(datasets.GeneratorBasedBuilder):
56
- """This dataset contains extracts from historical Dutch newspapers which have been containing keywords of potentially contentious words"""
57
-
58
- VERSION = datasets.Version("1.0.0")
59
-
60
- def _info(self):
61
- features = datasets.Features(
62
- {
63
- "extract_id": datasets.Value("string"),
64
- "text": datasets.Value("string"),
65
- "target": datasets.Value("string"),
66
- "annotator_responses_english": [
67
- {
68
- "id": datasets.Value("string"),
69
- "response": datasets.Value("string"),
70
- }
71
- ],
72
- "annotator_responses_dutch": [
73
- {
74
- "id": datasets.Value("string"),
75
- "response": datasets.Value("string"),
76
- }
77
- ],
78
- "annotator_suggestions": [
79
- {
80
- "id": datasets.Value("string"),
81
- "suggestion": datasets.Value("string"),
82
- }
83
- ],
84
- }
85
- )
86
- return datasets.DatasetInfo(
87
- description=_DESCRIPTION,
88
- features=features,
89
- homepage=_HOMEPAGE,
90
- license=_LICENSE,
91
- citation=_CITATION,
92
- )
93
-
94
- def _split_generators(self, dl_manager):
95
- ann_file = dl_manager.download(_URLS[0])
96
- text_file = dl_manager.download(_URLS[1])
97
- return [
98
- datasets.SplitGenerator(
99
- name=datasets.Split.TRAIN,
100
- gen_kwargs={"ann_file": ann_file, "text_file": text_file},
101
- ),
102
- ]
103
-
104
- def _generate_examples(self, ann_file, text_file):
105
- annotations = pd.read_csv(open(ann_file), dtype="object")
106
- texts = pd.read_csv(open(text_file), dtype="object")
107
- annotations.fillna("", inplace=True)
108
- texts.fillna("", inplace=True)
109
- for _, row in texts.iterrows():
110
- data_point = {
111
- "extract_id": row["extract_id"],
112
- "target": row["target_compound_bolded"],
113
- "text": row["text"],
114
- }
115
- annotator_responses = annotations[
116
- annotations["extract_id"] == row["extract_id"]
117
- ]
118
- resp_en_list = []
119
- resp_nl_list = []
120
- sugg_list = []
121
- for _, ann_row in annotator_responses.iterrows():
122
- ann_id = ann_row["anonymised_participant_id"]
123
- response_dutch = ann_row["response"]
124
- response_english = response_mapping[response_dutch]
125
- suggestion = ann_row["suggestion"]
126
- resp_en_list.append({"id": ann_id, "response": response_english})
127
- resp_nl_list.append({"id": ann_id, "response": response_dutch})
128
- sugg_list.append({"id": ann_id, "suggestion": suggestion})
129
-
130
- data_point["annotator_responses_english"] = resp_en_list
131
- data_point["annotator_responses_dutch"] = resp_nl_list
132
- data_point["annotator_suggestions"] = sugg_list
133
- yield data_point["extract_id"], data_point
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbfc97851b492f569c346cbc16cd825c9eb4b7242ed1eb55d8eb10c4788e5bb6
3
+ size 1940545