Nina Baumgartner commited on
Commit
692e445
1 Parent(s): 7a39ce7

Added loading script, data directory and dataset. Changed README.md

Browse files
README.md CHANGED
@@ -75,24 +75,11 @@ When the dataset is used in a multilingual setting selecting the the 'all' flag:
75
 
76
  ```python
77
  from datasets import load_dataset
78
- dataset = load_dataset('rcds/lower_court_insertion_swiss_judgment_prediction', 'all')```
79
-
80
- For lower_court-insertion:
81
- ```json
82
- {
83
- "id": 59810,
84
- "year": 2017,
85
- "label": "approval",
86
- "language": "de",
87
- "region": "Central_Switzerland",
88
- "canton": "LU",
89
- "legal_area": "social_law",
90
- "explainability_label": "Lower court",
91
- "text": "Sachverhalt: A. Die IV-Stelle Luzern sprach dem 1977 geborenen A._ im Anschluss an dessen Besuch einer Sonderschule berufliche Massnahmen und entsprechende Taggelder zu. Im Oktober 1997 (Postaufgabe) meldete sich der Versicherte erneut zum Bezug von Leistungen der Invalidenversicherung an. Im Feststellungsblatt vom 12. Oktober 1998 zum Rentenbeschluss vermerkte die IV-Stelle als Ausgangsbasis \"Jugendinvalidit\u00e4t\"; sodann errechnete sie einen Invalidit\u00e4tsgrad von 85,39 %. Mit Verf\u00fcgung vom 4. Dezember 1998 sprach sie A._ eine ganze Invalidenrente ab 1. Juli 1997 zu. Mit Verf\u00fcgung vom 7. Februar 2003, Mitteilung vom 15. Juni 2007 und Verf\u00fcgung vom 13. Mai 2008 wurde der bisherige Rentenanspruch jeweils (ohne n\u00e4here \u00dcberpr\u00fcfung der entsprechenden Voraussetzungen) best\u00e4tigt. Im Februar 2014 leitete die Verwaltung erneut ein Revisionsverfahren ein. Dabei veranlasste sie insbesondere das Gutachten des Dr. med. B._, Facharzt f\u00fcr Psychiatrie und Psychotherapie beim Regionalen \u00c4rztlichen Dienst (RAD), vom 13. November 2014 (\"neuropsychiatrisch-neuropsychologische Komplexfallabkl\u00e4rung\"). Am 10. Februar 2015 bot die IV-Stelle Luzern A._ Unterst\u00fctzung bei der Stellensuche an. Ab M\u00e4rz 2015 kam sie f\u00fcr zwei Arbeitsversuche w\u00e4hrend jeweils sechs Monaten auf. Zu einer anschliessenden Festanstellung kam es nicht. Nach Durchf\u00fchrung des Vorbescheidverfahrens hob die IV-Stelle mit Verf\u00fcgung vom 2. Juni 2016 die Invalidenrente wiedererw\u00e4gungsweise auf Ende Juli 2016 auf. B. Die dagegen erhobene Beschwerde hiess das Appellationsgericht Basel-Stadt mit Entscheid vom 3. Februar 2017 gut. Es hob die Verf\u00fcgung vom 2. Juni 2016 auf und bejahte einen weiterhin bestehenden Anspruch auf eine ganze Rente. C. Die IV-Stelle beantragt mit Beschwerde in \u00f6ffentlich-rechtlichen Angelegenheiten, der Entscheid vom 3. Februar 2017 sei aufzuheben, und ihre Verf\u00fcgung vom 2. Juni 2016 sei zu best\u00e4tigen. A._ schliesst auf Abweisung der Beschwerde. Das Bundesamt f\u00fcr Sozialversicherungen verzichtet auf eine Vernehmlassung. ",
92
- "lower_court": "Appellationsgericht Basel-Stadt"
93
- }
94
  ```
95
 
 
 
96
  #### Monolingual use of the dataset
97
 
98
  When the dataset is used in a monolingual setting selecting the ISO language code for one of the 3 supported languages. For example:
 
75
 
76
  ```python
77
  from datasets import load_dataset
78
+ dataset = load_dataset('rcds/lower_court_insertion_swiss_judgment_prediction', 'all')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  ```
80
 
81
+
82
+
83
  #### Monolingual use of the dataset
84
 
85
  When the dataset is used in a monolingual setting selecting the ISO language code for one of the 3 supported languages. For example:
