Datasets:

Languages:
English
ArXiv:
License:
ngarneau commited on
Commit
464765c
·
1 Parent(s): 42b7615

Add category to all samples

Browse files
Files changed (1) hide show
  1. legal_lama.py +12 -0
legal_lama.py CHANGED
@@ -122,6 +122,17 @@ class LegalLAMA(datasets.GeneratorBasedBuilder):
122
  ),
123
  ]
124
 
 
 
 
 
 
 
 
 
 
 
 
125
  def _generate_examples(self, filepath, split):
126
  """This function returns the examples in the raw (text) form."""
127
  with open(filepath, encoding="utf-8") as f:
@@ -130,5 +141,6 @@ class LegalLAMA(datasets.GeneratorBasedBuilder):
130
  example = {
131
  "text": data["masked_sentences"][0],
132
  "label": data["obj_label"],
 
133
  }
134
  yield id_, example
 
122
  ),
123
  ]
124
 
125
+ def _get_category(self, sample):
126
+ if 'canadian_article' in sample:
127
+ category = sample['canadian_article']
128
+ elif 'legal_topic' in sample:
129
+ category = sample['legal_topic']
130
+ elif 'echr_article' in sample:
131
+ category = sample['echr_article']
132
+ else:
133
+ category = sample['obj_label']
134
+ return category
135
+
136
  def _generate_examples(self, filepath, split):
137
  """This function returns the examples in the raw (text) form."""
138
  with open(filepath, encoding="utf-8") as f:
 
141
  example = {
142
  "text": data["masked_sentences"][0],
143
  "label": data["obj_label"],
144
+ "category": self._get_category(data)
145
  }
146
  yield id_, example