def main(argv): test = course_dictionary.create_course_dict() #Test to see if all prereqs are in the file. # prereq_list = [single_course for vals in test.values() # for some_prereqs in vals.prereqs for single_course in some_prereqs] # for prereq in prereq_list: # if prereq not in test: # print(prereq) # for key in test: # #Test to see if every course has a term and credits. # if not test[key].terms or not test[key].credits: # print(key) # #Test to see if a course's prereqs include the course itself # if key in [course for prereq in test[key].prereqs for course in prereq]: # print(key) # Prints all the CS courses. # for key in test: # if key.program == 'CS': # print(key, test[key]) #print(test[("ANTH", "4154")].prereqs) # Test 2, usual 0 credit semesters #solution = williamju_scheduler.course_scheduler (test, [("CS", "2231"), ("CS", "3251"), ("CS", "statsprobability")], [('MATH', '2810'), ("MATH", "2820"), ("MATH", "3640")]) #solution = williamju_scheduler.course_scheduler(test, [("CS", "major"), ("CS", "2201")], []) # solution = williamju_scheduler.course_scheduler(test, [("CS", "major"), ("CS", "4269")], []) # Test 3, usual 0 credit semesters #solution = williamju_scheduler.course_scheduler(test, [("CS", "core"), ("CS", "1101")], []) # Test 6, no errors #solution = williamju_scheduler.course_scheduler(test, [("CS", "major"), ('JAPN', '3891')], [('CS', '1101'), ('JAPN', '1101')]) # Test 8, no errors solution = williamju_scheduler.course_scheduler(test, [("CS", "major"), ('JAPN', '2201')], []) # Test 7, usual 0 credit semesters #solution = williamju_scheduler.course_scheduler(test, [("CS", "mathematics")], []) #solution = williamju_scheduler.course_scheduler(test, [("BME", "4900W")], []) # Test 4, no errors #solution = williamju_scheduler.course_scheduler(test, [("CS", "major")], [('CS', '1101')]) # Test 5 #solution = williamju_scheduler.course_scheduler(test, [("CS", "major"), ('ANTH', '4345'), ('ARTS', '3600'), ('ASTR', '3600'), ('BME', '4500'), ('BUS', '2300'), ('CE', '3705')], []) # Test 1, usual 0 credit semesters #solution = williamju_scheduler.course_scheduler(test, [("CS", "1101")], []) # Test 0 #solution = williamju_scheduler.course_scheduler(test, [("CS", "1101")], [("CS", "1101")]) #solution = williamju_scheduler.course_scheduler(test, [('ANTH', '4345'), ('ARTS', '3600'), ('BME', '4500'), ('BUS', '2300'), ('CE', '3705'), ('LAT', '3140'), ('JAPN', '3891')], []) for course in solution: print(course, solution[course])
def main(argv): #Creates a dictionary to use for testing test = course_dictionary.create_course_dict() #Creates an object course Course = namedtuple('Course', 'program, designation') #initializes a course(state) to be the end goal of the schedule #'CS', 'major' goals = [ Course('CS', 'major'), Course('ANTH', '4345'), Course('ARTS', '3600'), Course('ASTR', '3600'), Course('BME', '4500'), Course('BUS', '2300'), Course('CE', '3705'), Course('LAT', '3140'), Course('JAPN', '3891') ] semesters = [('Frosh', 'Fall'), ('Frosh', 'Spring'), ('Soph', 'Fall'), ('Soph', 'Spring'), ('Junior', 'Fall'), ('Junior', 'Spring'), ('Senior', 'Fall'), ('Senior', 'Spring')] semDict = {semester: [0, []] for semester in semesters} print(test[Course('CS', 'major')]) #initializes the initial state to no courses #use form [('MATH', '2810'),xxx init_state = [('CS', '1101')] #course_dictionary.print_dict(test) search(semesters, semDict, test, goals, init_state) check = -1 for goal in goals: for semester in semDict: if goal in semDict[semester][1]: check = 1 if check is -1: semDict = {} for each in semDict: print(each, semDict[each]) finalSchedule = {} print('Done')
def main(argv): test = course_dictionary.create_course_dict() Course = namedtuple('Course', 'program, designation') #goals = [('CS', '2231'), ('CS', '3251'), ('CS', 'statsprobability')] #init_state = [('MATH', '2810'), ('MATH', '2820'), ('MATH', '3640')] #goals = [('CS', 'core'), ('CS', '1101')] #goals = [('CS', 'major'), ('ANTH', '4345'), ('ARTS', '3600'), ('ASTR', '3600'), ('BME', '4500'), ('BUS', '2300'), ('CE', '3705'), ('LAT', '3140'), #('JAPN', '3891')] #goals = [('CS', 'major'), ('JAPN', '3891')] #goals = [('CS', 'major')] #init_state = [('CS', '1101')] #init_state = [] goals = [('CS', '1101')] init_state = [] plan = course_scheduler(test, goals, init_state) for key in plan: print(key, plan[key]) print('Done')
if operator.term.semester == Semester.Summer: continue schedule[operator.term].append(operator) for term in schedule: hours = 0 for operator in schedule[term]: hours += int(operator.courseInfo.credits) print(term, hours, " [") for operator in schedule[term]: if not is_higher_level_course_info(operator.courseInfo): print(operator, ",") print("]") if __name__ == '__main__': course_dict: Dict[Course, CourseInfo] = cd.create_course_dict() schedule_dict = course_scheduler(course_dict, goal_conditions=[ Course(program='CS', designation='major'), Course('JAPN', '3891') ], initial_state=[Course('CS', '1101')]) df = pd.DataFrame.from_dict(schedule_dict, orient='index') course_desc_dict: Dict[ Course, spm.CourseDesc] = spm.create_course_desc_dict(course_dict) course_names: List[str] = list() course_sums: List[str] = list() for course in schedule_dict.keys():
from pprint import pprint from typing import List, Dict, Tuple import spacy from spacy import displacy import course_dictionary as cd import sameerpuri_matcher as spm from pathlib import Path course_infos: Dict[cd.Course, cd.CourseInfo] = cd.create_course_dict() course_descs: Dict[cd.Course, spm.CourseDesc] = spm.create_course_desc_dict(course_infos) print('Loading...') print('Reading english word vector information...') nlp = spacy.load('en_core_web_lg') print('Analyzing course descriptions...') course_nlp_descs = {} course_nlp_names = {} for course in course_descs.keys(): course_nlp_descs[course] = nlp(course_descs[course].summary) course_nlp_names[course] = nlp(course_descs[course].name) print('Loaded!') def recommend_courses_using_search_text(search_text: str, num: int) -> List: search_text = nlp(search_text) text_similarities_dict: Dict[float, cd.Course] = { search_text.similarity(course_nlp_descs[course]): course for course in course_nlp_descs.keys() }
from flask import Flask, jsonify, render_template, request from typing import List, Tuple import course_dictionary as cd import click click.disable_unicode_literals_warning = True import sameerpuri_scheduler as sps import sameerpuri_matcher as spm import sameerpuri_recommender as spr app = Flask(__name__) course_dict = cd.create_course_dict() course_desc_dict = spm.create_course_desc_dict(course_dict) @app.route('/course/<program>/<int:designation>/<reqtype>') def get_course_desc(program: str, designation: int, reqtype: str): res = { 'summary': lambda course: course_desc_dict[course].summary, 'name': lambda course: course_desc_dict[course].name, 'formerly': lambda course: course_desc_dict[course].formerly, 'creditbracket': lambda course: course_desc_dict[course].creditbracket }[reqtype](cd.Course(program, str(designation))) return jsonify(res) @app.route('/') def index(): return render_template('index.html')