data/lci_test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
lower_court_insertion_swiss_judgment_prediction.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Dataset for the Lower Court Insertion task."""
15
+
16
+ import json
17
+
18
+ import datasets
19
+
20
+ logger = datasets.logging.get_logger(__name__)
21
+
22
+ try:
23
+ import lzma as xz
24
+ except ImportError:
25
+ import pylzma as xz
26
+
27
+ # TODO: Add final BibTeX citation
28
+ # Find for instance the citation on arxiv or on the dataset repo/website
29
+ _CITATION = """\
30
+ @misc{baumgartner_nina_occlusion_2022,
31
+ title = {From Occlusion to Transparancy – An Occlusion-Based Explainability Approach for Legal Judgment Prediction in Switzerland},
32
+ shorttitle = {From Occlusion to Transparancy},
33
+ abstract = {Natural Language Processing ({NLP}) models have been used for more and more complex tasks such as Legal Judgment Prediction ({LJP}). A {LJP} model predicts the outcome of a legal case by utilizing its facts. This increasing deployment of Artificial Intelligence ({AI}) in high-stakes domains such as law and the involvement of sensitive data has increased the need for understanding such systems. We propose a multilingual occlusion-based explainability approach for {LJP} in Switzerland and conduct a study on the bias using Lower Court Insertion ({LCI}). We evaluate our results using different explainability metrics introduced in this thesis and by comparing them to high-quality Legal Expert Annotations using Inter Annotator Agreement. Our findings show that the model has a varying understanding of the semantic meaning and context of the facts section, and struggles to distinguish between legally relevant and irrelevant sentences. We also found that the insertion of a different lower court can have an effect on the prediction, but observed no distinct effects based on legal areas, cantons, or regions. However, we did identify a language disparity with Italian performing worse than the other languages due to representation inequality in the training data, which could lead to potential biases in the prediction in multilingual regions of Switzerland. Our results highlight the challenges and limitations of using {NLP} in the judicial field and the importance of addressing concerns about fairness, transparency, and potential bias in the development and use of {NLP} systems. The use of explainable artificial intelligence ({XAI}) techniques, such as occlusion and {LCI}, can help provide insight into the decision-making processes of {NLP} systems and identify areas for improvement. Finally, we identify areas for future research and development in this field in order to address the remaining limitations and challenges.},
34
+ author = {{Baumgartner, Nina}},
35
+ year = {2022},
36
+ langid = {english}
37
+ }
38
+ """
39
+
40
+ # You can copy an official description
41
+ _DESCRIPTION = """\
42
+ This dataset contains an implementation of lower court insertion for the SwissJudgmentPrediction task.
43
+ """
44
+ _LICENSE = "cc-by-sa-4.0"
45
+
46
+ _LANGUAGES = [
47
+ "de",
48
+ "fr",
49
+ "it",
50
+ ]
51
+
52
+ _URL = "https://huggingface.co/datasets/rcds/lower_court_insertion_swiss_judgment_prediction/resolve/main/data/"
53
+
54
+ _URLS = {
55
+ "test": _URL + "lci_test.jsonl"
56
+ }
57
+
58
+
59
+ class LowerCourtInsertionSwissJudgmentPredictionConfig(datasets.BuilderConfig):
60
+ """BuilderConfig for LowerCourtInsertionSwissJudgmentPrediction."""
61
+
62
+ def __init__(self, language: str, **kwargs):
63
+ """BuilderConfig for LowerCourtInsertionSwissJudgmentPrediction.
64
+ Args:
65
+ language: One of de, fr, it, or all
66
+ **kwargs: keyword arguments forwarded to super.
67
+ """
68
+ super(LowerCourtInsertionSwissJudgmentPredictionConfig, self).__init__(**kwargs)
69
+ self.language = language
70
+
71
+
72
+ class LowerCourtInsertionSwissJudgmentPrediction(datasets.GeneratorBasedBuilder):
73
+ """This dataset contains court decision for the lower court insertion task in swiss judgment prediction"""
74
+
75
+ VERSION = datasets.Version("1.1.0")
76
+ BUILDER_CONFIG_CLASS = LowerCourtInsertionSwissJudgmentPredictionConfig
77
+ BUILDER_CONFIGS = [
78
+ LowerCourtInsertionSwissJudgmentPredictionConfig(
79
+ name=lang,
80
+ language=lang,
81
+ version=datasets.Version("1.1.0", ""),
82
+ description=f"Plain text import of OcclusionSwissJudgmentPrediction for the {lang} language",
83
+ )
84
+ for lang in _LANGUAGES
85
+ ] + [
86
+ LowerCourtInsertionSwissJudgmentPredictionConfig(
87
+ name="all",
88
+ language="all",
89
+ version=datasets.Version("1.1.0", ""),
90
+ description="Plain text import of OcclusionSwissJudgmentPrediction for all languages",
91
+ )
92
+ ]
93
+
94
+ def _info(self):
95
+ features = datasets.Features(
96
+ {
97
+ "id": datasets.Value("int32"),
98
+ "year": datasets.Value("int32"),
99
+ "label": datasets.Value("string"),
100
+ "language": datasets.Value("string"),
101
+ "region": datasets.Value("string"),
102
+ "canton": datasets.Value("string"),
103
+ "legal_area": datasets.Value("string"),
104
+ "explainability_label": datasets.Value("string"),
105
+ "occluded_text": datasets.Value("string"),
106
+ "text": datasets.Value("string")
107
+
108
+ }
109
+ )
110
+ return datasets.DatasetInfo(
111
+ description=_DESCRIPTION,
112
+ features=features,
113
+ supervised_keys=None,
114
+ homepage="https://github.com/ninabaumgartner/SwissCourtRulingCorpus",
115
+ license=_LICENSE,
116
+ citation=_CITATION,
117
+ )
118
+
119
+ def _split_generators(self, dl_manager):
120
+ # dl_manager is a datasets.download.DownloadManager that can be used to
121
+ # download and extract URLs
122
+ try:
123
+ dl_dir = dl_manager.download(_URLS)
124
+ except Exception:
125
+ logger.warning(
126
+ "If this download failed try a few times before reporting an issue"
127
+ )
128
+ raise
129
+ return [
130
+ datasets.SplitGenerator(
131
+ name="test",
132
+ # These kwargs will be passed to _generate_examples
133
+ gen_kwargs={"filepath": dl_dir["test"]},
134
+ ),
135
+ ]
136
+
137
+ def _generate_examples(self, filepath):
138
+ """This function returns the examples in the raw (text) form."""
139
+ if self.config.language in ["all"] + _LANGUAGES:
140
+ with open(filepath, encoding="utf-8") as f:
141
+ for id_, row in enumerate(f):
142
+ data = json.loads(row)
143
+ _ = data.setdefault("language", "n/a")
144
+ if self.config.language in ["all"] or data["language"] == self.config.language:
145
+ yield id_, data