Datasets:

srzhang commited on
Commit
9899651
·
1 Parent(s): b0f358e
Files changed (1) hide show
  1. LongConL.py +27 -17
LongConL.py CHANGED
@@ -73,23 +73,33 @@ class LongConLDataset(datasets.GeneratorBasedBuilder):
73
  ),
74
  ]
75
 
76
- def _generate_examples(self, file_path):
77
- """Generate examples from the dataset CSV."""
78
- data = pd.read_csv(file_path)
79
- print("Data loaded from file:", file_path)
80
- print(data.head()) # Display first few rows
81
- data_dict = data.to_dict(orient="records")
82
- print(f"Number of examples to generate: {len(data_dict)}")
83
-
84
- for id_, row in enumerate(data_dict):
85
- yield id_, {
86
- "Citation": row["Citation"],
87
- "Full Case Name": row["Full Case Name"],
88
- "Opinion Text": row["Opinion Text"],
89
- "Numerical Label": row.get("Numerical Label", None), # Use .get() to handle missing keys
90
- "Text Label": row["Text Label"],
91
- }
92
-
 
 
 
 
 
 
 
 
 
 
93
 
94
 
95
  # Use a dynamic config
 
73
  ),
74
  ]
75
 
76
+ def _generate_examples(self, file_path):
77
+ """Generate examples from the dataset CSV."""
78
+ data = pd.read_csv(file_path)
79
+ print("Data loaded from file:", file_path)
80
+ print(data.head()) # Display first few rows
81
+
82
+ # Check if the DataFrame is empty or has the correct columns
83
+ if data.empty:
84
+ print(f"Warning: No data found in {file_path}")
85
+ return # Early exit if there's no data
86
+
87
+ expected_columns = {"Citation", "Full Case Name", "Opinion Text", "Numerical Label", "Text Label"}
88
+ if not expected_columns.issubset(data.columns):
89
+ print(f"Warning: Missing columns in {file_path}. Expected columns: {expected_columns}. Found columns: {set(data.columns)}")
90
+ return # Early exit if columns are missing
91
+
92
+ data_dict = data.to_dict(orient="records")
93
+ print(f"Number of examples to generate: {len(data_dict)}")
94
+
95
+ for id_, row in enumerate(data_dict):
96
+ yield id_, {
97
+ "Citation": row["Citation"],
98
+ "Full Case Name": row["Full Case Name"],
99
+ "Opinion Text": row["Opinion Text"],
100
+ "Numerical Label": row.get("Numerical Label", None),
101
+ "Text Label": row["Text Label"],
102
+ }
103
 
104
 
105
  # Use a dynamic config