@@ -61,7 +61,7 @@ var buildingAbbreviations = map[string]string{
6161 "Student Union Food Court" : "SUFC" ,
6262 "Synergy Park North" : "SPN" ,
6363 "Synergy Park North 2" : "SP2" ,
64- "University Theater " : "TH" ,
64+ "University Theatre " : "TH" ,
6565 "Visitor Center" : "VC" ,
6666 "Waterview Science and Technology Center" : "WSTC" ,
6767 "Andromeda Hall & University Housing Office" : "RHA" ,
@@ -131,29 +131,6 @@ var validAbbreviations []string = []string{
131131 "RCW" ,
132132}
133133
134- // Some events refer to the room name instead of their number
135- // It's very likely that there are other named rooms with room numbers not added yet
136- // Maps room names to room number
137- var roomNumbers = map [string ]string {
138- "Artemis I" : "2.905A" ,
139- "Artemis II" : "2.905B" ,
140- "Main Gym" : "1.2" ,
141- "Auxiliary Gym" : "1.318" ,
142- "Axxess Atrium" : "1.100" ,
143- "Ballroom A" : "1.102A" ,
144- "Ballroom B" : "1.102B" ,
145- "Ballroom C" : "1.102C" ,
146- "AHT Gallery" : "3.102" ,
147- "SP/N Gallery" : "11.150" ,
148- "Galaxy Rooms" : "2.602" ,
149- "ATC Auditorium" : "1.102" ,
150- "ATC Lecture Hall" : "l.l02" ,
151- "TI Auditorium" : "2.102" ,
152- "SSA Auditorium" : "13.330" ,
153- "Clark Auditorium" : "1.315" ,
154- "ATC Lobby" : "1.700" ,
155- }
156-
157134func ParseCalendar (inDir string , outDir string ) {
158135
159136 calendarFile , err := os .ReadFile (inDir + "/eventScraped.json" )
@@ -188,41 +165,42 @@ func ParseCalendar(inDir string, outDir string) {
188165 room := roomRegexp .FindString (* location )
189166
190167 // buildingRegexp might capture something that isn't a valid building abbreviation (e.g., UTD)
191- if checkBuilding := slices .Contains (validAbbreviations , building ); ! checkBuilding {
192- building = ""
193- }
168+ isValidBuilding := slices .Contains (validAbbreviations , building )
194169
170+ // If location doesn't have building abbreviation or buildingRegexp captured an invalid abbreviation,
171+ // check for the full building name
195172 lowercaseLocation := strings .ToLower (* location )
196- // If location doesn't have building abbreviation, check for the full building name
197- if building == "" {
173+ if building == "" || ! isValidBuilding {
198174 for key := range buildingAbbreviations {
199175 if strings .Contains (lowercaseLocation , strings .ToLower (key )) {
200176 building = buildingAbbreviations [key ]
177+ isValidBuilding = true
201178 }
202179 }
203180 }
204181
205- // If location doesn't have room number, check for room names
206- if room == "" {
207- for key := range roomNumbers {
208- if strings .Contains (lowercaseLocation , strings .ToLower (key )) {
209- room = roomNumbers [key ]
210- }
211- }
182+ // If location doesn't have room number, check to see if location included a room
183+ if room == "" && isValidBuilding {
184+ locationParts := strings .SplitN (* location , "," , 2 )
185+ if len (locationParts ) == 2 {
186+ room = locationParts [1 ]
187+ }
212188 }
213189
214190 // If building is still empty string, then location was initally an empty string
215- // or was a place off campus
191+ // or location was a place off campus
216192 if building == "" {
217193 building = "Other"
218194 }
219195
220196 // If room is still empty string, then location was initally an empty string, or
221- // the room had no equivalent room number , or was a place off campus
197+ // location did not include a room, or location was a place off campus
222198 if room == "" {
223199 room = "Other"
224200 }
225201
202+ fmt .Println (* location + " | " + building + " | " + room )
203+
226204 if _ , exists := multiBuildingMap [date ]; ! exists {
227205 multiBuildingMap [date ] = make (map [string ]map [string ][]schema.Event )
228206 }
0 commit comments