Commit ·
847f078
1
Parent(s): 4e2b34c
Convert to parquet (loading scripts are no longer supported) (#4)
Browse files- Convert to parquet (loading scripts are no longer supported) (1b590b5eff45387d3911d8c22f20a4c535c3a280)
- Remove loading script; card no longer says loading is broken (a4f25690a64bb443879b5f6bafae81791ce99342)
Files changed (3)
- README.md+50-1
- contentious_contexts.pyDeleted-133
- data/train-00000-of-00001.parquetAdded+3
25 unmodified lines26272829303167 unmodified lines9910010110210310410525 unmodified linestask_ids:- sentiment-scoring- multi-label-classification---# Contentious Contexts Corpus (ConConCor)67 unmodified lines## LoadingThis 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.## Licence25 unmodified lines2627282930313233343536373839404142434445464748495051525354555657585960616263646566676867 unmodified lines13613713813914014114214314414514614714814915015115215315425 unmodified linestask_ids:- sentiment-scoring- multi-label-classificationdataset_info:features:- name: extract_iddtype: string- name: textdtype: string- name: targetdtype: string- name: annotator_responses_englishlist:- name: iddtype: string- name: responsedtype: string- name: annotator_responses_dutchlist:- name: iddtype: string- name: responsedtype: string- name: annotator_suggestionslist:- name: iddtype: string- name: suggestiondtype: stringsplits:- name: trainnum_bytes: 2199414num_examples: 2720download_size: 1940545dataset_size: 2199414configs:- config_name: defaultdata_files:- split: trainpath: data/train-*---# Contentious Contexts Corpus (ConConCor)67 unmodified lines## Loading```pythonfrom datasets import load_datasetds = load_dataset("biglam/contentious_contexts", split="train")row = ds[0]row["text"] # the newspaper extractrow["target"] # the flagged compound, bolded in `text`row["annotator_responses_dutch"] # [{'id': ..., 'response': 'Niet omstreden'}, ...]row["annotator_responses_english"] # the same responses, translated````Metadata.csv` in the [source repo](https://github.com/cultural-ai/ConConCor) adds newspapertitle, date and place for 2,719 of the 2,720 extracts; it is not carried here.## Licence
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License."""This dataset contains extracts from historical Dutch newspapers which have been containing keywords of potentially contentious words (according to present-day sensibilities). The dataset contains multiple annotations per instance, given the option to quantify agreement scores for annotations."""
import pandas as pdimport datasets
_CITATION = """@misc{ContentiousContextsCorpus2021, author = {Cultural AI}, title = {Contentious Contexts Corpus}, year = {2021}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\\url{https://github.com/cultural-ai/ConConCor}},}"""
_DESCRIPTION = """This dataset contains extracts from historical Dutch newspapers which have been containing keywords of potentially contentious words (according to present-day sensibilities). 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"""
_HOMEPAGE = "https://github.com/cultural-ai/ConConCor"
_LICENSE = "CC-BY"
_URLS = [ "https://raw.githubusercontent.com/cultural-ai/ConConCor/main/Dataset/Annotations.csv", "https://raw.githubusercontent.com/cultural-ai/ConConCor/main/Dataset/Extracts.csv",]response_mapping = { "Omstreden naar huidige maatstaven": "Contentious according to current standards", "Niet omstreden": "Not contentious", "Weet ik niet": "I don't know", "Onleesbare OCR": "Illegible OCR",}
logger = datasets.utils.logging.get_logger(__name__)
class ContentiousContexts(datasets.GeneratorBasedBuilder): """This dataset contains extracts from historical Dutch newspapers which have been containing keywords of potentially contentious words"""
VERSION = datasets.Version("1.0.0")
def _info(self): features = datasets.Features( { "extract_id": datasets.Value("string"), "text": datasets.Value("string"), "target": datasets.Value("string"), "annotator_responses_english": [ { "id": datasets.Value("string"), "response": datasets.Value("string"), } ], "annotator_responses_dutch": [ { "id": datasets.Value("string"), "response": datasets.Value("string"), } ], "annotator_suggestions": [ { "id": datasets.Value("string"), "suggestion": datasets.Value("string"), } ], } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, )
def _split_generators(self, dl_manager): ann_file = dl_manager.download(_URLS[0]) text_file = dl_manager.download(_URLS[1]) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"ann_file": ann_file, "text_file": text_file}, ), ]
def _generate_examples(self, ann_file, text_file): annotations = pd.read_csv(open(ann_file), dtype="object") texts = pd.read_csv(open(text_file), dtype="object") annotations.fillna("", inplace=True) texts.fillna("", inplace=True) for _, row in texts.iterrows(): data_point = { "extract_id": row["extract_id"], "target": row["target_compound_bolded"], "text": row["text"], } annotator_responses = annotations[ annotations["extract_id"] == row["extract_id"] ] resp_en_list = [] resp_nl_list = [] sugg_list = [] for _, ann_row in annotator_responses.iterrows(): ann_id = ann_row["anonymised_participant_id"] response_dutch = ann_row["response"] response_english = response_mapping[response_dutch] suggestion = ann_row["suggestion"] resp_en_list.append({"id": ann_id, "response": response_english}) resp_nl_list.append({"id": ann_id, "response": response_dutch}) sugg_list.append({"id": ann_id, "suggestion": suggestion})
data_point["annotator_responses_english"] = resp_en_list data_point["annotator_responses_dutch"] = resp_nl_list data_point["annotator_suggestions"] = sugg_list yield data_point["extract_id"], data_point123version https://git-lfs.github.com/spec/v1oid sha256:cbfc97851b492f569c346cbc16cd825c9eb4b7242ed1eb55d8eb10c4788e5bb6size 1940545README.md+50-1
contentious_contexts.pyDeleted-133
data/train-00000-of-00001.parquetAdded+3