scaiag commited on
Commit
8eba039
·
verified ·
1 Parent(s): b4953c1

Upload Sheets_generator.ipynb

Browse files
Files changed (1) hide show
  1. Sheets_generator.ipynb +497 -0
Sheets_generator.ipynb ADDED
@@ -0,0 +1,497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "markdown",
19
+ "source": [
20
+ "# Receipt"
21
+ ],
22
+ "metadata": {
23
+ "id": "wEKMGOFvSV_V"
24
+ }
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": null,
29
+ "metadata": {
30
+ "id": "iGlVFh9Yf1ar"
31
+ },
32
+ "outputs": [],
33
+ "source": [
34
+ "import random\n",
35
+ "import math\n",
36
+ "\n",
37
+ "vocabulary = [\n",
38
+ " \"Apple\", \"Banana\", \"Coffee\", \"Dumpling\", \"Eggs\", \"Fries\", \"Garlic\", \"Ham\",\n",
39
+ " \"Ice cream\", \"Juice\", \"Ketchup\", \"Lemon\", \"Milk\", \"Noodles\", \"Orange\",\n",
40
+ " \"Pasta\", \"Quinoa\", \"Rice\", \"Salad\", \"Tea\", \"Udon\", \"Vinegar\", \"Water\", \"Yogurt\",\n",
41
+ " \"Bread\", \"Cheese\", \"Donuts\", \"Espresso\", \"Fish\", \"Grapes\", \"Honey\",\n",
42
+ " \"Jam\", \"Kiwi\", \"Lobster\", \"Mango\", \"Nuts\", \"Oatmeal\", \"Pizza\", \"Ramen\",\n",
43
+ " \"Soda\", \"Tuna\", \"Vanilla\", \"Wine\", \"Zucchini\", \"Steak\", \"Burger\", \"Chicken\",\n",
44
+ " \"Pork\", \"Beef\", \"Lamb\", \"Tofu\", \"Avocado\", \"Tomato\", \"Potato\", \"Carrot\",\n",
45
+ " \"Broccoli\", \"Cauliflower\", \"Spinach\", \"Lettuce\", \"Cucumber\", \"Onion\",\n",
46
+ " \"Bottled water\", \"Sparkling water\", \"Green tea\", \"Black tea\", \"Beer\", \"Wine\",\n",
47
+ " \"Whiskey\", \"Vodka\", \"Rum\", \"Gin\", \"Tequila\", \"Cocktail\", \"Smoothie\", \"Milkshake\",\n",
48
+ " \"Shampoo\", \"Conditioner\", \"Soap\", \"Toothpaste\", \"Toothbrush\", \"Floss\", \"Mouthwash\",\n",
49
+ " \"Detergent\", \"Fabric softener\", \"Bleach\", \"Disinfectant\", \"Sponge\", \"Brush\",\n",
50
+ " \"Toilet paper\", \"Paper towel\", \"Tissues\", \"Napkins\", \"Trash bags\", \"Vacuum cleaner\",\n",
51
+ " \"Mop\", \"Broom\", \"Dustpan\", \"Duster\", \"Wipes\", \"Air freshener\", \"Candle\",\n",
52
+ " \"Light bulb\", \"Batteries\", \"Extension cord\", \"Plug adapter\", \"Hanger\",\n",
53
+ " \"Laundry basket\", \"Iron\", \"Ironing board\", \"Scissors\", \"Tape\", \"Glue\",\n",
54
+ " \"Nail clipper\", \"Razor\", \"Shaving cream\", \"Deodorant\", \"Perfume\", \"Cologne\",\n",
55
+ " \"Lotion\", \"Sunscreen\", \"Insect repellent\", \"Band-aids\", \"Cotton swabs\",\n",
56
+ " \"Notebook\", \"Journal\", \"Planner\", \"Calendar\", \"Pen\", \"Pencil\", \"Marker\",\n",
57
+ " \"Highlighter\", \"Eraser\", \"Ruler\", \"Stapler\", \"Staples\", \"Paper clips\",\n",
58
+ " \"Binder\", \"Folder\", \"Envelope\", \"Sticky notes\", \"Index cards\", \"Tape dispenser\",\n",
59
+ " \"Calculator\", \"Laptop\", \"Tablet\", \"E-reader\", \"Charger\", \"USB drive\",\n",
60
+ " \"Memory card\", \"External hard drive\", \"Mouse\", \"Keyboard\", \"Monitor\",\n",
61
+ " \"Headphones\", \"Speakers\", \"Webcam\", \"Microphone\", \"Printer\", \"Scanner\",\n",
62
+ " \"Ink cartridge\", \"Toner\", \"Paper\", \"Cardstock\", \"Laminating sheets\",\n",
63
+ " \"T-shirt\", \"Shirt\", \"Blouse\", \"Sweater\", \"Jacket\", \"Coat\", \"Jeans\",\n",
64
+ " \"Pants\", \"Shorts\", \"Skirt\", \"Dress\", \"Suit\", \"Tie\", \"Socks\", \"Underwear\",\n",
65
+ " \"Bra\", \"Pajamas\", \"Bathrobe\", \"Slippers\", \"Shoes\", \"Boots\", \"Sandals\",\n",
66
+ " \"Sneakers\", \"Hat\", \"Cap\", \"Beanie\", \"Scarf\", \"Gloves\", \"Mittens\",\n",
67
+ " \"Sunglasses\", \"Glasses\", \"Watch\", \"Wallet\", \"Purse\", \"Backpack\", \"Tote bag\",\n",
68
+ " \"Luggage\", \"Umbrella\", \"Belt\", \"Jewelry\", \"Necklace\", \"Bracelet\", \"Ring\",\n",
69
+ " \"Starbucks\", \"McDonald's\", \"Burger King\", \"KFC\", \"Subway\", \"Pizza Hut\",\n",
70
+ " \"Domino's\", \"Walmart\", \"Target\", \"Costco\", \"Kroger\", \"Safeway\", \"Trader Joe's\",\n",
71
+ " \"Whole Foods\", \"CVS\", \"Walgreens\", \"Home Depot\", \"Lowe's\", \"Best Buy\",\n",
72
+ " \"Apple Store\", \"Microsoft Store\", \"Amazon\", \"eBay\", \"Etsy\", \"Netflix\",\n",
73
+ " \"Spotify\", \"Uber\", \"Lyft\", \"Airbnb\", \"Nike\", \"Adidas\", \"Puma\", \"Reebok\",\n",
74
+ " \"H&M\", \"Zara\", \"Gap\", \"Old Navy\", \"IKEA\", \"Wayfair\", \"7-Eleven\", \"FedEx\",\n",
75
+ " \"UPS\", \"USPS\", \"Internet\", \"Phone service\", \"Cable TV\", \"Streaming\", \"Electricity\", \"Gas\",\n",
76
+ " \"Water\", \"Sewage\", \"Trash collection\", \"Rent\", \"Mortgage\", \"Insurance\",\n",
77
+ " \"Car payment\", \"Gas\", \"Parking\", \"Toll\", \"Bus fare\", \"Train ticket\",\n",
78
+ " \"Plane ticket\", \"Hotel\", \"Gym membership\", \"Haircut\", \"Manicure\", \"Pedicure\",\n",
79
+ " \"Massage\", \"Therapy\", \"Doctor visit\", \"Dentist\", \"Veterinarian\", \"Tuition\",\n",
80
+ " \"Tutoring\", \"Course fee\", \"Subscription\", \"Donation\", \"Tip\", \"Tax\",\n",
81
+ " \"Cleaning service\", \"Lawn care\", \"Snow removal\", \"Plumber\", \"Electrician\",\n",
82
+ " \"Repair service\", \"Installation fee\", \"Delivery fee\", \"Shipping\"\n",
83
+ "]\n",
84
+ "\n",
85
+ "def generate_random_price(op_type=None):\n",
86
+ " if op_type is None:\n",
87
+ " op_type = random.choice([\"simple\", \"divide\", \"minus\", \"multiply\"])\n",
88
+ "\n",
89
+ " if op_type == \"simple\":\n",
90
+ " # Simple price: 1.5-50 with 0-2 decimal places\n",
91
+ " price = round(random.uniform(1.5, 50), random.randint(0, 2))\n",
92
+ " return price, f\"{price:.2f}\" if price % 1 != 0 else f\"{int(price)}\"\n",
93
+ "\n",
94
+ " elif op_type == \"divide\":\n",
95
+ " # Price divided by (2-4)\n",
96
+ " original = round(random.uniform(8, 100), random.randint(0, 2))\n",
97
+ " divisor = random.randint(2, 4)\n",
98
+ " result = original / divisor\n",
99
+ " return result, f\"{original:.2f}/{divisor}={result:.2f}\"\n",
100
+ "\n",
101
+ " elif op_type == \"minus\":\n",
102
+ " # Price with a discount\n",
103
+ " original = round(random.uniform(10, 80), random.randint(0, 2))\n",
104
+ " discount = round(random.uniform(1, original/3), random.randint(0, 2))\n",
105
+ " result = original - discount\n",
106
+ " return result, f\"{original:.2f}-{discount:.2f}={result:.2f}\"\n",
107
+ "\n",
108
+ " elif op_type == \"multiply\":\n",
109
+ " # Price with tax or service charge\n",
110
+ " base = round(random.uniform(8, 50), random.randint(0, 2))\n",
111
+ " multiplier = round(random.uniform(1.05, 1.25), 2)\n",
112
+ " result = base * multiplier\n",
113
+ " return result, f\"{base:.2f}*{multiplier:.2f}={result:.2f}\"\n",
114
+ "\n",
115
+ "def format_item_line(item, price_text):\n",
116
+ " #shuffle\n",
117
+ " if random.random() < 0.5:\n",
118
+ " return f\"{price_text}{item}\"\n",
119
+ " else:\n",
120
+ " return f\"{item}{price_text}\"\n",
121
+ "\n",
122
+ "\n",
123
+ "def generate_random_bill(num_items=1000, include_division=True):\n",
124
+ " bill_items = []\n",
125
+ " total = 0\n",
126
+ "\n",
127
+ " # Create a copy of vocabulary and shuffle it to avoid duplicates\n",
128
+ " available_items = random.sample(vocabulary, min(len(vocabulary), num_items*2))\n",
129
+ "\n",
130
+ " # Generate items\n",
131
+ " for _ in range(num_items):\n",
132
+ " item = available_items.pop() if available_items else random.choice(vocabulary)\n",
133
+ "\n",
134
+ " # Decide operation type with weights\n",
135
+ " op_weights = {\"simple\": 0.55, \"divide\": 0.25, \"minus\": 0.1, \"multiply\": 0.1}\n",
136
+ " op_type = random.choices(\n",
137
+ " list(op_weights.keys()),\n",
138
+ " weights=list(op_weights.values()),\n",
139
+ " k=1\n",
140
+ " )[0]\n",
141
+ "\n",
142
+ " # Special case: if include_division is True, make sure we have at least one division\n",
143
+ " if include_division and _ == num_items - 1 and not any(item[1].find('/') != -1 for item in bill_items):\n",
144
+ " op_type = \"divide\"\n",
145
+ "\n",
146
+ " value, price_text = generate_random_price(op_type)\n",
147
+ " bill_items.append((item, price_text, value))\n",
148
+ " total += value\n",
149
+ "\n",
150
+ " # Format the bill\n",
151
+ " bill_text = \"\"\n",
152
+ " for item, price_text, _ in bill_items:\n",
153
+ " formatted_line = format_item_line(item, price_text)\n",
154
+ " bill_text += f\"{formatted_line}\\n\"\n",
155
+ "\n",
156
+ " # Add total\n",
157
+ " bill_text += f\"\\nTotal Number = {total:.2f}\"\n",
158
+ " bill_text += f\"\\nTotal Items = {len(bill_items)}\"\n",
159
+ "\n",
160
+ " return bill_text\n",
161
+ "\n",
162
+ "def main():\n",
163
+ " # Generate a bill with a random number of items\n",
164
+ " num_items = random.randint(1000, 1001)\n",
165
+ " bill = generate_random_bill(num_items)\n",
166
+ "\n",
167
+ " with open(\"random_bill.txt\", \"w\", encoding=\"utf-8\") as f:\n",
168
+ " f.write(bill)\n",
169
+ " print(\"\\nBill has been saved to 'random_bill.txt'\")\n"
170
+ ]
171
+ },
172
+ {
173
+ "cell_type": "code",
174
+ "source": [
175
+ "import os\n",
176
+ "import datetime\n",
177
+ "\n",
178
+ "def save_bill_to_file(bill_text, num_items, count, directory=\"/content/bills/\", filename=None):\n",
179
+ " # Create directory if it doesn't exist\n",
180
+ " os.makedirs(directory, exist_ok=True)\n",
181
+ "\n",
182
+ " if num_items is None and count is None:\n",
183
+ " raise ValueError(\"Either num_items or count must be provided\")\n",
184
+ "\n",
185
+ " filename = filename or f\"bill_{num_items}_{count}.txt\"\n",
186
+ "\n",
187
+ " if os.path.isfile(filename):\n",
188
+ " return filename\n",
189
+ "\n",
190
+ " # Full path\n",
191
+ " filepath = os.path.join(directory, filename)\n",
192
+ "\n",
193
+ " # Save the bill\n",
194
+ " with open(filepath, \"w\", encoding=\"utf-8\") as f:\n",
195
+ " f.write(bill_text)\n",
196
+ "\n",
197
+ " return filepath\n",
198
+ "\n",
199
+ "# Generate multiple bills\n",
200
+ "def generate_multiple_bills(count=100, num_items=1000, directory=\"/content/bills/\"):\n",
201
+ " bills_info = []\n",
202
+ "\n",
203
+ " for i in range(count):\n",
204
+ " # Random number of items\n",
205
+ " min_items = num_items - 50\n",
206
+ " max_items = num_items + 50\n",
207
+ " items = random.randint(min_items, max_items)\n",
208
+ "\n",
209
+ " # Generate bill\n",
210
+ " bill_text = generate_random_bill(items)\n",
211
+ "\n",
212
+ " # Create filename\n",
213
+ " filename = f\"bill_{num_items}_{i+1}.txt\"\n",
214
+ "\n",
215
+ " # Save bill\n",
216
+ " filepath = save_bill_to_file(bill_text, num_items, i+1, directory+str(num_items)+'/', filename)\n",
217
+ "\n",
218
+ " # Store info\n",
219
+ " bills_info.append({\n",
220
+ " \"index\": i+1,\n",
221
+ " \"filepath\": filepath,\n",
222
+ " })\n",
223
+ "\n",
224
+ " return bills_info\n",
225
+ "\n",
226
+ "generate_multiple_bills(count=100, num_items=1000, directory=\"/content/bills/\")"
227
+ ],
228
+ "metadata": {
229
+ "id": "KkIxfRxFpwtv"
230
+ },
231
+ "execution_count": null,
232
+ "outputs": []
233
+ },
234
+ {
235
+ "cell_type": "markdown",
236
+ "source": [
237
+ "# Vital Log"
238
+ ],
239
+ "metadata": {
240
+ "id": "uusf4fQBSKL2"
241
+ }
242
+ },
243
+ {
244
+ "cell_type": "code",
245
+ "source": [
246
+ "import numpy as np\n",
247
+ "import pandas as pd\n",
248
+ "import matplotlib.pyplot as plt\n",
249
+ "import random\n",
250
+ "import os\n",
251
+ "from datetime import datetime, timedelta\n",
252
+ "\n",
253
+ "\n",
254
+ "def generate_random_start_time():\n",
255
+ " start_date = datetime(2020, 1, 1)\n",
256
+ " end_date = datetime(2025, 12, 31)\n",
257
+ " delta = end_date - start_date\n",
258
+ " random_days = random.randint(0, delta.days)\n",
259
+ " random_seconds = random.randint(0, 86400 - 1)\n",
260
+ " return start_date + timedelta(days=random_days, seconds=random_seconds)\n",
261
+ "\n",
262
+ "def generate_heart_rate_data(num_points):\n",
263
+ " states = []\n",
264
+ " heart_rates = []\n",
265
+ "\n",
266
+ " for i in range(num_points):\n",
267
+ " state = random.choices(['rest', 'exercise', 'recovery'], weights=[0.8, 0.1, 0.1])[0]\n",
268
+ " if state == 'rest':\n",
269
+ " hr = np.random.normal(70, 3)\n",
270
+ " elif state == 'exercise':\n",
271
+ " hr = np.random.normal(140, 8)\n",
272
+ " else: # recovery\n",
273
+ " hr = np.random.normal(90, 5)\n",
274
+ "\n",
275
+ " states.append(state)\n",
276
+ " heart_rates.append(int(hr))\n",
277
+ "\n",
278
+ " return heart_rates, states\n",
279
+ "\n",
280
+ "\n",
281
+ "def generate_vital_log(count=50, num_points = 100, directory=None):\n",
282
+ " interval_minutes = 10\n",
283
+ " start_time = generate_random_start_time()\n",
284
+ " timestamps = [start_time + timedelta(minutes=i * interval_minutes) for i in range(num_points)]\n",
285
+ "\n",
286
+ " heart_rates, states = generate_heart_rate_data(num_points)\n",
287
+ "\n",
288
+ " vital_log = pd.DataFrame({\n",
289
+ " 'timestamp': timestamps,\n",
290
+ " 'heart_rate': heart_rates,\n",
291
+ " 'state': states\n",
292
+ " })\n",
293
+ "\n",
294
+ " vital_log_serialized = vital_log.copy()\n",
295
+ " vital_log_serialized['timestamp'] = vital_log_serialized['timestamp'].dt.strftime('%Y-%m-%d %H:%M:%S')\n",
296
+ "\n",
297
+ " json_data = vital_log_serialized.to_json(orient='records', indent=2)\n",
298
+ "\n",
299
+ " os.makedirs(directory, exist_ok=True)\n",
300
+ " csv_path = f\"heartrate_{num_points}_{count+1}.csv\"\n",
301
+ " csv_path = os.path.join(directory, csv_path)\n",
302
+ " vital_log.to_csv(csv_path, index=False)\n",
303
+ "\n",
304
+ " json_path = f\"heartrate_{num_points}_{count+1}.json\"\n",
305
+ " json_path = os.path.join(directory, json_path)\n",
306
+ " with open(json_path, 'w') as f:\n",
307
+ " f.write(json_data)\n",
308
+ "\n",
309
+ "num_points = 1000\n",
310
+ "count = 50\n",
311
+ "directory=\"/content/drive/MyDrive/sheets_vital_log/\"\n",
312
+ "for i in range(count):\n",
313
+ " generate_vital_log(count=i, num_points=num_points, directory=directory+str(num_points)+'/')"
314
+ ],
315
+ "metadata": {
316
+ "id": "XZeMvlAvpCSi"
317
+ },
318
+ "execution_count": null,
319
+ "outputs": []
320
+ },
321
+ {
322
+ "cell_type": "code",
323
+ "source": [
324
+ "import json\n",
325
+ "import random\n",
326
+ "\n",
327
+ "counts = 50\n",
328
+ "\n",
329
+ "heart_rate_variations = [\n",
330
+ " lambda hr: f\"The true heart rate is {hr}.\",\n",
331
+ " lambda hr: f\"The heart rate = {hr}.\",\n",
332
+ " lambda hr: f\"HR: {hr} (beats per minute).\",\n",
333
+ " lambda hr: f\"Current heart rate: {hr} BPM.\",\n",
334
+ " lambda hr: f\"Heart rate measured at {hr}.\",\n",
335
+ " lambda hr: f\"{hr} — that's the heart rate!\",\n",
336
+ " lambda hr: f\"Your heart is beating at {hr} BPM.\",\n",
337
+ " lambda hr: f\"Pulse rate detected: {hr}.\",\n",
338
+ " lambda hr: f\"Heart rate reading: {hr} beats per minute.\",\n",
339
+ " lambda hr: f\"{hr} BPM — steady and normal.\",\n",
340
+ " lambda hr: f\"The monitor shows a heart rate of {hr}.\",\n",
341
+ " lambda hr: f\"Heart rate (measured): {hr}.\",\n",
342
+ " lambda hr: f\"BPM = {hr} (heart rate).\",\n",
343
+ " lambda hr: f\"Your current pulse is {hr} beats per minute.\",\n",
344
+ " lambda hr: f\"Heart rate recorded as {hr} BPM.\",\n",
345
+ " lambda hr: f\"{hr} — the magic number for your heart rate!\",\n",
346
+ " lambda hr: f\"HR measurement result: {hr}.\",\n",
347
+ " lambda hr: f\"Beats per minute: {hr}.\",\n",
348
+ " lambda hr: f\"The heart is ticking at {hr} BPM.\",\n",
349
+ " lambda hr: f\"Heart rate analysis: {hr} beats per minute.\"\n",
350
+ "]\n",
351
+ "\n",
352
+ "variations = [\n",
353
+ " lambda key,value: f\"{key}:{value}\",\n",
354
+ " lambda key,value: f\"{key}={value}\",\n",
355
+ " lambda key,value: f\"{key} is {value}\",\n",
356
+ "]\n",
357
+ "\n",
358
+ "fake_heart_rate_variations = [\n",
359
+ " lambda hr: f\"The fake heart rate is {hr}.\",\n",
360
+ " lambda hr: f\"Fake HR: {hr} bpm.\",\n",
361
+ "]\n",
362
+ "\n",
363
+ "#\n",
364
+ "for num_items in [100, 200, 500, 1000]:\n",
365
+ " for j in range(counts):\n",
366
+ " prompt_path = f'/content/drive/MyDrive/sheets_vital_log/{num_items}/heartrate_{num_items}_{j+1}.json'\n",
367
+ "\n",
368
+ " with open(prompt_path, 'r') as infile:\n",
369
+ " data = json.load(infile)\n",
370
+ "\n",
371
+ " lines = []\n",
372
+ " for line in data:\n",
373
+ " random_variation = random.choice(heart_rate_variations)\n",
374
+ " hr_text = random_variation(line[\"heart_rate\"])\n",
375
+ "\n",
376
+ " fake_hr = random.randint(50, 200) # Adjust range as needed\n",
377
+ " fake_hr_text = random.choice(fake_heart_rate_variations)(fake_hr)\n",
378
+ "\n",
379
+ " # line = f\"timestamp:{line['timestamp']} {hr_text} state:{line['state']}\"\n",
380
+ " # line = \" \".join(f\"{key}:{value}\" for key, value in line.items())\n",
381
+ " time_variation = random.choice(variations)\n",
382
+ " time_text = time_variation(\"timestamp\", line[\"timestamp\"])\n",
383
+ " state_variation = random.choice(variations)\n",
384
+ " state_text = state_variation(\"state\", line[\"state\"])\n",
385
+ "\n",
386
+ " if random.random() < 0.5:\n",
387
+ " line = f\"{time_text} {fake_hr_text} {hr_text} {state_text}\"\n",
388
+ " else:\n",
389
+ " line = f\"{time_text} {hr_text} {fake_hr_text} {state_text}\"\n",
390
+ "\n",
391
+ " lines.append(line)\n",
392
+ "\n",
393
+ " output_file = f'/content/drive/MyDrive/sheets_vital_log/{num_items}/heartrate_{num_items}_{j+1}.txt'\n",
394
+ "\n",
395
+ " with open(output_file, 'w') as outfile:\n",
396
+ " outfile.write(\"\\n\".join(lines))"
397
+ ],
398
+ "metadata": {
399
+ "id": "RPPoDBfJ5JeM"
400
+ },
401
+ "execution_count": null,
402
+ "outputs": []
403
+ },
404
+ {
405
+ "cell_type": "markdown",
406
+ "source": [
407
+ "# Transcript"
408
+ ],
409
+ "metadata": {
410
+ "id": "TxAubn6gSf9H"
411
+ }
412
+ },
413
+ {
414
+ "cell_type": "code",
415
+ "source": [
416
+ "!pip install faker\n",
417
+ "import pandas as pd\n",
418
+ "import random\n",
419
+ "from faker import Faker\n",
420
+ "import os\n",
421
+ "\n",
422
+ "def generate_transcript(count=50, num_students = 100, directory=\"/content/drive/MyDrive/sheets_transcript/\"):\n",
423
+ " fake = Faker()\n",
424
+ " names = [fake.name() for _ in range(num_students)]\n",
425
+ "\n",
426
+ " subjects = ['Math', 'Chemistry', 'Biology', 'Physics', 'Geography']\n",
427
+ "\n",
428
+ " data = {'Name': names}\n",
429
+ " for subject in subjects:\n",
430
+ " data[subject] = [random.randint(0, 100) for _ in range(num_students)]\n",
431
+ "\n",
432
+ " df = pd.DataFrame(data)\n",
433
+ " json_data = df.to_json(orient='records')\n",
434
+ "\n",
435
+ " os.makedirs(directory, exist_ok=True)\n",
436
+ " csv_path = f\"transcript_{num_students}_{count+1}.csv\"\n",
437
+ " csv_path = os.path.join(directory, csv_path)\n",
438
+ " df.to_csv(csv_path, index=False)\n",
439
+ "\n",
440
+ " json_path = f\"transcript_{num_students}_{count+1}.json\"\n",
441
+ " json_path = os.path.join(directory, json_path)\n",
442
+ " with open(json_path, 'w') as f:\n",
443
+ " f.write(json_data)\n",
444
+ "\n",
445
+ "count = 50\n",
446
+ "num_students = 1000\n",
447
+ "directory=\"/content/drive/MyDrive/sheets_transcript/\"\n",
448
+ "for i in range(count):\n",
449
+ " generate_transcript(count=i, num_students=num_students, directory=directory+str(num_students)+'/')"
450
+ ],
451
+ "metadata": {
452
+ "id": "Ol17CCnIh9FP"
453
+ },
454
+ "execution_count": null,
455
+ "outputs": []
456
+ },
457
+ {
458
+ "cell_type": "code",
459
+ "source": [
460
+ "import json\n",
461
+ "\n",
462
+ "counts = 50\n",
463
+ "variations = [\n",
464
+ " lambda key,value: f\"{key}:{value}\",\n",
465
+ " lambda key,value: f\"{key}={value}\",\n",
466
+ " lambda key,value: f\"{key} is {value}\",\n",
467
+ "]\n",
468
+ "#\n",
469
+ "for num_items in [100, 200, 500, 1000]:\n",
470
+ " for j in range(counts):\n",
471
+ " prompt_path = f'/content/drive/MyDrive/sheets_transcript/{num_items}/transcript_{num_items}_{j+1}.json'\n",
472
+ "\n",
473
+ " with open(prompt_path, 'r') as infile:\n",
474
+ " data = json.load(infile)\n",
475
+ "\n",
476
+ " lines = []\n",
477
+ "\n",
478
+ " for line_data in data:\n",
479
+ " line = \"\"\n",
480
+ " for key, value in line_data.items():\n",
481
+ " random_variation = random.choice(variations)\n",
482
+ " line=line+random_variation(key=key,value=value)+\" \"\n",
483
+ " lines.append(line.strip())\n",
484
+ "\n",
485
+ " output_file = f'/content/drive/MyDrive/sheets_transcript/{num_items}/transcript_{num_items}_{j+1}.txt'\n",
486
+ "\n",
487
+ " with open(output_file, 'w') as outfile:\n",
488
+ " outfile.write(\"\\n\".join(lines))"
489
+ ],
490
+ "metadata": {
491
+ "id": "waA7fHuV5gM4"
492
+ },
493
+ "execution_count": null,
494
+ "outputs": []
495
+ }
496
+ ]
497
+ }