Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
meezlung committed Dec 18, 2024
1 parent ef17862 commit f0cd1ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crs_scraper/data_sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self, subjects_with_time: ListOfCoursesWithTime) -> None:
self.subjects_with_time = subjects_with_time
self.optimized_schedule = []

# We need to generalize the code for this because there will be more possible day combinations
self.days_mapping = {
"M": ["Monday"],
"T": ["Tuesday"],
Expand Down Expand Up @@ -178,10 +179,9 @@ def parse_time(self, time: str) -> tuple[datetime, datetime]:
return start_time, end_time

def parse_days(self, days: str) -> list[str]:
return self.days_mapping[days] # We need to generalize the code for this because there will be more possible day combinations

def check_conflict(self, accumulated_schedule: list[Schedule], new_schedule: Schedule) -> bool: # Still need to test this
return self.days_mapping[days]

def check_conflict(self, accumulated_schedule: list[Schedule], new_schedule: Schedule) -> bool:
for existing_schedule in accumulated_schedule:
for entry1 in existing_schedule:
for entry2 in new_schedule:
Expand All @@ -203,6 +203,7 @@ def check_conflict(self, accumulated_schedule: list[Schedule], new_schedule: Sch

return False

# Implement DP here or simply just cache state space
def backtrack(self, subjects_with_time: ListOfCoursesWithTime,
current_index: int,
current_schedule: ListOfCoursesWithTime,
Expand Down Expand Up @@ -289,7 +290,6 @@ def calculate_average_probability(self, schedule: ListOfCoursesWithTime) -> floa
return sum(probabilities) / len(probabilities) if probabilities else 0.0

def rank_by_probability(self, all_schedules: list[ListOfCoursesWithTime]) -> list[ListOfCoursesWithTime]:
# Rank schedules by average probability
all_schedules.sort(
key=self.calculate_average_probability,
reverse=True
Expand Down

0 comments on commit f0cd1ea

Please sign in to comment.