Skip to content

Commit

Permalink
ckp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Nagler committed Apr 7, 2024
1 parent be8ca76 commit efe23a5
Show file tree
Hide file tree
Showing 11 changed files with 1,223 additions and 0 deletions.
Binary file added assets/i/learning-chatgpt-01-reformat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/i/learning-chatgpt-02-prog.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions assets/i/learning-chatgpt-02-prog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
class Workout:
def __init__(self, date, warmup, strength_power, cool_down):
self.date = date
self.warmup = warmup
self.strength_power = strength_power
self.cool_down = cool_down

def display(self):
print(f"Date: {self.date}")
print("")

print("General Warm-Up:")
self.display_exercises(self.warmup)
print("")

print("Completed:")
print("Strength/Power:")
self.display_sets(self.strength_power)
print("")

print("General Cool Down:")
self.display_exercises(self.cool_down)

@staticmethod
def display_exercises(exercises):
for exercise in exercises:
print(f"- {exercise}")

@staticmethod
def display_sets(sets):
for i, set in enumerate(sets, 1):
print(f"Set {i}:")
for exercise, details in set.items():
print(f" {exercise}:")
for key, value in details.items():
print(f" {key}: {value}")


# Sample workout data
workout1 = Workout(
"Monday 3.23.20",
warmup=["3' movement on treadmill, bike, or fast-paced walking",
"Squat @ BW x 10 reps",
"RDL @ BW x 10 reps",
"Forward-backward lunge @ BW x 5 each side",
"Push-ups x 8-10 reps",
"TRX Rows x 8-10 reps"],
strength_power=[
{"KB Lateral Lunge": {"Use dumbbells": None, "Reps per side": 8, "Weight": 30}},
{"Full Sit-Up": {"Reps": 12}},
{"DB Push-Up-Row": {"Reps": 10, "Weight": 40}},
{"Speed Skaters": {"Seconds": 25}},
{"Leg Lift": {"Reps": 12}}
],
cool_down=["Static Stretching: Hamstrings",
"Quads",
"Glutes",
"Calves",
"Chest",
"Back",
"Shoulders"]
)

workout2 = Workout(
"Wednesday 3.25.20",
warmup=["3' movement on treadmill, bike, or fast-paced walking",
"Squat @ BW x 10 reps",
"RDL @ BW x 10 reps",
"Forward-backward lunge @ BW x 5 each side",
"Push-ups x 8-10 reps",
"TRX Row x 8-10 reps"],
strength_power=[],
cool_down=[]
)

# Display the workout
workout1.display()
print("")
workout2.display()
Binary file added assets/i/learning-chatgpt-03-prog.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions assets/i/learning-chatgpt-03-prog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import re

class WorkoutParser:
def __init__(self, text):
self.text = text

def parse(self):
workouts = []
workout_texts = re.split(r'REVIEW WORKOUT \(\d/\d DONE\)', self.text)
for workout_text in workout_texts:
if workout_text.strip():
workout = self._parse_workout(workout_text.strip())
workouts.append(workout)
return workouts

def _parse_workout(self, workout_text):
workout_info = workout_text.split('\n')
date = workout_info[0].strip()
warmup_index = workout_info.index('GENERAL WARM UP') + 1
strength_power_index = workout_info.index('STRENGTH/POWER') + 1
cool_down_index = workout_info.index('GENERAL COOL DOWN') + 1

warmup = workout_info[warmup_index:strength_power_index-1]
strength_power = workout_info[strength_power_index:cool_down_index-1]
cool_down = workout_info[cool_down_index:]

return {
'date': date,
'warmup': self._parse_section(warmup),
'strength_power': self._parse_strength_power(strength_power),
'cool_down': self._parse_section(cool_down)
}

def _parse_section(self, section):
exercises = []
for line in section:
if line.strip() and not line.startswith('COMPLETED'):
exercises.append(line.strip())
return exercises

def _parse_strength_power(self, section):
sets = []
current_set = None
for line in section:
if line.strip() and not line.startswith('COMPLETED'):
if line.startswith('SET'):
current_set = {}
sets.append(current_set)
else:
exercise, details = line.split(':', 1)
current_set[exercise.strip()] = {d.strip(): None for d in details.split(';')}
return sets

# Sample text
text = """
Rob Nagler
MONDAY 3.23.20
GENERAL WARM UP
HISTORY
Perform the following exercises:
-3' movement on treadmill, bike or fast-paced walking
-Squat @BW x10 reps
-RDL @BW x10 reps
-Forward-backward lunge @BW x5ea side
-Push ups x8-10 reps
-TRX Rows x8-10 reps

COMPLETED
STRENGTH/POWER
4 SETS
1
2
3
4
KB LATERAL LUNGE
TIPS HISTORY
Use dumbbells;
Reps for each side per set

REPS
WEIGHT
8
30
8
30
8
30
8
30
FULL SIT UP
TIPS HISTORY
REPS
12
12
12
12
DB PUSH UP-ROW
TIPS HISTORY
REPS
WEIGHT
10
40
10
40
10
40
10
40
SPEED SKATERS
TIPS HISTORY
SECONDS
WEIGHT
25
25
25
25
LEG LIFT
TIPS HISTORY
REPS
12
12
12
12
COMPLETED
GENERAL COOL DOWN
HISTORY
Static Stretching:
Hamstrings
Quads
Glutes
Calves
Chest
Back
Shoulders

COMPLETED
Write notes about your workout...
REVIEW WORKOUT (3/3 DONE)Rob Nagler
WEDNESDAY 3.25.20
GENERAL WARM UP
HISTORY
Perform the following exercises:
-3' movement on treadmill, bike or fast-paced walking
-Squat @BW x10 reps
-RDL @BW x10 reps
-Forward-backward lunge @BW x5ea side
-Push ups x8-10 reps
-TRX Row x8-10 reps

COMPLETED
STRENGTH/POWER
4 SETS
1
2
3
"""

# Parse the text
parser = WorkoutParser(text)
workouts = parser.parse()

# Display the parsed workouts
for workout in workouts:
print(f"Date: {workout['date']}")
print("Warm-Up:")
for exercise in workout['warmup']:
print(f"- {exercise}")
print("Strength/Power:")
for set in workout['strength_power']:
for exercise, details in set.items():
print(f"- {exercise}:")
for detail, value in details.items():
print(f" - {detail}: {value}")
print("Cool Down:")
for exercise in workout['cool_down']:
print(f"- {exercise}")
print()
Loading

0 comments on commit efe23a5

Please sign in to comment.