1
1
import { Course , Day , Module } from './types'
2
- import * as parseCsv from 'csv-parse/lib/sync'
3
- import * as _cliProgress from 'cli-progress'
4
2
import { read as readXLSX , utils } from 'xlsx'
5
3
import * as assert from 'assert'
6
4
@@ -14,8 +12,8 @@ const analyzeDayAndPeriod = (str: string): { day: Day; period: number }[] => {
14
12
//全ての曜日に対して
15
13
Object . entries ( Day ) . forEach ( ( k ) => {
16
14
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 ++ ) {
19
17
/*
20
18
strが{曜日}(任意の文字列){時限} にマッチするか調べる
21
19
任意の文字列を間に挟むことで検出が一度で済む
@@ -42,12 +40,27 @@ const analyzeDayAndPeriod = (str: string): { day: Day; period: number }[] => {
42
40
}
43
41
} )
44
42
45
- if ( / 集 中 / gm. test ( str ) )
43
+ // 集中
44
+ if ( str . includes ( Day . Intensive ) )
46
45
result . push ( {
47
46
day : Day . Intensive ,
48
47
period : 0 ,
49
48
} )
50
49
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
+
51
64
//どのテストにも合格しなかったが空文字でなければ仮にunknownとする
52
65
if ( str !== '' && result . length === 0 )
53
66
result . push ( { day : Day . Unknown , period : 0 } )
@@ -72,13 +85,26 @@ const analyzeModule = (str: string): Module[] => {
72
85
if ( / 春 [ A B C ] * B / gm. test ( str ) ) result . push ( Module . SpringB )
73
86
if ( / 春 [ A B C ] * C / gm. test ( str ) ) result . push ( Module . SpringC )
74
87
88
+ //「 春学期」記述の場合、kdb内部では春A~夏季扱いになっていた
89
+ if ( str . includes ( '春学期' ) )
90
+ result . push (
91
+ Module . SpringA ,
92
+ Module . SpringB ,
93
+ Module . SpringC ,
94
+ Module . SummerVacation
95
+ )
96
+
75
97
// 夏季休業中、通年のマッチング
76
98
if ( str . includes ( Module . SummerVacation ) ) result . push ( Module . SummerVacation )
77
99
78
100
if ( / 秋 [ A B C ] * A / gm. test ( str ) ) result . push ( Module . FallA )
79
101
if ( / 秋 [ A B C ] * B / gm. test ( str ) ) result . push ( Module . FallB )
80
102
if ( / 秋 [ A B C ] * C / gm. test ( str ) ) result . push ( Module . FallC )
81
103
104
+ //「 秋学期」記述の場合、kdb内部では秋A~春季扱いになっていた
105
+ if ( str . includes ( '秋学期' ) )
106
+ result . push ( Module . FallA , Module . FallB , Module . FallC , Module . SpringVacation )
107
+
82
108
// 春季休業中のマッチング
83
109
if ( str . includes ( Module . SpringVacation ) ) result . push ( Module . SpringVacation )
84
110
0 commit comments