cipher982 commited on
Commit
58cb8a8
·
verified ·
1 Parent(s): 1547efb

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitignore +59 -0
  2. LICENSE +55 -0
  3. README.md +172 -3
  4. test_dataset.py +113 -0
  5. upload_to_hf.py +137 -0
  6. wine_text_126k.parquet +3 -0
.gitignore ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+
24
+ # Virtual environments
25
+ .env
26
+ .venv
27
+ env/
28
+ venv/
29
+ ENV/
30
+ env.bak/
31
+ venv.bak/
32
+
33
+ # IDE
34
+ .vscode/
35
+ .idea/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # OS
41
+ .DS_Store
42
+ .DS_Store?
43
+ ._*
44
+ .Spotlight-V100
45
+ .Trashes
46
+ ehthumbs.db
47
+ Thumbs.db
48
+
49
+ # HuggingFace Hub
50
+ .huggingface/
51
+
52
+ # Temporary files
53
+ *.tmp
54
+ *.temp
55
+
56
+ # Data processing scripts (keep dataset files only)
57
+ process_data.py
58
+ clean_data.py
59
+ upload.py
LICENSE ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Creative Commons Attribution 4.0 International License
2
+
3
+ Wine Text Dataset 126K
4
+ Copyright (c) 2025 David Rose
5
+
6
+ This work is licensed under the Creative Commons Attribution 4.0 International License.
7
+ To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/
8
+ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
9
+
10
+ ===============================================================================
11
+
12
+ You are free to:
13
+
14
+ Share — copy and redistribute the material in any medium or format
15
+ Adapt — remix, transform, and build upon the material for any purpose,
16
+ even commercially.
17
+
18
+ The licensor cannot revoke these freedoms as long as you follow the license terms.
19
+
20
+ -------------------------------------------------------------------------------
21
+
22
+ Under the following terms:
23
+
24
+ Attribution — You must give appropriate credit, provide a link to the license,
25
+ and indicate if changes were made. You may do so in any reasonable
26
+ manner, but not in any way that suggests the licensor endorses you
27
+ or your use.
28
+
29
+ No additional restrictions — You may not apply legal terms or technological
30
+ measures that legally restrict others from doing
31
+ anything the license permits.
32
+
33
+ -------------------------------------------------------------------------------
34
+
35
+ Notices:
36
+
37
+ You do not have to comply with the license for elements of the material in the
38
+ public domain or where your use is permitted by an applicable exception or limitation.
39
+
40
+ No warranties are given. The license may not give you all of the permissions
41
+ necessary for your intended use. For example, other rights such as publicity,
42
+ privacy, or moral rights may limit how you use the material.
43
+
44
+ ===============================================================================
45
+
46
+ DATA COLLECTION NOTICE:
47
+
48
+ The underlying wine information was collected from publicly available retailer
49
+ websites for research purposes. The dataset compilation, data cleaning, stable
50
+ ID system, and structured format represent the original contribution covered
51
+ by this license.
52
+
53
+ Users should respect the intellectual property rights of the original wine
54
+ descriptions and retailer content. This dataset is intended for research,
55
+ education, and fair use applications.
README.md CHANGED
@@ -1,3 +1,172 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: Wine Text Dataset 126K
3
+ tags:
4
+ - wine
5
+ - food-and-drink
6
+ - text-classification
7
+ - text-generation
8
+ - recommendation-systems
9
+ task_categories:
10
+ - text-classification
11
+ - text-generation
12
+ - feature-extraction
13
+ size_categories:
14
+ - 100K<n<1M
15
+ license: cc-by-4.0
16
+ language:
17
+ - en
18
+ dataset_info:
19
+ features:
20
+ - name: id
21
+ dtype: string
22
+ - name: name
23
+ dtype: string
24
+ - name: description
25
+ dtype: string
26
+ - name: price
27
+ dtype: float32
28
+ - name: category
29
+ dtype: string
30
+ - name: region
31
+ dtype: string
32
+ - name: image_id
33
+ dtype: string
34
+ config_name: default
35
+ splits:
36
+ - name: train
37
+ num_bytes: 30729648
38
+ num_examples: 125787
39
+ download_size: 30729648
40
+ dataset_size: 30729648
41
+ ---
42
+
43
+ # Wine Text Dataset 126K
44
+
45
+ A comprehensive dataset of 125,787 wine records with detailed descriptions, pricing, categories, and regions. This dataset is perfect for natural language processing, recommendation systems, and wine-related machine learning tasks.
46
+
47
+ ## Dataset Description
48
+
49
+ This dataset contains rich textual information about wines scraped from wine retailer websites. Each record includes the wine name, detailed tasting notes and descriptions, pricing information, wine category classification, and geographic region.
50
+
51
+ ### Key Features
52
+
53
+ - **125,787 wine records** with high-quality text descriptions
54
+ - **Rich descriptions** with tasting notes, production details, and wine characteristics
55
+ - **Pricing information** for market analysis and recommendation systems
56
+ - **Wine categories**: red_wine, white_wine, sparkling, rosé, dessert, other
57
+ - **Geographic regions**: california, france, italy, other
58
+ - **Stable IDs** for linking with companion image dataset
59
+
60
+ ## Dataset Structure
61
+
62
+ ```python
63
+ {
64
+ "id": "wine_000001", # Unique wine identifier
65
+ "name": "Dom Perignon Vintage 2008", # Wine name
66
+ "description": "Complex champagne with...", # Detailed description
67
+ "price": 199.97, # Price in USD
68
+ "category": "sparkling", # Wine type classification
69
+ "region": "france", # Geographic region
70
+ "image_id": "wine_000001" # Links to companion image dataset
71
+ }
72
+ ```
73
+
74
+ ## Usage
75
+
76
+ ```python
77
+ from datasets import load_dataset
78
+
79
+ # Load the dataset
80
+ dataset = load_dataset("YOUR_USERNAME/wine-text-126k")
81
+
82
+ # Access the data
83
+ wine_data = dataset["train"]
84
+
85
+ # Example: Get wine descriptions for NLP tasks
86
+ descriptions = wine_data["description"]
87
+
88
+ # Example: Filter by wine category
89
+ sparkling_wines = wine_data.filter(lambda x: x["category"] == "sparkling")
90
+
91
+ # Example: Price analysis
92
+ import pandas as pd
93
+ df = wine_data.to_pandas()
94
+ price_stats = df.groupby("category")["price"].describe()
95
+ ```
96
+
97
+ ## Data Quality
98
+
99
+ - **Complete coverage**: No missing values in any field
100
+ - **Rich text**: 91% of wines have detailed descriptions (average ~500 characters)
101
+ - **Price range**: $0 - $19,999 (median: $24, mean: $49)
102
+ - **Geographic diversity**: Wines from major wine regions worldwide
103
+ - **Category balance**: Good representation across wine types
104
+
105
+ ### Category Distribution
106
+
107
+ | Category | Count | Percentage |
108
+ |------------|---------|------------|
109
+ | red_wine | 62,187 | 49.4% |
110
+ | other | 30,509 | 24.3% |
111
+ | white_wine | 26,251 | 20.9% |
112
+ | rosé | 2,713 | 2.2% |
113
+ | dessert | 2,520 | 2.0% |
114
+ | sparkling | 1,607 | 1.3% |
115
+
116
+ ### Region Distribution
117
+
118
+ | Region | Count | Percentage |
119
+ |------------|---------|------------|
120
+ | other | 105,841 | 84.2% |
121
+ | california | 10,887 | 8.7% |
122
+ | france | 4,839 | 3.8% |
123
+ | italy | 4,220 | 3.4% |
124
+
125
+ ## Companion Datasets
126
+
127
+ This text dataset is designed to work with a companion image dataset:
128
+
129
+ - **wine-images-126k** (coming soon): Contains wine bottle images linked by `image_id`
130
+
131
+ ## Use Cases
132
+
133
+ - **Text Classification**: Wine category prediction from descriptions
134
+ - **Recommendation Systems**: Content-based wine recommendations
135
+ - **Price Prediction**: Predict wine prices from descriptions and features
136
+ - **Text Generation**: Generate wine descriptions and tasting notes
137
+ - **Sentiment Analysis**: Analyze wine review sentiment and quality indicators
138
+ - **Information Extraction**: Extract wine characteristics (vintage, grape varieties, etc.)
139
+
140
+ ## Ethical Considerations
141
+
142
+ - **Data Source**: Collected from public wine retailer websites
143
+ - **Privacy**: No personal information included
144
+ - **Commercial Use**: Please respect original retailers' terms of service
145
+ - **Accuracy**: Descriptions and prices reflect retailer data at time of collection
146
+
147
+ ## Citation
148
+
149
+ If you use this dataset in your research, please cite:
150
+
151
+ ```bibtex
152
+ @dataset{wine_text_126k,
153
+ title={Wine Text Dataset 126K},
154
+ author={David Rose},
155
+ year={2025},
156
+ url={https://huggingface.co/datasets/cipher982/wine-text-126k}
157
+ }
158
+ ```
159
+
160
+ ## License
161
+
162
+ This dataset is released under the **Creative Commons Attribution 4.0 International License (CC-BY-4.0)**.
163
+
164
+ **You are free to:**
165
+ - 🔄 **Share** — copy and redistribute the material in any medium or format
166
+ - 🔧 **Adapt** — remix, transform, and build upon the material for any purpose, even commercially
167
+
168
+ **Under the following terms:**
169
+ - 📝 **Attribution** — You must give appropriate credit and indicate if changes were made
170
+
171
+ **Data Collection Notice:**
172
+ The underlying wine information was collected from publicly available retailer websites for research purposes under fair use. This dataset compilation and the stable ID system is our original contribution. Users should respect the intellectual property rights of the original wine descriptions and retailer content.
test_dataset.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test the wine dataset before uploading to HuggingFace.
4
+ This script validates the data quality and structure.
5
+ """
6
+
7
+ import pandas as pd
8
+ from datasets import Dataset, Features, Value
9
+
10
+ def test_dataset():
11
+ """Test the dataset structure and quality."""
12
+
13
+ print("🍷 Testing Wine Text Dataset")
14
+ print("=" * 40)
15
+
16
+ # Load the parquet file
17
+ print("📁 Loading dataset...")
18
+ df = pd.read_parquet("wine_text_126k.parquet")
19
+
20
+ # Basic structure validation
21
+ print(f"✅ Dataset loaded: {len(df):,} records")
22
+ print(f"✅ Columns: {list(df.columns)}")
23
+
24
+ # Check schema matches expected
25
+ expected_columns = ['id', 'name', 'description', 'price', 'category', 'region', 'image_id']
26
+ if list(df.columns) == expected_columns:
27
+ print("✅ Schema matches expected structure")
28
+ else:
29
+ print(f"❌ Schema mismatch. Expected: {expected_columns}")
30
+ return False
31
+
32
+ # Data quality checks
33
+ print("\n📊 Data Quality Report:")
34
+
35
+ # Check for missing values
36
+ missing = df.isnull().sum()
37
+ if missing.any():
38
+ print("❌ Missing values found:")
39
+ for col, count in missing.items():
40
+ if count > 0:
41
+ print(f" {col}: {count:,} missing")
42
+ return False
43
+ else:
44
+ print("✅ No missing values")
45
+
46
+ # Check ID format
47
+ id_pattern_valid = df['id'].str.match(r'^wine_\d{6}$').all()
48
+ if id_pattern_valid:
49
+ print("✅ ID format is correct (wine_XXXXXX)")
50
+ else:
51
+ print("❌ Invalid ID format found")
52
+ return False
53
+
54
+ # Check price range
55
+ price_min, price_max = df['price'].min(), df['price'].max()
56
+ print(f"✅ Price range: ${price_min:.2f} - ${price_max:.2f}")
57
+
58
+ # Check categories
59
+ categories = df['category'].value_counts()
60
+ print(f"✅ Wine categories ({len(categories)} types):")
61
+ for cat, count in categories.head().items():
62
+ print(f" {cat}: {count:,}")
63
+
64
+ # Check regions
65
+ regions = df['region'].value_counts()
66
+ print(f"✅ Regions ({len(regions)} types):")
67
+ for region, count in regions.items():
68
+ print(f" {region}: {count:,}")
69
+
70
+ # Test HuggingFace Dataset creation
71
+ print("\n🤗 Testing HuggingFace Dataset creation...")
72
+ try:
73
+ features = Features({
74
+ "id": Value("string"),
75
+ "name": Value("string"),
76
+ "description": Value("string"),
77
+ "price": Value("float32"),
78
+ "category": Value("string"),
79
+ "region": Value("string"),
80
+ "image_id": Value("string"),
81
+ })
82
+
83
+ dataset = Dataset.from_pandas(df, features=features, preserve_index=False)
84
+ print(f"✅ HuggingFace Dataset created successfully")
85
+ print(f"✅ Dataset info: {dataset}")
86
+
87
+ # Sample a few records
88
+ print("\n📋 Sample records:")
89
+ for i in range(min(3, len(dataset))):
90
+ record = dataset[i]
91
+ print(f" ID: {record['id']}")
92
+ print(f" Name: {record['name'][:50]}...")
93
+ print(f" Price: ${record['price']:.2f}")
94
+ print(f" Category: {record['category']}")
95
+ print()
96
+
97
+ return True
98
+
99
+ except Exception as e:
100
+ print(f"❌ HuggingFace Dataset creation failed: {e}")
101
+ return False
102
+
103
+ if __name__ == "__main__":
104
+ success = test_dataset()
105
+
106
+ if success:
107
+ print("🎉 All tests passed! Dataset is ready for upload.")
108
+ print("\n📤 To upload to HuggingFace Hub:")
109
+ print("1. pip install datasets huggingface_hub pyarrow")
110
+ print("2. huggingface-cli login")
111
+ print("3. python upload_to_hf.py --username YOUR_USERNAME")
112
+ else:
113
+ print("❌ Tests failed. Please fix the issues above before uploading.")
upload_to_hf.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Upload the wine text dataset to HuggingFace Hub.
4
+
5
+ Prerequisites:
6
+ 1. Install required packages: pip install datasets huggingface_hub pyarrow
7
+ 2. Login to HF Hub: huggingface-cli login
8
+ 3. Replace YOUR_USERNAME with your actual HF username
9
+
10
+ Usage:
11
+ python upload_to_hf.py --username YOUR_USERNAME [--private]
12
+ """
13
+
14
+ import argparse
15
+ import pandas as pd
16
+ from datasets import Dataset, Features, Value
17
+ from huggingface_hub import HfApi
18
+ import os
19
+
20
+ def create_dataset_features():
21
+ """Define the dataset schema."""
22
+ return Features({
23
+ "id": Value("string"),
24
+ "name": Value("string"),
25
+ "description": Value("string"),
26
+ "price": Value("float32"),
27
+ "category": Value("string"),
28
+ "region": Value("string"),
29
+ "image_id": Value("string"),
30
+ })
31
+
32
+ def load_and_prepare_dataset(parquet_file="wine_text_126k.parquet"):
33
+ """Load the parquet file and create a HuggingFace Dataset."""
34
+
35
+ print(f"Loading dataset from {parquet_file}...")
36
+ df = pd.read_parquet(parquet_file)
37
+
38
+ # Verify data quality
39
+ print(f"Dataset shape: {df.shape}")
40
+ print(f"Columns: {list(df.columns)}")
41
+
42
+ # Check for any missing values
43
+ missing = df.isnull().sum()
44
+ if missing.any():
45
+ print("Warning: Missing values found:")
46
+ print(missing[missing > 0])
47
+ else:
48
+ print("✅ No missing values found")
49
+
50
+ # Create HuggingFace Dataset with proper features
51
+ features = create_dataset_features()
52
+ dataset = Dataset.from_pandas(df, features=features, preserve_index=False)
53
+
54
+ print(f"✅ Created HuggingFace Dataset with {len(dataset):,} records")
55
+ return dataset
56
+
57
+ def upload_dataset(dataset, username, repo_name="wine-text-126k", private=False):
58
+ """Upload the dataset to HuggingFace Hub."""
59
+
60
+ full_repo_name = f"{username}/{repo_name}"
61
+
62
+ print(f"\n🚀 Uploading to HuggingFace Hub: {full_repo_name}")
63
+ print(f"Privacy: {'Private' if private else 'Public'}")
64
+
65
+ try:
66
+ # Create the repository (this will fail gracefully if it already exists)
67
+ api = HfApi()
68
+ try:
69
+ api.create_repo(
70
+ repo_id=full_repo_name,
71
+ repo_type="dataset",
72
+ private=private
73
+ )
74
+ print(f"✅ Created repository: {full_repo_name}")
75
+ except Exception as e:
76
+ if "already exists" in str(e).lower():
77
+ print(f"ℹ️ Repository already exists: {full_repo_name}")
78
+ else:
79
+ print(f"⚠️ Repository creation warning: {e}")
80
+
81
+ # Upload the dataset
82
+ print("📤 Uploading dataset files...")
83
+ dataset.push_to_hub(
84
+ full_repo_name,
85
+ private=private,
86
+ commit_message="Initial upload of wine text dataset"
87
+ )
88
+
89
+ print(f"\n🎉 Upload completed successfully!")
90
+ print(f"🔗 Dataset URL: https://huggingface.co/datasets/{full_repo_name}")
91
+ print(f"\n📖 Usage:")
92
+ print(f'from datasets import load_dataset')
93
+ print(f'dataset = load_dataset("{full_repo_name}")')
94
+
95
+ return True
96
+
97
+ except Exception as e:
98
+ print(f"❌ Upload failed: {e}")
99
+ print("\nTroubleshooting:")
100
+ print("1. Make sure you're logged in: huggingface-cli login")
101
+ print("2. Check your internet connection")
102
+ print("3. Verify the username is correct")
103
+ print("4. Ensure you have write permissions")
104
+ return False
105
+
106
+ def main():
107
+ parser = argparse.ArgumentParser(description="Upload wine dataset to HuggingFace Hub")
108
+ parser.add_argument("--username", required=True, help="Your HuggingFace username")
109
+ parser.add_argument("--private", action="store_true", help="Make the dataset private")
110
+ parser.add_argument("--parquet-file", default="wine_text_126k.parquet",
111
+ help="Path to the parquet file")
112
+
113
+ args = parser.parse_args()
114
+
115
+ # Check if parquet file exists
116
+ if not os.path.exists(args.parquet_file):
117
+ print(f"❌ Error: Parquet file not found: {args.parquet_file}")
118
+ print("Make sure you're running this script from the wine-text-126k directory")
119
+ return
120
+
121
+ print("🍷 Wine Text Dataset - HuggingFace Upload")
122
+ print("=" * 50)
123
+
124
+ # Load and prepare dataset
125
+ dataset = load_and_prepare_dataset(args.parquet_file)
126
+
127
+ # Upload to HuggingFace
128
+ success = upload_dataset(dataset, args.username, private=args.private)
129
+
130
+ if success:
131
+ print("\n✅ All done! Your dataset is now live on HuggingFace Hub.")
132
+ print("Don't forget to update the README.md with your actual username!")
133
+ else:
134
+ print("\n❌ Upload failed. Please check the error messages above.")
135
+
136
+ if __name__ == "__main__":
137
+ main()
wine_text_126k.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5eb086a2d7d0783fd1f6c9da78caf92cb0b041fbedb66511895bba9456cdced1
3
+ size 30732050