Vu Anh commited on
Commit
6b29edc
Β·
1 Parent(s): 0702fa5

Refactor validation script - simple and elegant

Browse files

- Reduced from 41 lines to 29 lines
- Single main() function with clear logic
- Concise output with essential information
- Added shebang for direct execution
- Returns boolean for programmatic use
- Clean, readable, and maintainable code

Files changed (1) hide show
  1. validate.py +15 -27
validate.py CHANGED
@@ -1,41 +1,29 @@
1
- """
2
- Validation script to verify the UTS2017_Bank dataset can be loaded from HuggingFace Hub.
3
- """
4
 
5
  from datasets import load_dataset
6
 
7
 
8
- def validate_huggingface_loading():
9
- """Validate that the dataset can be loaded from HuggingFace Hub."""
10
-
11
- print("πŸ” UTS2017_Bank Dataset Validation")
12
- print("=" * 60)
13
- print("VALIDATING HUGGINGFACE HUB LOADING")
14
- print("=" * 60)
15
-
16
  configs = ["classification", "sentiment", "aspect_sentiment"]
17
 
 
 
18
  for config in configs:
19
  try:
20
- print(f"\nπŸ€— Loading from Hub - config: {config}")
21
  dataset = load_dataset("undertheseanlp/UTS2017_Bank", config)
22
-
23
- print(" βœ“ Successfully loaded from HuggingFace Hub")
24
- print(f" βœ“ Train: {len(dataset['train'])} examples")
25
- print(f" βœ“ Test: {len(dataset['test'])} examples")
26
-
27
- sample = dataset["train"][0]
28
- print(f" βœ“ Sample keys: {list(sample.keys())}")
29
-
30
  except Exception as e:
31
- print(f" ❌ Failed to load {config} from Hub: {e}")
 
32
 
33
- print("\n" + "=" * 60)
34
- print("βœ… VALIDATION COMPLETE")
35
- print("=" * 60)
36
- print("πŸŽ‰ Dataset can be loaded from HuggingFace Hub!")
37
- print("πŸ’‘ Usage: load_dataset('undertheseanlp/UTS2017_Bank', config_name)")
38
 
39
 
40
  if __name__ == "__main__":
41
- validate_huggingface_loading()
 
1
+ #!/usr/bin/env python3
2
+ """Validate UTS2017_Bank dataset loading from HuggingFace Hub."""
 
3
 
4
  from datasets import load_dataset
5
 
6
 
7
+ def main():
8
+ """Test loading all dataset configurations from HuggingFace Hub."""
 
 
 
 
 
 
9
  configs = ["classification", "sentiment", "aspect_sentiment"]
10
 
11
+ print("πŸ” Validating UTS2017_Bank dataset...")
12
+
13
  for config in configs:
14
  try:
 
15
  dataset = load_dataset("undertheseanlp/UTS2017_Bank", config)
16
+ train_size = len(dataset["train"])
17
+ test_size = len(dataset["test"])
18
+ print(f"βœ… {config}: {train_size} train, {test_size} test")
 
 
 
 
 
19
  except Exception as e:
20
+ print(f"❌ {config}: {e}")
21
+ return False
22
 
23
+ print("\nπŸŽ‰ All configurations loaded successfully!")
24
+ print("πŸ’‘ Usage: load_dataset('undertheseanlp/UTS2017_Bank', '<config>')")
25
+ return True
 
 
26
 
27
 
28
  if __name__ == "__main__":
29
+ main()