davanstrien HF Staff commited on
Commit
a4f2569
·
verified ·
1 Parent(s): 1b590b5

Remove loading script; card no longer says loading is broken

Browse files
Files changed (2) hide show
  1. README.md +13 -1
  2. contentious_contexts.py +0 -133
README.md CHANGED
@@ -136,7 +136,19 @@ def majority_vote(example):
136
 
137
  ## Loading
138
 
139
- 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.
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  ## Licence
142
 
 
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