parser

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package parser converts scraped course and scheduling inputs into structured Nebula API schema documents.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Sections maps section IDs to the associated section records.
	Sections = make(map[primitive.ObjectID]*schema.Section)

	// Courses maps catalog identifiers to course definitions.
	Courses = make(map[string]*schema.Course)

	// Professors maps professor names to professor documents.
	Professors = make(map[string]*schema.Professor)

	// CourseIDMap maps course IDs to their catalog keys.
	CourseIDMap = make(map[primitive.ObjectID]string)

	// ProfessorIDMap maps professor IDs to their lookup keys.
	ProfessorIDMap = make(map[primitive.ObjectID]string)

	// ReqParsers maps course IDs to requisite parser functions.
	ReqParsers = make(map[primitive.ObjectID]func())

	// GradeMap stores grade distributions keyed by semester and section identifier.
	GradeMap map[string]map[string][]int
)
View Source
var ANDRegex = regexp.MustCompile(`(?i)\s+and\s+`)
View Source
var BUILDINGS_CATEGORY_IDS = []int{42138, 42141}

BUILDINGS_CATEGORY_IDS lists category identifiers for academic, administrative, and housing buildings on Concept3D.

View Source
var DefaultBuildings = map[string]string{
	"Activity Center":                              "AB",
	"Activity Center Bookstore":                    "ACB",
	"Administration":                               "AD",
	"Edith and Peter O’Donnell Jr. Athenaeum":      "APC",
	"Edith O'Donnell Arts and Technology Building": "ATC",
	"Lloyd V. Berkner Hall":                        "BE",
	"Bioengineering and Sciences Building":         "BSB",
	"Classroom Building":                           "CB",
	"Callier Center Richardson":                    "CR",
	"Callier Center Addition":                      "CRA",
	"Davidson-Gundy Alumni Center":                 "DGA",
	"Dining Hall West":                             "DHW",
	"Engineering and Computer Science North":       "ECSN",
	"Engineering and Computer Science South":       "ECSS",
	"Engineering and Computer Science West":        "ECSW",
	"Energy Plant":                                 "EP",
	"Founders Annex":                               "FA",
	"Facilities Management":                        "FM",
	"Founders North":                               "FN",
	"Founders Building":                            "FO",
	"Cecil H. Green Hall":                          "GR",
	"Karl Hoblitzelle Hall":                        "HH",
	"Erik Jonsson Academic Center":                 "JO",
	"Naveen Jindal School of Management":           "JSOM",
	"Eugene McDermott Library":                     "MC",
	"Modular Lab 1":                                "ML1",
	"Modular Lab 2":                                "ML2",
	"North Office Building":                        "NB",
	"North Lab":                                    "NL",
	"Police":                                       "PD",
	"Physics Annex":                                "PHA",
	"Physics Building":                             "PHY",
	"Natural Science and Engineering Research Lab": "RL",
	"Research and Operations Center":               "ROC",
	"Research and Operations Center West":          "ROW",
	"Service Building":                             "SB",
	"Sciences Building":                            "SCI",
	"Safety and Grounds":                           "SG",
	"Student Learning Center":                      "SLC",
	"Student Services Building Addition":           "SSA",
	"Student Services Building":                    "SSB",
	"Student Union":                                "SU",
	"Student Union Food Court":                     "SUFC",
	"Synergy Park North":                           "SPN",
	"Synergy Park North 2":                         "SP2",
	"University Theatre":                           "TH",
	"Visitor Center":                               "VC",
	"Waterview Science and Technology Center":      "WSTC",
	"Andromeda Hall & University Housing Office":   "RHA",
	"Capella Hall":                                 "RHC",
	"Helix Hall":                                   "RHH",
	"Sirius Hall":                                  "RHS",
	"Vega Hall":                                    "RHV",
	"Recreation Center West":                       "RCW",
	"SP/N Gallery":                                 "SP2",
}

Some events have only the building name, not the abbreviation Maps building names to their abbreviations

View Source
var DefaultValid []string = []string{
	"AB",
	"ACB",
	"AD",
	"APC",
	"ATC",
	"BE",
	"BSB",
	"CB",
	"CR",
	"CRA",
	"DGA",
	"DHW",
	"ECSN",
	"ECSS",
	"ECSW",
	"EP",
	"FA",
	"FM",
	"FN",
	"FO",
	"GR",
	"HH",
	"JO",
	"JSOM",
	"MC",
	"ML1",
	"ML2",
	"NB",
	"NL",
	"PD",
	"PHA",
	"PHY",
	"RL",
	"ROC",
	"ROW",
	"SB",
	"SCI",
	"SG",
	"SLC",
	"SSA",
	"SSB",
	"SU",
	"SUFC",
	"SPN",
	"SP2",
	"TH",
	"VC",
	"WSTC",
	"RHA",
	"RHC",
	"RHH",
	"RHS",
	"RHV",
	"RCW",
}

