Skip to content

Commit f260c8c

Browse files
committed
Get room name instead of using other
1 parent 47fb9ad commit f260c8c

File tree

3 files changed

+26
-38
lines changed

3 files changed

+26
-38
lines changed

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/valyala/fastjson v1.6.4
1313
go.mongodb.org/mongo-driver v1.17.3
1414
golang.org/x/net v0.36.0
15+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
1516
)
1617

1718
require (
@@ -57,6 +58,8 @@ require (
5758
github.com/json-iterator/go v1.1.12 // indirect
5859
github.com/klauspost/compress v1.17.8 // indirect
5960
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
61+
github.com/kr/pretty v0.3.1 // indirect
62+
github.com/kr/text v0.2.0 // indirect
6063
github.com/leodido/go-urn v1.4.0 // indirect
6164
github.com/mailru/easyjson v0.9.0 // indirect
6265
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -65,6 +68,7 @@ require (
6568
github.com/montanaflynn/stats v0.7.1 // indirect
6669
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
6770
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
71+
github.com/rogpeppe/go-internal v1.13.1 // indirect
6872
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
6973
github.com/ugorji/go/codec v1.2.12 // indirect
7074
github.com/xdg-go/pbkdf2 v1.0.0 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ
5252
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
5353
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 h1:Om6kYQYDUk5wWbT0t0q6pvyM49i9XZAv9dDrkDA7gjk=
5454
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
55+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
5556
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5657
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5758
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -121,8 +122,11 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
121122
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
122123
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
123124
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
125+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
124126
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
125127
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
128+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
129+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
126130
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
127131
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
128132
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo=
@@ -144,10 +148,12 @@ github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhA
144148
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
145149
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
146150
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
151+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
147152
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
148153
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
149154
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
150155
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
156+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
151157
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
152158
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
153159
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

parser/calendarParser.go

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
157134
func 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

Comments
 (0)