Skip to content

Commit a517ce0

Browse files
committed
update: 応談/随時 7,8対応 春秋学期対応
1 parent b62679e commit a517ce0

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/parser.ts

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { Course, Day, Module } from './types'
2-
import * as parseCsv from 'csv-parse/lib/sync'
3-
import * as _cliProgress from 'cli-progress'
42
import { read as readXLSX, utils } from 'xlsx'
53
import * as assert from 'assert'
64

@@ -14,8 +12,8 @@ const analyzeDayAndPeriod = (str: string): { day: Day; period: number }[] => {
1412
//全ての曜日に対して
1513
Object.entries(Day).forEach((k) => {
1614
const day = k[1] as Day //月, 火 , .... , 日 のどれか
17-
// 1から6限について
18-
for (let i = 1; i <= 6; i++) {
15+
// 1から8限について
16+
for (let i = 1; i <= 8; i++) {
1917
/*
2018
strが{曜日}(任意の文字列){時限} にマッチするか調べる
2119
任意の文字列を間に挟むことで検出が一度で済む
@@ -42,12 +40,27 @@ const analyzeDayAndPeriod = (str: string): { day: Day; period: number }[] => {
4240
}
4341
})
4442

45-
if (//gm.test(str))
43+
// 集中
44+
if (str.includes(Day.Intensive))
4645
result.push({
4746
day: Day.Intensive,
4847
period: 0,
4948
})
5049

50+
// 応談
51+
if (str.includes(Day.Appointment))
52+
result.push({
53+
day: Day.Appointment,
54+
period: 0,
55+
})
56+
57+
// 随時
58+
if (str.includes(Day.AnyTime))
59+
result.push({
60+
day: Day.AnyTime,
61+
period: 0,
62+
})
63+
5164
//どのテストにも合格しなかったが空文字でなければ仮にunknownとする
5265
if (str !== '' && result.length === 0)
5366
result.push({ day: Day.Unknown, period: 0 })
@@ -72,13 +85,26 @@ const analyzeModule = (str: string): Module[] => {
7285
if (/[ABC]*B/gm.test(str)) result.push(Module.SpringB)
7386
if (/[ABC]*C/gm.test(str)) result.push(Module.SpringC)
7487

88+
//「 春学期」記述の場合、kdb内部では春A~夏季扱いになっていた
89+
if (str.includes('春学期'))
90+
result.push(
91+
Module.SpringA,
92+
Module.SpringB,
93+
Module.SpringC,
94+
Module.SummerVacation
95+
)
96+
7597
// 夏季休業中、通年のマッチング
7698
if (str.includes(Module.SummerVacation)) result.push(Module.SummerVacation)
7799

78100
if (/[ABC]*A/gm.test(str)) result.push(Module.FallA)
79101
if (/[ABC]*B/gm.test(str)) result.push(Module.FallB)
80102
if (/[ABC]*C/gm.test(str)) result.push(Module.FallC)
81103

104+
//「 秋学期」記述の場合、kdb内部では秋A~春季扱いになっていた
105+
if (str.includes('秋学期'))
106+
result.push(Module.FallA, Module.FallB, Module.FallC, Module.SpringVacation)
107+
82108
// 春季休業中のマッチング
83109
if (str.includes(Module.SpringVacation)) result.push(Module.SpringVacation)
84110

src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ export enum Day {
3939
Fri = '金',
4040
Sat = '土',
4141
Intensive = '集中',
42+
Appointment = '応談',
43+
AnyTime = '随時',
4244
Unknown = '不明',
4345
}

0 commit comments

Comments
 (0)