Valid building abreviations for checking

View Source
var Matchers []Matcher

Matchers contains the ordered collection of matcher rules applied during requisite parsing. NOTE: PARENTHESES ARE OF HIGHEST PRECEDENCE! (This is due to groupParens() handling grouping of parenthesized text before parsing begins)

View Source
var ORRegex = regexp.MustCompile(`(?i)\s+or\s+`)

Functions

func ANDMatcher

func ANDMatcher(group string, subgroups []string) interface{}

ANDMatcher parses conjunction-separated requisites into an AND collection requirement.

func ChoiceMatcher

func ChoiceMatcher(group string, subgroups []string) interface{}

ChoiceMatcher converts a subgroup collection into a mutually exclusive choice requirement.

func ConsentMatcher

func ConsentMatcher(group string, subgroups []string) interface{}

ConsentMatcher captures grantor consent requirements from requisite text.

func CoreCompletionMatcher

func CoreCompletionMatcher(group string, subgroups []string) interface{}

CoreCompletionMatcher indicates completion of a specific core category without an hour requirement.

func CoreMatcher

func CoreMatcher(group string, subgroups []string) interface{}

CoreMatcher creates a requirement for completion of a specific core course count.

func CourseMatcher

func CourseMatcher(group string, subgroups []string) interface{}

CourseMatcher returns a course requirement with the default minimum grade expectation.

func CourseMinGradeMatcher

func CourseMinGradeMatcher(group string, subgroups []string) interface{}

CourseMinGradeMatcher returns a course requirement enforcing a minimum grade when an ICN is found.

func GPAMatcher

func GPAMatcher(group string, subgroups []string) interface{}

GPAMatcher represents GPA-based prerequisites.

func GroupTagMatcher

func GroupTagMatcher(group string, subgroups []string) interface{}

GroupTagMatcher resolves stack-referenced groups by index.

func LimitMatcher

func LimitMatcher(group string, subgroups []string) interface{}

LimitMatcher produces a limit requirement that caps allowable credit hours.

func MajorMatcher

func MajorMatcher(group string, subgroups []string) interface{}

MajorMatcher produces a major-specific requirement.

func MajorMinorMatcher

func MajorMinorMatcher(group string, subgroups []string) interface{}

MajorMinorMatcher builds an OR collection spanning both major and minor requirements.

func MinorMatcher

func MinorMatcher(group string, subgroups []string) interface{}

MinorMatcher produces a minor-specific requirement.

func ORMatcher

func ORMatcher(group string, subgroups []string) interface{}

ORMatcher parses disjunction-separated requisites into an OR collection requirement.

func OtherMatcher

func OtherMatcher(group string, subgroups []string) interface{}

OtherMatcher wraps unmatched text in an OtherRequirement.

func Parse

func Parse(inDir string, outDir string, csvPath string, skipValidation bool)

Parse loads scraped course artifacts, applies parsing and validation, and persists structured results.

func ParseAcademicCalendars

func ParseAcademicCalendars(inDir string, outDir string)

func ParseAstra

func ParseAstra(inDir string, outDir string)

ParseAstra reads Astra scrape output and produces structured multi-building event JSON files.

func ParseCometCalendar

func ParseCometCalendar(inDir string, outDir string)

func ParseMapLocations

func ParseMapLocations(inDir string, outDir string)

ParseMapLocations filters Concept3D location exports to building records and writes normalized JSON output.

func ParseMazevo

func ParseMazevo(inDir string, outDir string)

ParseMazevo reads Mazevo scrape output and emits normalized multi-building event JSON.

func SubstitutionMatcher

func SubstitutionMatcher(parseFnc func(string, []string) interface{}) func(string, []string) interface{}

SubstitutionMatcher returns a matcher that replaces a subgroup with parseFnc's result before parsing the outer group. For example, "(OPRE 3360 or STAT 3360 or STAT 4351), and JSOM majors and minors only" becomes "... and @N".

func ThrowawayMatcher

func ThrowawayMatcher(group string, subgroups []string) interface{}

ThrowawayMatcher marks text that should be ignored during requisite evaluation.

Types

type InputData

type InputData struct {
	Fields string          `json:"fields"`
	Data   [][]interface{} `json:"data"`
}

InputData describes the raw Astra export payload containing fields metadata and row values.

type Matcher

type Matcher struct {
	Regex   *regexp.Regexp
	Handler func(string, []string) interface{}
}

Matcher defines a regex-driven handler used during requisite group parsing.

type SourceData

type SourceData struct {
	Bookings []map[string]interface{} `json:"bookings"`
}

SourceData represents the Mazevo API response containing booking records.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL