Upload example.py with huggingface_hub
Browse files- example.py +80 -0
example.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def display_dataset_statistics(dataset):
|
| 5 |
+
"""
|
| 6 |
+
Display overall statistics about the dataset.
|
| 7 |
+
|
| 8 |
+
Args:
|
| 9 |
+
dataset: A HuggingFace Dataset object.
|
| 10 |
+
"""
|
| 11 |
+
print("\n" + "=" * 50)
|
| 12 |
+
print(f"{'DATASET STATISTICS':^50}")
|
| 13 |
+
print("=" * 50)
|
| 14 |
+
|
| 15 |
+
print(f"\n📊 Number of entries: {len(dataset):,}")
|
| 16 |
+
|
| 17 |
+
# Convert to pandas for easier analysis
|
| 18 |
+
df = dataset.to_pandas()
|
| 19 |
+
|
| 20 |
+
# Count presentation types
|
| 21 |
+
if "status" in df.columns:
|
| 22 |
+
print("\n" + "-" * 30)
|
| 23 |
+
print("📝 PRESENTATION TYPES")
|
| 24 |
+
print("-" * 30)
|
| 25 |
+
status_counts = df["status"].value_counts()
|
| 26 |
+
for status, count in status_counts.items():
|
| 27 |
+
print(f" • {status}: {count:,} ({count / len(df) * 100:.1f}%)")
|
| 28 |
+
|
| 29 |
+
# Count venues
|
| 30 |
+
if "venue" in df.columns:
|
| 31 |
+
print("\n" + "-" * 30)
|
| 32 |
+
print("🏢 VENUES")
|
| 33 |
+
print("-" * 30)
|
| 34 |
+
venue_counts = df["venue"].value_counts()
|
| 35 |
+
for venue, count in venue_counts.items():
|
| 36 |
+
print(f" • {venue}: {count:,} ({count / len(df) * 100:.1f}%)")
|
| 37 |
+
|
| 38 |
+
# Count primary research areas
|
| 39 |
+
if "primary_area" in df.columns:
|
| 40 |
+
print("\n" + "-" * 30)
|
| 41 |
+
print("🔬 TOP 10 PRIMARY RESEARCH AREAS")
|
| 42 |
+
print("-" * 30)
|
| 43 |
+
area_counts = df["primary_area"].value_counts().head(10)
|
| 44 |
+
for area, count in area_counts.items():
|
| 45 |
+
print(f" • {area}: {count:,} ({count / len(df) * 100:.1f}%)")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def display_sample_entries(dataset, n=3):
|
| 49 |
+
"""
|
| 50 |
+
Display sample entries from the dataset.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
dataset: A HuggingFace Dataset object.
|
| 54 |
+
n: Number of samples to display.
|
| 55 |
+
"""
|
| 56 |
+
print("\n" + "=" * 50)
|
| 57 |
+
print(f"{'SAMPLE ENTRIES':^50}")
|
| 58 |
+
print("=" * 50)
|
| 59 |
+
|
| 60 |
+
for i in range(min(n, len(dataset))):
|
| 61 |
+
print(f"\n📄 SAMPLE {i + 1}")
|
| 62 |
+
print("-" * 30)
|
| 63 |
+
print(f"🎬 Video file: video/{dataset[i].get('video_file', 'N/A')}")
|
| 64 |
+
print(f"📝 Title: {dataset[i].get('title', 'N/A')}")
|
| 65 |
+
print(f"💡 TL;DR: {dataset[i].get('tldr', 'N/A')}")
|
| 66 |
+
print(f"🔬 Primary area: {dataset[i].get('primary_area', 'N/A')}")
|
| 67 |
+
print(f"🏷️ Keywords: {dataset[i].get('keywords', 'N/A')}")
|
| 68 |
+
print("=" * 50)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
if __name__ == "__main__":
|
| 72 |
+
# Load the dataset
|
| 73 |
+
dataset = load_dataset("vivianchen98/LearningPaper24", data_files="metadata/catalog.jsonl", split="train")
|
| 74 |
+
print(f"Successfully loaded LearningPaper24 dataset with {len(dataset)} entries.")
|
| 75 |
+
|
| 76 |
+
# Display statistics
|
| 77 |
+
display_dataset_statistics(dataset)
|
| 78 |
+
|
| 79 |
+
# Display sample entries
|
| 80 |
+
display_sample_entries(dataset)
|